if(desire_to_program > 10)
When I tell people I’m a programmer, I get that look. The glazed eyes, the polite smile, the clear desire to change topic. If I’m lucky, I’ll get pitched on an idea for the next killer mobile app that my conversation partner insists will make us rich; if I’m less lucky, I’ll get wrangled into providing free tech support for the rest of my life. The thing is, though, as impossible as it might sound, programming can be more fun than people realise. Fun enough to warrant its own video game genre, even.
Just how educational are these games, though? Is it really possible to become a programmer by playing games? I dug through Steam and came away with three promising candidates. Let’s take a look at them, and see whether they can really teach you skills to pay the bills.
Obviously few games are going to teach you how to write C# code, but these programming games translate the concepts of programming into visual metaphors and achievable puzzles. We’re going to therefore review each game in terms of the programming concepts it introduces and how well it teaches those concepts in a manner that would carry over should you start to learn a programming language later. We’re also going to run through these games in ascending order of conceptual complexity, so that they might form a complete course towards programming.
It should also be stressed, before we begin, that none of these games claim that they will teach you to code; we just think that they might. Onwards!
Human Resource Machine
Difficulty: Beginner – Intermediate
Human Resource Machine is all about data processing. A conveyor belt marked ‘IN’ delivers tiles with numbers and letters printed on them, and it is your job to send the right ones – as defined by each puzzle – to the conveyor belt marked ‘OUT’. To do this, you put together a list of commands for your eager worker to follow – a program, essentially. Since the tiles rolling in are randomised, your program has to account for all possible combinations of numbers and letters. This is a concern all programmers are intimately familiar with.
HRM does a great job of introducing concepts in an approachable way, giving you time to familiarise yourself with each new command before moving onto the next one. Even better, you can slow down time as your worker performs your program, stepping through each command so you can see exactly where and why it isn’t working the way you expected. Given how much time a programmer spends debugging, getting used to breaking down a program line by line is incredibly useful.
Accessibility, though, is only part of the programming equation. The critical question is: can playing HRM teach you how to program? To answer that, let’s dig a little deeper into the concepts powering HRM’s puzzles.
Concept: Basic Variables
What are they?
Dealing with unknown data, whether it be a conveyor belt of random numbers and letters or the light-speed keyboard commands of a StarCraft pro, is a fundamental component of virtually every program ever written. Because programs can’t predict the future – yet, anyway – they need a generic placeholder for storing and referring to unknown data during their execution. This is where variables come in. A variable is basically a labelled container for data that can be emptied and refilled as needed.
How is it taught?
In HRM, floor tiles serve as a surrogate for variables. At the centre of each puzzle room, the floor is divided into a numbered grid where you can temporarily store the numbers and letters coming in on the conveyor belt. In your list of commands, you refer to these tiles by their numerical labels – starting at 0, because in programming counting always begins at 0, not 1. Alternatively, you can give them your own labels like ‘FirstAdder’ or ‘Tally’ to help make your program easier to understand. This is a crucial technique in programming, especially if multiple people are working on the same code. Well-named variables can be the difference between diagnosing your misbehaving program straight away, and spending hours just trying to remember what the heck your code is doing.
What are they?
Where variables are used for referencing a single value or object, arrays are used when you need to group a whole bunch of similar objects together. Instead of needing a separate variable for each slot in a player’s inventory, for example, a game might have a single ‘inventory’ array within which all inventory items are stored. The benefit to this approach is that those items can be referenced in relation to the ‘inventory’ object like so: inventory, inventory, inventory… This makes it very easy to write code that checks all slots in a player’s inventory, and in terms of raw performance, arrays are a lot faster than individual variables.
How is it taught?
HRM pulls no punches with its implementation of arrays. Instead of referencing floor tiles directly through their labels, you can use the value inside one tile as the label pointing to another. For example, Tile ‘0’ might have the number 7 inside it. If you use the standard copyfrom ‘0’ command on it, you’ll get that 7 back. If instead you use the copyfrom  command, the program will use the 7 as another label and retrieve the value inside Tile 7. Don’t worry too much if that sounds a little confusing; you really need to see arrays in action to understand how they work. Importantly, HRM lets you do that with a number of well-paced puzzles.
Concept: Conditional Statements (aka IF…THEN statements)
What are they?
A program wouldn’t be much use if it produced the exact same output every time, regardless of the data you fed into it. That would be like a game that literally played itself, ignoring all player input and looping the same run-through again and again. Programs need to make decisions, whether they be as simple as deciding which of two numbers is bigger, or determining if a player’s crossbow bolt will hit its target or not. Conditional statements are the real brains of a program, the artificial equivalent of our neocortex.
How is it taught?
To keep things simple, HRM includes only two types of conditional statements: jump if zero, and jump if negative. These commands check the value in your worker’s hands and ‘jump’ to another part of your program if the condition is true. If your worker is holding -5, the jump-if-negative command will resolve as true and follow the jump arrow to the part of the program you pointed it at. If your worker is holding 1 instead, the program will continue as normal onto the next command in line. This may seem pretty simple, but later puzzles require a bunch of jump-if commands all working together, their jump arrows crisscrossing like a football play devised by the devil himself.
Concept: Iteration (aka Looping)
What is it?
Repetition is the bread and butter of computing. We write programs to automate the tasks we don’t have time to do ourselves, and for that we use loops. Loops herd NPCs back and forth along the same patrol route. Loops hit enemies with burning damage for every second they’re aflame. Loops keep a car accelerating until it reaches its top speed. Hand-coding each iteration of these processes would be woefully inefficient, and when it comes to programming, inefficiency is a sin.
How is it taught?
HRM combines the aforementioned conditional statements with the standard jump command to convey the basics of looping. There are two main types of loops, for loops and while loops, and HRM teaches both. For loops, which perform a set of commands a predetermined number of times, are implemented using one floor tiles as a counter that ticks down until it satisfies the jump-if-zero check and ‘breaks’ out of the loop. While loops function much the same way, except instead of looping a set number of times, they keep repeating while a certain condition is true. As the puzzles get tougher, you need to combine both types of loops with the array tiles to process lists of data of unknown length. This is a another cornerstone of basic programming, and HRM does a good job of gradually building you up to it.
By framing itself in familiar concepts like conveyor belts and floor tiles, and by offering only a small list of commands to work with, Human Resource Machine serves as a solid introduction to the core principles of programming. Colour-coded commands and helpful jump arrows echo the language of flow charts, making it easier to keep track of what a program is doing as it executes. The bespoke terminology like copyfrom and bump might not translate 1:1 to modern programming languages, but the concepts they teach are one and the same. After conquering HRM, you would be well-equipped to start learning how to code for real.
On page two, we look at Double Fine’s Hack ‘n’ Slash.