For some reason most people seem to be born without the part of the brain that understands pointers. Pointers require a complex form of doubly-indirected thinking that some people just can’t do, and it’s pretty crucial to good programming.—Joel Spolsky, "The Guerrilla Guide to Interviewing (version 3.0)"
In programming, pointers are variables that contain not values, but memory locations. It's a seemingly simple concept that causes considerable confusion even if you do have "the part of the brain that understands pointers". They also produce the strangest bugs. One of my earliest C programs crashed unless I was debugging it. Eventually I discovered the problem was my use of pointers.1
Now I don't know if Joel is correct that some people can never learn to understand pointers. But I do know that it's easy to get turned around while using pointers such that it feels like I've lost my mind. Baba Is You produces that same feeling when it requires "a complex form of doubly-indirected thinking" to solve.
It doesn't start out that way, of course. Like all great puzzle games, Baba Is You introduces ideas incrementally. The goal of every puzzle is to move to the winning item. For instance, this puzzle requires you to move Baba (the rabbit-type creature) onto the flag in order to win.
The text forms the rules of the game:
BABA IS YOU
FLAG IS WIN
Every level has to have an
X IS YOU rule or there would be nothing
to control and nothing to claim the win. The other rule you need is an
X IS WIN rule, but that's not always set to start the puzzle. In
this puzzle, all you have to do is step on the flag to win. Each word
in the rules can be pushed around so sometimes a puzzle will have an
incomplete win rule that you will need to assemble before you can win.
By the way, I created the puzzles I'm showing and you can play them if
you download the Baba Is You level
enter the code I provide. This trivial level is
Puzzles frequently use rules malleability. Even this easy puzzle is
trickier than it first appears. If the player presses the down arrow
to go down, they will push the word
BABA out of the first
rule. Since there is no longer a rule defining the player and since a
player is always needed to complete the puzzle, the game instantly
stops. You can only resume the puzzle by resetting it (with the R key)
or undoing the most recent move (Z). Expect to use these keys
Here's a trickier puzzle (
It has the same two rules, but there doesn't seem to be a way to win since I didn't provide a flag. The level isn't that hard to solve with a little trial and error. (Again, you can play it with the level editor.) How would you approach this problem? I'll let you ponder a solution while I explain another aspect of the game.
Pushing the text blocks around was inspired by another puzzle game called Sokoban, which is Japanese for "warehouse keeper". It's about a awkwardly designed warehouse that's too cheap to give workers a forklift. So they have to move boxes by pushing them. The catch is you can get boxes stuck if you push them into a corner or along a wall with no door. It's a somewhat tedious game. Most levels involve a little trick to make space and then a bunch of repetitive maneuvering to get each box in its place.
Baba Is You suffers this problem occasionally, but most levels can be solved in less than a minute once you know the secret. The rich variety of possible rules helps. Some levels are box-pushing puzzles, but there are plenty of other mechanisms to play with. Baba moves through themed sections of the world: lake, island, forest, space, volcano, etc. Each subworld introduces new concepts and typically has sections dedicated to specific ideas. New subworlds are opened up once you complete a specified number of levels.
There aren't any Sokoban levels in the game itself, but I was able to
approximate2 one (
CKNB-BV1G) with some of the more advanced
rules. (It's wonderful to have a level editor to help understand how
the game functions. It even hides "spoiler" words behind a setting so
that you can be surprised in the actual game.) What's notable about
this level is that none of the rules can be altered. Official levels
always allow at least some rules to be altered, which is the charm
(and challenge) of the game.
The Sokoban ruleset is about twice as long as the typical puzzle has
at the start. Then again, it's likely you'll need to recombine the
rules several times to reach the win condition. Sometimes you'll find
yourself animating one object after another by changing the
X IS YOU
rule. Other times you'll rotate attributes, such as
PUSH from one
object to the next as needed. The only real limitation is access to
the right word needed to create the rules.
Have you solved my puzzle? The answer is that Baba can also be the win
condition. Here's an image showing how I will win by pushing the
text to the left:
Since the player's avatar and the win condition are in the same location (because they are the same item), it's an instant win. Strange, right? But not all that strange in the world of Baba Is You. Moving the rules around causes the changes in the level in ways that often feel strange or wrong. And yet, they are always logical. The game never cheats even though it seems like cheating to do things like making your avatar the win condition.
I can't recommend the game enough. If you aren't sure you will enjoy it, I recommend trying out the original prototype which includes the first few levels of the final product. Even though I've played these levels in the past, I still enjoy playing them again to find alternate (and likely unplanned) solutions. It's an incredibly clever puzzle system with a generous supply of levels.
I did find a few levels too hard to solve on my own. Sometimes putting away the game and coming back after a night's sleep did the trick. But when I get impatient, I turn to Baba Is Hint an unofficial guide that give gentle (and not so gentle) nudges rather than simply providing the solution. I still haven't finished all the levels because I'm savoring them.
It was a variation of "Hello World!" where I was trying to make the output a variable. Strings in C are null-terminated character arrays that are manipulated using pointers. If you forget (or don't know) to initialize the pointer you want to use for holding strings, it will point to some random point in memory. It could be a somewhere that's not used by anything. Or it could be somewhere important and putting something in that location could cause serious problems. Since the code of the program itself is stored in memory, you might even overwrite part of the program with nonsense.
Uninitialized pointers are a common source of heisenbugs. In this case, my program started working as soon as I added a statement to print the value of the string. Most likely the new line of code moved the random location my pointer referenced from somewhere dangerous to a safe location. ↩
I think I accounted for everything. Each time I thought I'd hit a limit of the ruleset, I discovered a way implment a rule in a way that's not immediately obvious. The rules I came up with should work for other Sokoban puzzles:
TILE WITHOUT BOX IS WIN BOX ON TRACK IS CART CART ON TILE IS BOX BOX NEAR ROBOT IS PUSH CART NEAR ROBOT IS PUSH WALL IS STOP BOX IS STOP CART IS STOP ROBOT IS YOU
I also made the tracks and carts red to reflect the way crates in the final locations are signified in the classic Sokoban game. It makes sense to me that boxes are loaded ont carts at these locations rather than just changing colors. That also made the rules work, which is a nice bonus. ↩