We Need To Talk About Spiders

On November 28, 2014, in King Machine, by bateleur

Spiders! King Machine is for the most part not a game about "enemies", but there are some characters in the game besides the player. One such character type are the mechanical spiders which cause problems for the player on some of the levels. And recently they've been causing problems for me too. They're fixed now, but it took a ridiculously long time (nearly a month) so I thought I'd write about this a bit. This is probably mostly of interest to other game designers, but there may be a bit of crossover into other kinds of programming.

So what was the problem? Well, in King Machine the player can alter (and even outright create) bits of the environment. The spiders have to traverse this environment correctly no matter what shape it is. Algorithms aren't something I find difficult, so I happily sat down and wrote a thing which treats the level like a graph and has the spiders traverse it. Easy! Took about an afternoon. Then the problems started.

First problem is that the spiders walk by raycasting possible leg placements. This looks great a lot of the time, but breaks horribly in a few cases. In particular, if something blocks the spider's body but none of the legs are touching it, the spider just gets stuck. Imagine a spider running like crazy, with its forehead pressed against a telegraph pole. Fixing this requires forcing the spider to walk on any surface which obstructs it.

Not that all the problems were with the legs. Next, imagine a sequence of cubes arranged into a path. The spider navigation algorithm easily plans a route along this path. Try it with the spider and it works. But what happens if you put a flat, square board over one of the cubes? Now the spider walks the same path, but when it tries to walk on the cube under the board it never reaches it because the board's in the way, so it just carries on walking. This is a problem with the pathfinding – it assumes that given two touching objects one is always reachable from the other, which is clearly wrong. Fixing this involved a massive increase in complexity as the spiders started looking ahead a bit to what they could actually reach and trying to walk around obstacles. And "around" itself is hardly a simple concept in 3D space!

Now if you're an experienced software developer you're probably already rolling your eyes by this point. And maybe also muttering things about complexity creep and keeping things simple. Maybe you'd recommend fundamentally changing how spiders move to something more manageable? Maybe you'd recommend throwing them out altogether and picking something easy? Good advice. Good advice.

So why didn't I? I see the problem the same way, but I don't agree with the objective. King Machine has been full of problems like this. Things which are awkward and complex and take far longer than they should. But if you go through a project and discard any interesting feature that is hard to implement, what you end up with isn't the thing you were trying to make. Some developers don't have a choice but to pick easy paths and ship as fast as possible. Given that I'm fortunate enough to have the option, I want to use that flexibility to make games other designers can't make.

That's not to say the spiders were really a good idea. A problem which King Machine has had all along is that the version of the game in my head was too complex for a one person team. I didn't know – and still don't know – how a really stripped down version of the game would work. Attempts to reach for a minimum core gameplay just looked too much like puzzle games. I like puzzle games, but King Machine isn't supposed to be one. Perhaps ultimately a certain amount of complexity is needed to support creativity?

Tagged with: