Friday, April 17, 2015

Guest post by Ondrej Petrzilka - Space Engineers: Planets, scenarios and new multiplayer

Hello, I am Ondrej Petrzilka, for those who don't know me I am the lead developer for Space and Medieval Engineers. I joined Keen Software House in 2011 as a game programmer for Miner Wars 2081 and since then I have worked on various projects in the studio mostly on the development of Space Engineers. In this blog post I would like to put some light on our current and future plans with Space Engineers. Currently we’re working on three big things: planets, scenarios and new multiplayer.


Planets have been discussed many times and players have wanted them for a long time. I would like to give you more information about our intentions and the background of the idea.

When Space Engineers was released to Early Access, we were very pessimistic about planets, but that changed by the end of 2014, when the procedural asteroid generator was created. We realized that it could be possible to create bigger asteroids – more than 8 km across. When we discussed planets in the team, we’ve realized we don’t just want just big asteroids, we want planets with ‘everything’.

Planet features:
  • Decent size
  • Gravity (affecting ships too if possible)
  • Atmosphere
  • Terrain (mountains, canyons)
  • Vegetation (trees, bushes, grass)
  • Visible from big distance (1000+ km)

How big should the planet be? Currently we’re able to create ‘planets’ with a size of around 20 – 50 km. It’s quite small compared to Earth and technically, it’s not a planet. Even Pluto has a radius 1184 km and it’s classified as a dwarf planet. When we tried first prototypes of big asteroids, 8 km in diameter, it looked pretty big. With bigger sizes, gameplay issues emerged.

Imagine a planet with a radius of 100 km. You’ll get close to the planet to fill your screen from top to bottom. When you have default field of view (FOV in video options), you’ll be still 73 km away from the planet surface! When traveling at the maximum speed of 104 m/s, it will take you almost 12 minutes to reach the surface. That seems like too long.

How long would it take to fly around a 100 km planet? The circumference of a 100 km planet is 628 km. When traveling at maximum speed, it would take more than 90 minutes to fly around.

Solution. First we were thinking about changing the maximum speed, but it’s too problematic. We’re limited by physics stability, bullet-through-paper issues and other problems. We’ve decided to make planet size configurable in world options (minimum and maximum planet size). This way we can release planets soon and satisfy players who want small planets and also players who want huge planets. It’s possible that we will reevaluate maximum speed in future.

Gravity. Planets will have gravity which is similar to earth gravity. With distance from a planet, gravity will gradually decrease; bigger planets will have more gravity. We plan to apply planet gravity to ships as well.

Atmosphere. We plan to add atmosphere to certain planets; when there’s atmosphere, there will be vegetation. Other planets will be barren, without atmosphere. Vegetation should be very similar to what you see in Medieval Engineers. To achieve nice atmosphere effects, we’re planning to use a special shader which takes into account sun direction, air density, the distance light travels through air and other parameters. It will be possible to breathe freely and refill the oxygen tanks on a planet with atmosphere.

Visibility distance. Space Engineers has a default view distance of 20 km. If you were to fly toward a 30 km asteroid or planet, you would see nothing…nothing…nothing…and then suddenly a big planet would appear in front of you. This feels very weird and it would break the experience, so we had to come up with a solution.

One option was increasing view distance, but there’s still a limit of 50-70 km, because of Z-buffer precision. We wanted players to see planets from 1000 km distance or more. We’ve decided to render distant planets‘separately’. This allows players to see planets 10.000 km away, while other objects like ships and small asteroids are visible only to 20 km.


In last 15 months, we’ve added a large amount of game features, but we haven’t added much of the gameplay. Space Engineers is now sandbox game where you can do many crazy things…without any goal. We’re planning to add goals soon; you’ve probably seen the first scenario a week ago, this was just a testing scenario. More scenarios will follow; both single-player and multi-player.

The primary purpose of scenarios is to entertain players who seek goals and achievements in the game. The secondary purpose is to teach new players how to play the game and introduce them slowly to most of the game mechanics. A game like this, with a lot of features available at once, can be confusing for new players.

Single-player scenarios will consist of a series of objectives with possible branches (sometimes the player will be able to choose how to progress). Scenarios will take advantage of features which are already in game. First scenarios will be very straight-forward, to teach players certain mechanics, like mining or repairing the station. Then there will be more advanced scenarios with multiple ways of reaching the goal. An example can be: ‘destroy military output’. It will be up to the player to decide whether to build a heavily armored ship with missile launchers or to build decoys for distraction, blow one turret with a warhead and hack the rest of outpost. We haven’t decided yet whether it will be possible to play single-player scenarios in cooperative mode.

Multiplayer scenarios will be designed to bring some competitive gaming to Space Engineers. We’re discussing the designs of these scenarios in the team. There are ideas for classic scenarios like "defend station", "capture the flag", "death-match" and less common scenarios, for example where players compete in mining to deliver the largest amount of gold ore from a big gold asteroid to a merchant. Some scenarios will be team-based while others will be free-for-all.

Modding. We want to make scenarios fully modable, it should be possible for modders to create and script both single-player and multi-player scenarios. There will also be a simple scenario editor directly in-game; modders will be able to prepare a world and select victory conditions in the UI. Modders will be able to use prepared infrastructure, like victory/game-over screens, scoring screens, team selection, define player inventory, possible respawn count and more.

New Multiplayer

Update 01.015, which added multiplayer was released on Jan 16th 2014, more than a year ago. Multiplayer itself was written in 5 weeks. We knew it’s far from being perfect, there were connection issues, lags, desync issues, jittering, hackers and many many other issues. We didn’t want to spend 2 months rewriting multiplayer from scratch, so we decided to fix the things we could fix and focus on ‘better’ multiplayer later. We also knew that if we add infinite worlds, we’ll have to change multiplayer again.

Now we’re ready to rewrite multiplayer from scratch. The game has many more features and we can take these into account when rewriting multiplayer, especially infinite and procedurally generated worlds. We also have a bigger team, so we can keep adding features and also work on multiplayer.

In the current version of multiplayer, every client knows everything. When somebody is drilling 100.000 km away, the client gets this information from the server. It’s not necessary for the client to know it; the client should only get this information when he gets close to the drilled asteroid. In new multiplayer, clients will only receive information which is necessary and related to an area close to their position (or camera position in case they are looking through camera). This will reduce required bandwidth a lot; it will also allow many more players in the game (depending only on the server’s internet connection).

Information sent to the client will be prioritized; important things like position updates will have high priority. Less important things like battery capacity update or inventory changes will be sent with lower priority. This should reduce lags and make multiplayer more smooth.

Every client is now sending position updates to all other clients (it’s not going through server). This can reduce lag a little, but it also requires a bigger upload, because it’s necessary to send messages to every other client (not only to the server). It also makes connection issues much worse, because it’s necessary for each client to be connected to every other client. With more players on server, this issue has a much bigger impact.

In new multiplayer, the client won’t be connected to every other client, but only to the server. The server will validate data sent from the client (e.g. position updates) and send it only to other clients who need this information (clients who see the original client). This will prevent connection issues and reduce network bandwidth. It’s also a necessary step for increasing the number of players on server.

The current multiplayer uses the Steam Networking layer which allows us very easily to send data between players and it’s very easy to use. On the other hand it’s missing some advanced features. To get advanced features, we’ve decided to switch to RakNet. RakNet is a popular networking layer; it’s robust and it supports many platforms including Xbox, PlayStation, Linux, Android and other.

New multiplayer will work technically in a similar way to Halo Reach or the Tribes series (way of synchronizing objects and its properties). We’ve been working on the new multiplayer for a month now. The work will continue for at least several weeks or a few months before it’s done.

Stay tuned for more information about ship AI, Xbox, game controller and Medieval Engineers.

Note: All images are public domain

Ondrej Petrzilka

Thank you for reading this! For the latest news on our games, follow us on Facebook or on Twitter.

Medieval Engineers on Facebook:
Medieval Engineers on Twitter:
Space Engineers on Facebook:
Space Engineers on Twitter:

Wednesday, April 8, 2015

Introducing our general artificial intelligence project with my personal $10M investment

I am very happy that I can finally introduce our general AI project that we have been working on here at Keen Software House. Just to be clear, this is not an AI for video games (although it could be used in games).

One of my life-long dreams has always been to create a human-level artificial intelligence. After the success of Space Engineers, I was finally in a position to go full-throttle on this. In 1/2014 we started a new team dedicated solely for this purpose. Today, the AI team has 15 computer scientists and engineers and our plan is to grow to at least 30 people. We are also considering opening offices across Europe (to reach the talent who can’t move to Prague).

If you are interested, we are hiring:

In this blog post I will talk about:
  • Why we believe that AI is the most important project to undertake
  • What this AI project is about
  • How our approach differ from others
  • What have we achieved so far
  • What are our short-term and long-term goals
  • Video talk
  • How our R&D team works
  • What’s next

Why is AI so important?

We believe that general AI is the technology with the greatest potential to help people. If we solve the intelligence, replicate it, clone it, scale it up, make it smarter and faster than us – then the AI can keep inventing things for us. AI can become our “final invention” – in a good sense :)

Imagine that we get to build a computer that has the cognitive capability of a smart human. We ask it to optimize its hardware and software and come up with a more advanced version. And then we repeat this process, over and over. The progress won’t be linear; it will be exponential, leading to a recursively self-improving AI.

Then in a very short period of time you will have a computer whose cognitive capabilities may be a million times larger than ours. We can’t even imagine the type of problems this machine would be able to understand and solve. But we know that if we control it safely, it can solve everything that humanity ever wanted: just faster, better and more efficiently.

And because we are speaking in terms of exponential growth, one dollar invested in an AI company can soon represent a value millions of times larger. That’s a return-on-investment that can’t be achieved in any other business. Of course we’re not doing this just for the money: AI will open doors to unimaginable worlds.

Let’s dream for a second and see where AI can be useful:
  • Upgrade our bodies; fix death and diseases
  • Upgrade our intelligence
  • Travel to outer space, harvest asteroids, gather clean energy
  • Discover natural laws that are too complex for the human mind to comprehend
  • Invent and build things for people
  • And many more - AI scientists, AI programmers, AI astronauts, AI [insert anything]

General AI could be the best thing in human history. Admittedly there are some risks too, and they need to be addressed carefully when the time comes.

Our long-term mission is to build artificial brains, be useful to humanity, and understand the universe.

What is our AI project about?

We are trying to build an artificial brain that can perceive, learn and adapt to the environment while generating behavior that maximizes reward. The AI brain could be integrated into any type of a robot body or  software application. It would receive data from sensors and it would output commands to motors/actuators. Motivation will come in the form of a positive or negative reward signal.

The brain will learn time-based patterns in incoming and outgoing data, and also from the brain’s internal activity; it will seek causalities, correlations and associations; it will make predictions (e.g. what’s going to happen in next 10 milliseconds, 100 milliseconds, etc.) – and then it will use all these mechanisms to build a model of the world, its own body and mind; this all will be processed on multiple levels of abstraction and hierarchy. After this the brain will generate behavior patterns that are directed to maximize its chances to receive positive reward in the future. The brain will learn the associations between its current situation, its latest actions and the outcome/reward.

The brain will develop and learn in the same way that children do. It will start with zero knowledge of the world (except a few innate reflexes), then it will start interacting with the world (randomly or through innate reflexes) and by observing the causalities (time-based patterns), it will start creating a model of the world - layer by layer, with multiple levels of hierarchy and abstraction.

How does our approach differ from machine learning or
specialized/narrow AI?

Our approach is very similar to traditional ML techniques (looking for patterns) except we add behavior and motivation on top of it. We want to build a brain, not just process data.

Behaviors are executed by a sequence of muscle commands, which in fact are just another type of pattern (played in the opposite direction to sensory signals). Nevertheless, we take a lot of inspiration from ML and narrow AI approaches.

Some of our AI modules will become very specialized (e.g. image recognition, audio processing) because we don’t have the millions of years that evolution had to fine-tune a solution for a general principle. Instead, we have engineering skills and we already know how the end-result should look (the human mind).

Current state and plans

Our AI project is still in the early stages of development. Our long-term goal is human-level intelligence (10+ years), but we are already looking for short-term goals (1-3 years).

Already accomplished:
  • Brain Simulator – a visual editor for designing the architecture of artificial brains; developer selects from various AI modules (e.g. image recognition, working memory, prediction, motion behavior generator, etc.) and links them together so that the signals travel between the right modules; currently implemented in Windows and CUDA, but we plan to make it multi-platform very soon;
  • AI that learns to play Pong
Upcoming milestones:
  • AI that plays a game with a more complex environment; multiple sub-goals needed to achieve the end-goal; delayed reward; this all requires long-term hierarchical goal following
  • AI that learns to play variety of games without forgetting any of them and being able to generalize rules across the games
  • Muscle control sequences, bipedal robot balancing

AI playing Pong (visualization of attention module, taken action and
current state to goal state similarity measurement)

Brain Simulator: this video shows a simple test of Self-organizing Map
(Kohonen map) with the MNIST hand-written digits data set.

Short-term goals: 3-12 months

  • Release the Brain Simulator with all example apps (e.g. Pong); most likely for free
  • Release a platform where AI researchers can share their AI modules and brains (e.g. if someone makes a better version of an AI module and uploads it to this storage, others can benefit from it)
  • Hire at least 15 colleagues for the AI team; open offices across Europe
  • Promote our AI project and explain its benefits to the general population
  • Find use cases for short-term commercial utilizations without sacrificing our long-term mission. We already have some B2B ideas (marketing, predictions, and desktop work automation). We need real feedback and we need to help real people
  • Spin off our AI project to a new sister company – the reason is that Keen Software House is a game development company and this situation may be confusing to potential partners of our AI business
  • Work with the community and let our game fans join this adventure
    • Players will design AI brains (via Brain Simulator) and then import them to Space Engineers or Medieval Engineers where the AI will come to life
    • Enable third-party AI module/brain developers to cooperate with our game fans on testing and training of their creations (players’ collective force will help training the developer’s AI brain)
We study and are inspired by the work of other teams and we want to cooperate wherever possible.

Business model

At the beginning, our AI brains are going to be inferior to existing specialized AI solutions (nobody would pay for an AI that can only play a Pong game…).

But in time, the universalness of our approach will show its fruits and business customers will start using our AI brains in their robots and software applications. Brain Simulator will be used to design and test AI brains for specific applications; developers will have freedom in choosing our or third-party AI modules.

Brain Simulator will become a platform for a new ecosystem, joining AI module/brain developers with business customers.

AI company’s income shall come from licensing (royalties). Receiving a share from every product where our AI brain is integrated is a huge business opportunity worth billions of dollars.

Third-party AI module/brain developers will make money too – their work will get sub-licensed and they will get their share on royalties.

$10mil USD funding

I have an enormous belief in our AI project and that’s why I am funding it with $10mil of my own money. More money will come if needed.

We plan to raise additional funding via equity crowd-funding and venture capital, but this is not an urgent thing.

However, the idea of equity crowd-funding is neat because it’s a way how we can give people a chance to participate in the future profits that the AI economy will bring. Becoming a co-owner in an AI company and receiving dividends is one of the ways to have an income in an era where automation replaces all human jobs.

None of this will negatively impact our game development. Our game dev teams have more money than that they can spend in years and they are doing a fantastic job even after I had to split my time between games and AI; currently I focus a little bit more on AI, but this is going to change from time to time. There are still things that I want to accomplish in gaming and I know for sure that in 6 months I will be back, preparing some very specific new ideas… I love making games and not even robots can stop me from creating them :)

Just a reminder of what’s under development in our games:
  • Game AI and animals for Medieval Engineers; soon after that we will focus on AI for Space Engineers
  • Planets for Space Engineers – a very huge project!
  • Multi-player for Medieval Engineers:
  • Campaigns and scenarios for ME and SE
  • Redoing networking layer for ME and SE
  • SE on Xbox One
  • Many more!
As you can see, we try to do everything we can to secure a solid game development process while not ignoring the long-term goals that we have in general AI.

I have a gut-feeling that the general AI will come to our games too. And because it will not be constrained by short-term narrow AI concepts, it could be a major game changer for the whole video-game industry.

Presentation at the Czech Technical University in Prague

You can learn more in our first public talk which was held a few weeks ago at Czech Technical University in Prague.

How does our R&D team work?

We switch between free periods (when everyone works on a topic of his choice) and milestone periods (that are focused and lead to a measurable goals). It’s usually 1 month free period and 2 months for a milestone period.

We hold two team meetings each week. First one is for brainstorming where anyone can speak up about his ideas, findings and questions. The second one is an update meeting where everyone shows what he has done since the last meeting and what is he going to do next.

We try to replicate the “agile development” which is so successful in our game development teams and so we aim for rapid iterations: come up with an idea/hypothesis, implement it fast, test it fast and see if it’s worth further investigation.

The motivation of all our colleagues is crystal clear: we are working on the most exciting scientific challenge and if we do it right, the fruits of our work will change everything.

In my humble opinion, there’s no better work in Prague for a programmer/researcher than what we do in our AI and game teams.

What’s next?

We plan to keep informing you about our AI project: business model, short-term commercialization ideas, AI ethics, AI safety, technological singularity, our milestones, etc.

We will have a new web site dedicated entirely to AI project/company very soon.


Thank you for reading this!

If you want to follow our AI project, please follow me on twitter!/marek_rosa or keep checking my blog: