Black Knife Dungeon - notes on combat

If you finished BKD and enjoyed the final boss fight, read on.

The final boss battle mimicks boss battles in a lot of video games – you can tell when the boss will attack, you learn rules about when and how you should attack, and you can put it into a vulnerable state.

Superficially, this fight might resemble early adventure game fights like the troll or the thief in Zork. (Each turn you get a line about your attack, and then a line about the opponent’s attack.) However, structurally it’s fundamentally different. For example, (as far as I know) in Zork you just attack over and over, while in BKD you have about five combat options. That leads to a complex state system.

I cannot think of another example of this kind of one-on-one combat in text adventure history. (But there must be one, right?) If you know of one, please inform me.

As simple as the behavior ultimately feels, the code to create this state machine is complex, and it has to handle a whole lot of individual cases. I like the result, but I’m not at all happy about the code. The code boils down to a switch statement with lots of cases. It’s hard to decipher, and very resistant to iterative changes. Making almost any change in the logic of the fight requires a painstaking re-write of the code. It’s not robust.

I think this kind of fight is fun and interesting, and I’d like to see (or maybe write) more stuff like this. But even though it’s not too hard to design a fight like this, programming one proved to be surprisingly troublesome. I have a feeling there’s a fundamentally better way to go about it, but I haven’t figured out what it would be.


On a related note, my first stab at this game worked differently. Every fight was like a small version of the boss fight. At the beginning you could ATTACK or GUARD, so it was a pretty simple process of looking for “tells” from the enemy. I changed it because I wanted the fights to go quicker, and because the coding was cumbersome. If you’re interested in seeing that original version, let me know.

(My email is on the page.)


Is Kerkerkruip at all the kind of combat you’re thinking of?

Yeah, that definitely has some of the characteristics. It would be a good game to look at for people who liked BKD.