Space Coding Games

Lots of space games focus on flying around in a spaceship firing lasers; but what if you want to combine a love of space and the joy of coding? Described below are a few games that allow you to experience this perfect union. I've avoided games that focus solely on combat, like Mindrover and Carnage Heart; or games that you could pretend were set in space but don't have it as a specific theme, like Screeps.

The title for each game includes some extra information, in the format: (free or commercial | which programming language | which operating system).

CodinGame (Free | All Major | Browser)

The CodinGame site is like a shrine to programming, where you can go to worship regularly and never get bored. There are huge competitions involving thousands, quick 5 minute head-to-head challenges involving half a dozen, and a variety of programming puzzles to attempt on your own. It made this list because of one set of puzzles in particular - the Mars Lander.

Easy Mars lander puzzle. Easy Mars lander puzzle.

The idea is simple enough. Just like the original Lunar Lander (which you can play online), you need to guide your ship to land on a nice flat bit of the planet's surface. However, this time you need to write a program that continuously decides the direction and power of the engine thrust. The beauty of the site is that you can write your code in almost any language, and the environment provides instructions, coding area, and test environment all on the same page.

CodinGame development environment. CodinGame development environment.

There are three levels of difficulty: easy, medium, and very hard. You'll have to unlock each level in turn, including the hard level that doesn't have a Mars Lander puzzle. There's also a fuel optimisation puzzle that you can access pretty much straight away.

Colobot (Free | CBOT | Win.Linux.OSX)

Colobot is a perfect example for this list. You play as an astronaut and can program various types of drones to complete tasks for you. There are a few different game modes, including exercises to learn how to program your drones, programming puzzles, head-to-head battles (think RTS but with programming instead of clicking), and a (loosely) story-driven set of missions. You can directly control the drones - driving/flying them around, collecting resources and shooting giant alien bugs - but programming them does actually make things easier.

caption Mission to the Moon. Time to build some bases and recharge the drone's battery.

The programming language is roughly in the style of Java/C++/C#. The code shown below is part of the solution to one of the training exercises. Using the radar option lets you search for something in the environment (in this case the game's raw material for building: Titanium Ore). You can then just tell your drone to go to it and grab it. Much easier than driving around trying to spot it yourself.

caption Code window. The program waits for each statement to be completed before moving on to the next.

The radar function will also take additional parameters to choose the direction, distance, arc, etc to search in. A reference for all of the commands is included, and although there is enough for some complexity it isn't overwhelming.

Colobot was originally a commercial game, but at some point was open sourced and made available for free. The graphics maybe look a little dated, but I think Minecraft has helped people look beyond visual styles now. You can download it from the project website; but it was also in my Linux distro's (Lubuntu) software centre. It's available on all three major operating systems, so there's really no reason not to try it out.

SpaceChem (Commercial | Visual | Windows)

SpaceChem is different to every other game on this list because it uses a visual programming language. At least, I class it as a visual programming language, and that's why it's here.

Spacechem SpaceChem's visual programming language

The scenario revolves around factories placed on the surface of different planets; with each factory needing to produce a specific chemical from the supplied ingredients. Inside each factory the game environment is a grid, and you can move the supplied ingredients around on a path of your choosing, with various command points being triggered as the ingredient goes past.

Mostly you'll be combining elements together to make new compounds, or doing the reverse. It's quite novel, and that makes it a bit confusing to explain. Seeing it in action doesn't actually help that much either.

However, once you've gone through the initial tutorial levels you'll understand the mechanic. It can get fiendishly difficult when you're trying to create large compounds, and there's the added complexity of connecting factories together and pumping chemicals between them. Overall it's a fun, novel, and challenging puzzle game.

KSP (Commercial | kOS | Win.Linux.OSX)

It feels like no list of space games would be complete without Kerbal Space Program (shortened to KSP). Although it doesn't include any programming elements out-of-the-box, there is a mod that you can install to quench your coding thirst. The mod is kOS (Kerbal Operating System), and is billed as a "do it yourself auto-pilot". Essentially, with the mod installed and the requisite part added, you can write programs to control your spacecraft.

kOS enabled rocket at launch. Console and script editor are shown on the left.

The kOS site contains instructions on how to install it, but it also suggests using CKAN - which is a mod manager. I did, and it was a pain-free process. It installed another mod that it felt like it needed, and also recommended RemoteTech (to make antennas more realistic).

If you're reading this list then you either have KSP, or should immediately go and buy it. All aspects of the game pose a significant challenge, even if blowing up is half the fun, and initially at least the coding is likely to make things more difficult. However, the kOS site provides tutorials and plenty of information to get you started - although at the time of writing you should ignore step 4 of the quick start guide, since in the current version you do not right-click on the part to access the console, but use the button on the right-hand side instead.

Take on Mars (Commercial | NA | Windows)

Take on Mars sits at the realistic end of the simulation spectrum. The main game starts you off with basic probes, and you need to unlock new lander and rover technologies by exploring (mainly) the surface of Mars - taking pictures and collecting sensor readings. You can also explore as an astronaut - setting up a base and cruising around in Mars-bus (not its official name). However, it's the rovers that have placed it on this list.

Take on Mars - remote view. Take on Mars - a small six-wheeled rover on the Martian surface.

At any point you can switch to an external view of the lander/rover, and directly control it to complete the chosen mission. If you want to increase the difficulty you can try to complete the missions using only the on-board cameras and satellite image. If you want to push the realism (and difficulty) to its maximum, then you can try to complete missions by programming a sequence of commands as well.

As described in another article on this site, the time delay caused by distances between planets means that instructions are sent in batches. Thankfully you won't need to wait 20 minutes between issuing commands and seeing the result; but you can if you want to.

Take on Mars - extreme mode Take on Mars - view through the on-board camera, with satellite view on the left, list of available commands on the right, and the programming console shown in the middle.

You can access the command console by clicking on the button in-between the primary and secondary control panels. It doesn't use a programming language as such, but more a set of simple commands. Something that caught me out to begin with was that some commands require you to add the units - e.g. FORWARD 12 needs either METERS or YARDS adding on (note the US spelling of metres - unacceptable. If you don't use them then you can't dictate the spelling). The satellite view is also particularly useful for plotting a course, since you can choose a point and see the angle and distance to it. If you hit even a small rock then the rover will be deflected off in a different direction, so you'll want to plot your path carefully.

Take on Mars is still in Beta, so not everything is working perfectly. Sometimes landers just hover, refusing to land, and the jets from rockets mostly sit some distance away from the rockets themselves, but there is still plenty of game here.