This is a project I have wanted to implement for several years, but never found the time to do it. Here I present a 3D version of the classic cellular automaton devised by the mathematician John Conway in 1970.
Compute Shader Update
For the adventurous, you can check out an alternative implementation I made using a compute shader to calculate and update the grid positions. This allows significantly larger grid sizes to be represented live, and much faster calculation for smaller grid sizes. The implementation works by passing numpy texture arrays (which encode the 3D grid representation) back and forth between the program and the GPU with RAM images. The next major performance improvement will likely come by representing the cubes with a geometry shader, as the bottleneck now seems to be actually rendering the 3D grid. Implementation here: 3D-Conway-Game-of-Life/compute_shader_experimental at main · rayanalysis/3D-Conway-Game-of-Life · GitHub
Video of the game in action:
This video demonstrates the deterministic starting grid configuration. By default, the program will begin with a probabilistic starting grid.
As you may well know, the Game of Life can produce surprisingly complex emergent phenomenon from simple rules.
My 3D implementation of the game runs the grid update calculation in a separate thread in order to provide closer to realtime visualization. Still, the updates are slow compared to the 2D representation. I believe that my implementation could run for a very long time, however, so theoretically I imagine that all the emergent behavior you might expect could occur eventually if you ran it long enough.
You may assign whatever grid size you like, though for practical purposes, any grid size over about 25 will tend to be slow on current gen personal computers.
Why did I do it in 3D? Well, 3D is cooler than 2D, and besides that, 3D cellular automata are kind of hot in computer science these days. Myself and some others believe that studying these automata could provide insights into such things as how molecular biology emerged from simple components. I believe this is the first such example of the 3D version of the Game of Life implemented in Panda3D, at least publicly.
Hope you find the program interesting! I’d be thrilled to see any follow up experiments, or even PRs if you think of something cool to add.
Evolution of a grid with 5,832,000 possible cube positions (generated with the compute shader version):