As I start getting the Neohack code debugged and filled in, I’m implementing a very simple game to make sure that most of the mechanical bits work correctly.
The game is one I call “Nine Keys.” It goes like this. You are trapped in a big complicated cave, and in order to get out you have to unlock a door using nine keys. These keys are scattered through the cave randomly. So what you have to do is explore the caverns, gather the keys, and return to the door. Unfortunately for you, three of the nine keys are guarded by wraiths. That means there are at least three of them you can’t get to without waking up the wraiths, and at least two where you will probably wake up a wraith in front of you while one or two are already chasing behind you.
Wraiths are terrible creatures whose touch, if they ever touch you, will automatically kill you. Accordingly, this tends to be nonconsensual touch, in that you’d rather not be touched by any wraith. They are also inerrant trackers; once they have seen you, they will come after you and they will never ever give up, or stop, or get lost, or lose your trail. If you stand still for too long, they will catch up.
Lucky for you, they’re a little bit slower than you (they take five steps in the same time it takes you to take six), they can’t actually pick up or move the keys, and their penchant for chasing you means they’ll leave the key they’re guarding on the ground where they were standing, so if you lead them away then come back, you can pick up the keys they were guarding. Also lucky for you, the caves are pretty open and well connected, so your speed advantage is actually pretty useful.
Because you have superior speed, and because wraiths are just a little bit stupid about close maneuvering, you can sometimes dance past one of them at a wide spot in the passage if you get caught in a dead end, or kite them after you while you run around the edge of a larger chamber. But the more of them are chasing you, the harder it becomes and the more room such maneuvers require.
In order to win this game, you have to figure out how the wraiths move and track you so you’re able to guess where on the map they are even when you haven’t seen them for a hundred turns or more. You have to learn to exploit randomly occurring loops in the map as places to get past them without getting caught — or if the loop is big enough, you can lead them around in a circle to get more steps ahead of them. Figure out about how many steps ahead of them you are, because that’s how far you can go down an unexplored tunnel before you either find a place where you can get back past them if they chase you that far, or you have to turn back so they don’t catch you in a dead end.
Because their movements are a little bit random, your guesses about where they’ve gotten to will never be exact. They can be further ahead or further behind than you expected, take a corner wider or cut it closer than you thought they would, or sometimes one or two, or all three, might cut a corner you didn’t expect them to cut. Sometimes you have to maneuver to get the wraiths chasing you back together, because they’re more dangerous (tend to occupy more of your potential escape routes) when they get spread out or separated.
Anyway, I’ve got the dungeon generator making the caverns, and the keys, and the wraiths, and the player character. I’ve got the wraiths chasing the player character. I’ve got the player character able to pick up keys and able to check inventory to see how many keys he has. I’ve got the ‘death touch’ attack of the wraiths implemented, and the game detecting game over (and not crashing) when the player character gets killed. So, I can play this game now, and it’s a tight little coffeebreak game. In fact I’ve been getting distracted playing it when I intend to just test a particular feature I’ve been working on. I can even tell when I’m supposed to win, because I get all nine keys and get back to the middle of the cave.
Now I need to add a door at the middle of the cave, have the game notice when the player wins, implement scoring, and show a high scores screen.