So look, if you’ve read this blog before you might be forgiven for thinking that the following statement is somewhat redundant, but here we go: I think about videogames a lot.
What I’ve been getting more and more into recently is thinking about how they are constructed, and this has lead to a gradual realization that my skills as a programmer are way inferior to where I think they would need to be to produce a game on my own. My brain doesn’t really occupy the same headspace as those who write serious code for a living.
… but that does make thought experiments on basic aspects of game construction very informative and revealing to me. So, let me tell you about this dream I had!
It would be an understatement to say that while in The Netherlands for beam time experiments I don’t sleep well. What with shifts going up to 20 hours, and the mental states that come with a high pressure environment, I don’t sleep a lot and when I do I have some very odd dreams. Most of them are just mumbo jumbo, but this week I dreamed I was dumped into a labyrinth and gradually turned into the Minotaur while trying to survive. I woke up and realized that it was an awesome idea for a game.
So, after hashing out in my head what the general mechanics would be, my mind turned to how one might put it together, and ran into an instant road block; I need a labyrinth. I have no idea how to make one of those in code. So, this evening, I found the Wikipedia page for Spanning Trees and thought I’d have a shot at building an algorithm.
It was surprisingly easy, once I got my head around what I actually *wanted*, the code to make it happen is pretty straightforward, but I know that the obvious way isn’t usually the efficient way of doing it.
So thanks to pugnodeum on Twitter, I read this little set of lecture slides showing how an efficient algorithm will generate the same thing. It uses the idea of the “unity” of sets of numbers to do a much more comprehensive search than my algorithm in a much smaller set of commands, and it makes a lot of sense to implement an algorithm that way.
What did I learn by doing something badly? Well, I gained an appreciation for the way that thinking of things using slightly more abstract ideas can ultimately make your goal a lot easier to program, but I also learned a bit more about the available space of functions to use (the lecture notes I linked use find() and unity() which aren’t things which I was really aware existed until now). That awareness really helps to make me a better programmer in the long run! =]
It’s amazing what some people do for fun, right?