QC Dev 004: Autocomplete

While demoing Quadrilateral Cowboy at PAX 2012, a lot of people asked for autocomplete functionality when typing commands into the game.

I put it on my to-do list and it languished there for a while. The mere idea of an autocomplete system intimidated me, and in my head it ballooned into a beast of a task.

Then one day I started implementing it, and found it wasn’t that bad at all.

The Cat Plays No Part

Here’s the sample level. There’s three doors and a window. The cat plays no part in this example.


Now, let’s say the player types this in: d


And then presses tab to autocomplete it. What happens?


First the game iterates through all hack-able entities in the world and generates a list. In this example level, the list is:

There, we now have a list of possible candidates.


We then filter out anything that doesn’t fit the player’s command. The player typed in ‘d’, and we compare that to the above list.

window1’ is immediately filtered out, since ‘window1’ starts with a ‘w’, not a ‘d’. You’re dead to me, window1.

That leaves us with three possible candidates: door1, door2, door3A


With this list of candidates, we further pare it down to the best autocomplete entry. We do this by comparing all the candidates amongst one another, and evaluating what they have in common. We compare them character-by-character:

Character 1: d All the candidates have this in common, so we continue.

Character 2: o All the candidates have this in common, so we continue.

Character3: o All the candidates have this in common, so we continue.

Character4: r All the candidates have this in common, so we continue.

Character5: 1 One or more candidates has a different fifth character. We immediately stop here, and we now know what all the candidates have in common: the first four characters, door.

Ship it

We send door to the autocomplete, filling in the player prompt with: door



Et al

I remember when Guitar Hero first came out, I was working late at Pandemic. Some guys bought the game and the plastic guitar into the conference room.

As I sat there watching our gameplay programmer tap colored buttons on the guitar, my first thought was “this is the dorkiest thing I’ve ever seen.” After a few minutes my opinion became “this is the best thing I’ve ever seen.”  There was something in the room, an energy created by the role-playing aspect and a tiny plastic guitar. He’s a rock star! He played the hell out of that song! That guitar solo ripped my limbs off!

Quadrilateral Cowboy intends to use the keyboard as the role-playing peripheral, to get that thrill of being an internationally-renown deck jockey. If I someday see someone go the extra mile and play this game in a dark room wearing sunglasses and a trenchcoat, I’ll be a happy man.