Flawed Ontology

Had some pretty powerful and sad realisations about how I’ve been implementing queuing in my current game today. In a lot of ways it’s very reflective of how I think as a programmer and perhaps as a person more generally. In this case it turned out bad, though I’d like to think that sometimes it’s a good thing, too.

Basically when I initially started working on the notion of queues in the game, I went with the “ontological” perspective that a queue should be a thing in the underlying world of the game. That is, that there should be a class/object that represents the queue in the code. Thus I spent rather a lot of time writing the code that would manage the queue, work out who was in the queue, work out how far apart they should start, and on and on and on. Put lots of effort into it and it turned into a behemoth that became harder and harder to understand.

Today, as I wandered to the grocery store, I realised that a queue is literally just a whole lot of people walking in the same direction at the same y-coordinate (in a 2D world) where at some point the front person stops and therefore everyone behind them stops too (because they can’t keep moving). That is, rather than positioning a queue as some extra entity in the code, it’s also possible to think of a queue as an emergent behaviour stemming from how the agents in a system behave. You really only need a couple of “rules” to establish queuing – the idea that people stop if they run into the back of someone else, the idea that everyone is moving along in a line with each other, and the idea that the front person gets stopped by some external force (such as a ticket barrier, say). The queue just happens.

From a coding perspective, the emergent queue seems considerably easier to deal with and seems like it’ll solve a great number of problems I was running into by defining the queue as a separate construct. In particular, by reifying the queue (always wanted to use the word “reify” in a sentence – that’s the first time!) I was seizing control of a lot of aspects of behaviour that I didn’t need to. That meant having to account for lots of behaviour (like new people officially entering the queue, or the avatar moving out of it) that became confusing and hard. These are things that seem like they won’t even really come up in the “emergent” queue.

All of this is to say that I probably wasted a lot of time thanks to a particular philosophical stance I took from the beginning of implementation. It’s interesting to me that something like our ontological view of the abstract concepts we make in a game can have such a massive influence on how the process of actually making something goes – though reading that sentence it hardly seemes surprising at all.

Like, “what? Our specific view of the reality our code represents matters?! Pull the other one!”

2 September 2011
← next words previous words →