It’s another programming blog, Hooray! This time it’s completely independent from the 3D engine. I started programming this one a little while ago because I felt like experimenting a bit and doing something completely unrelated for a little while.
Cellular automata is a way of simulating just about any physical system through processing individual cells based on the state of neighbouring cells. Conway’s Game of Life is The Example of cellular automata, and also it’s origins. The rules are quite simple: Each living cell, represented by a black pixel, stays alive if there are two or three living neighbours, dies if there is less than two (under population) and dies if there are more than three (over population). Dead cells spontaneously come to life if there are exactly two living neighbours. Below is an animation of Life based on these rules.
Another, more modern and well known example of cellular automata is Minecraft. Minecraft can create and process huge map sizes simply because of the fact that cellular automata, if designed correctly, can efficiently simulate large systems. This is why they are so appealing to programmers. We see this inherently in the 1x1x1 cubes that give Minecraft it’s distinct look. Minecraft (shown below) uses this process to simulate water and lava flow, tree growth and fire spreading among other things.
My foray into the topic was to use hexagons instead of squares. I did several different simulations, but I started with a simulation of wind without any idea on how wind behaves and what the end result would look like. To sum it up neatly: it failed miserably. I then tried to do a simulation of water, inspired by a post that Shaun linked me. It was mildly successful, but I found that it didn’t entirely conserve the water (it magically disappeared and reappeared in very small quantities. Not enough for anyone to notice, but still enough). The core code for processing how water flowed between cells was also rather convoluted, which means it would probably be easier to start it from scratch rather than modify it.
Finally I went back to basics and implemented Conway’s Game of Life in hexagons. I was surprised to find that the original rules actually seem to generate an interesting world despite the fundamental change (most game rules generate too few or too many live cells). I also found a modification that looks to me like it is trying to generate a map for a side scroller (sort of in the vein of the helicopter game).
There’s a link here with all the different simulations I did, of which probably only Conway’s Game of Life is interesting. I’ve included the ability to toggle a cell between live and dead by clicking on it and some extra options including the ability to change the rules of the simulation. This means that you can pause the simulation and create little seeds like the one below and see intricate patterns play out.
Well, that’s all from me.