…And You Will Enjoy It.
SpaceChem is a game that I recently discovered. It is a wonderful puzzle game of fiendish difficulty. The game has you construct molecules by disassembling other molecules and reassembling them in a different form. The crux is that you cannot do that by hand; you have two “waldo’s” (which you can think of as graspers) which follow a line that you set out. You can place instructions along the line, and the waldo’s will execute them when they encounter them. Typical instructions are: unload a new molecule from a particular input, grab a molecule, rotate it, bond it with a neighboring molecule, and dump a molecule in an output. The game starts out with some easy puzzles to teach you the ropes, but quickly ramps up the difficulty and has you construct factories that deal with the greenhouse effect, fuse atoms to create new elements, and even construct laser defenses against Lovecraftian monsters.
For people who like programming, SpaceChem is a wonderful experience. It requires you to be inventive with a limited instruction set and limited space. It requires you to invent new mechanisms based on simple instructions. It requires you to envision what the solution you are constructing is actually doing without seeing it being executed. It requires you think outside the box. It requires you to come up with ways to use the simple instructions provided to implement common programming tools (SpaceChem has no counter, but it has a flip-flop: a split in the road which the waldo will alternate between the left and right side; with a bit of inventiveness, you can come up with a way to use flip-flops to count to specific numbers, i.e., implement a for-loop).
After playing several levels of SpaceChem, I was convinced that I should use it in my programming classes. Because the main problem I encounter there is that students are unable to think like programmers. They are used to looking up stuff in books, to argue a point, to produce statistical results, to understand what variance entails, and to use software. But they cannot imagine what it means to talk to a machine in a language of basic instructions, and use those instructions to tell the machine how it should solve a problem.
This is what SpaceChem requires you to do. The two waldo’s are stupid; they just follow the line and do exactly what the instructions along the line are saying. They will happily try to rotate a molecule that they are not holding. They will run in an endless loop if you have made one. They make molecules crash into each other if you have not made sure that that cannot happen. They are just doing what you told them to do. But the thing is, even with the very few instructions available, and the very limited space, you can make the waldo’s do grand jobs.
This is what programming is all about. The problem with programming a solution for a problem is that you get confronted with the whole problem at once. You will have to find ways to cut it into manageable chunks, see how those chunks interact, and implement the chunks using the limited toolset that you have. The power that a good programmer has is that he or she can take huge problems, and carve them up into pieces that are all logical, understandable, and possible to implement. SpaceChem provides this experience in an entertaining way.
I am not the only one who came up with the idea of using SpaceChem in programming class. I found that in the UK the game is actively used in high-school programming classes. If it indeed helps students understand what programming is, it is probably the first edutainment game that I have encountered that actually is both fun to play and has educational value.
Of course, I would not be surprised if the main reason that I like SpaceChem is that I like programming and can do a reasonable job of it. And it should be noted that what a programmer has to do is usually much easier than the jobs that you have to do in SpaceChem. Modern programming tools are far more powerful than the simple SpaceChem environment, and the artificial limitations that the game pushes in your face are at least 30 years out of date. Therefore I feel that the following statement is apt:
“SpaceChem does not make you think like a programmer — it makes you think like an assembly programmer.”