For those who haven’t, it’s a simulation of cells interacting with their neighbors by following a simple rule set on an infinite, two dimensional grid.
So let’s add a dimension -> view the game of life in 3D!
The Game of Life has become famous not only in theoretical computer science, for it is Turing Complete, generates the most interesting patterns and is easy to implement.
In flash it can be done in ‘one line’ of code by means of a convolution filter.
So since 1970 the Game of Life has been explored by almost every programmer, it’s no surprise its “Glider” pattern became the official “Hacker Emblem” in 2003.
Customarily it’s visualized by a 2D representation of the board/grid – however, it can be applied to 1D and 3D space as well.
While I find 3D versions/rule sets to be interesting too, there is a much simpler way to lift the game into three dimensions that also generates more beautiful patterns:
Simply plotting the (visible) game grid´s state over time on the third axis perfectly visualizes the process and generates amazing shapes… or at least very interesting greebles
The draw call issue
Since I am generating a lot of cubes (cells) on every frame, Unity has to do a huge amount of draw calls – one for each object.
The frame rate on my machine (Q6600, GF8600) dropped right into the basement.
The simple solution to this issue was to generate the complete generation of cubes and to fuse them to one single mesh using Mesh.CombineMeshes.
Normally this is done on startup – for the exact purpose of reducing draw calls – and I thought it could also be done at runtime for this scenario.
And indeed it works and allowed me to easily push more than a million vertices.
The app now draws a 50*50 grid showing the last 200 generations – the game is restarted with a new seed if new generations eventually become too similar.
Admittedly, it takes some resources – a graphic adapter with at least 128MB is essential as the simulation might end up with 1.5 million vertices.
Hope you get to see some interesting patterns – have fun!
The game now runs continuously – the VRAM size check was removed since it returned false-positives.