Blocked.

On the list of eventually about 200 things to be fixed in the Pac-Man doodle, “reversing should be faster” was one of the first ones to appear, and one of the last ones to go away.

On the surface, it was a very simple bug. Although it’s forbidden in normal gameplay, ghosts reverse directions under some circumstances. The most common one is when Pac-Man eats one of those big magical pellets (“energizers”). It seems natural: the ghosts start running for their lives instead of chasing you.

But there was a problem: I couldn’t make that happen.

The life of a ghost is both more and less sophisticated than it might appear. For instance, a ghost always thinks one step ahead. When it enters a tile, it looks ahead to the next one and makes a decision about what it’s going to do next—if you look carefully, you can see its eyes actually betraying its intentions just a fraction of a second before the turn.

But this is the only opportunity for a ghost to make that decision. When a ghost reverses its direction rapidly, it doesn’t have time to look ahead. If it just cleared a corner and now starts coming back, there won’t ever be time to make a new decision. The ghost is left with a memory of a previous direction it chose and, sometimes, disaster strikes—it is left there, in that corner, unable to move, with its eyes looking wistfully for that imaginary path that doesn’t exist and, indeed, never did.

The first time I saw a ghost freeze in a corner was devastating. I was sure the logic I programmed in was flawless, and now something happened that not only wasn’t at all expected, but I also had absolutely no idea what could be causing it. “A computer won’t do what you want it to do,” the old saying goes, “it only does what you tell it to do.” And there must be a clever saying for another thing too: programming is oftentimes art. Just like in design, in photography, in music, you sometimes code things just because your gut feeling tells you to. I implemented a ghost moving logic that felt right, but, as I just found out, wasn’t. It took me an hour or two just to come up with that above explanation for a broken behaviour.

Fixing it was even harder.

Initially, I didn’t even try. I implemented a little workaround so that a ghost was given enough time to clear a tile before heading the other way. There was now always enough time to make a new, adjusted decision, but there was also a problem: reversing took longer than it should. Longer than it took in the original Pac-Man. I half-mindedly dropped in a new bug entry stating “reversing should be faster,” assuming it would be an easy fix. I mean, how hard could it be?

I tried to repair it that same day. I failed miserably. I spent a couple of hours, still without understanding exactly what was wrong. In the end, I gave up, and moved on to fixing most of the 199 other things that seemed more important. After all, who would ever notice that ghosts change directions a couple pixels later?

I tried to fix it again today. Many new lines of code were created; ghosts probed and prodded a little bit; the game sped up 20 times so that I didn’t have to take too much time playing it over and over again. But it still took hours and, in the end, led nowhere. Once in a while, a ghost would just stop in the corner, each accident like this feeling more and more like betrayal. I destroyed all that new code and quietly admitted defeat. The game wouldn’t be perfect, but maybe it didn’t have to be.

But something didn’t feel right about that. I wanted to make Pac-Man as faithful as I possibly could. I know it’s just a game, and most people won’t give a damn, but it matters to me in ways I myself might not realize. It reminds me of my father back when we used to spend so much time together. It reminds me of my childhood, and those moments when I was happy, but I only realized that many years later; I can almost imagine the smell of a room filled with arcade games, the feel of a quarter in my hand, the glow of all the displays, electronic sounds coming from every corner. It brings memories of the Netherlands, where we found a table that looked like Pac-Man and took photos of it, colouring it yellow in Photoshop for that extra “realism.” It reminds me of that evening just a couple of years ago when I played a vintage Pac-Man math game (sic!) with some people who were on their way to becoming my great friends.

There is also something more. I like it when I care so much. I like it when others care so much. I always find it wonderful and inspiring when I see someone truly, deeply passionate about something—almost no matter what it is—and I hope that some things that I do inspire others as well. Perhaps it’s just a game, but perhaps on May 22, if the game is done exactly right, it will be someone’s return to beautiful memories as well.

The following scene would look cool and romantic if serialized for TV, but in reality it was almost the opposite. True, I went for a walk in that beautiful park next to me to recharge, but when I started for the third time, I approached the whole problem much more methodically. I equipped each ghost with a virtual loudspeaker to announce exactly what it was doing. It looked something like this:

In this cacophony of obsessive-compulsive reporting (I am not sure why I added all the exclamation marks—perhaps I wanted the ghosts to be heard in that rose-tinted noisy arcade), once in a while, you would see REVERSING DIRECTIONS! and, at the very end, the dreaded BLOCKED!

Only this way I could actually understand what I created before. It’s as if instead of using gut feeling to fix my gut feeling, I instead gave it a pen and paper and finally let it explain itself.

That was the breakthrough I needed. After that, it didn’t take that long for the fix to almost write itself. After changing directions, a ghost would now not only look ahead to the next tile, but check if that tile actually existed—and if not, make a new decision based on the current one. I ran a test game with the latest change, and after a while finally realized, not without a lot of suspicion and double-checking, that this time it actually worked.

And there I was, after so many hours of trials and mistakes and frustration, being able to finally cross out “reversing should be faster” from the list, and make my homage to that simple game (and that simple life) of yesteryear so much more closer to what it deserves to be.

Out of the few remaining bugs, the next in line is: “eyes should travel home even during ghost eating pause.”

I mean, how hard could it be?

Google Pac-Man