This is a post to provide info and answer some questions raised in the comments of the following YouTube movie.
Cellular Automata in 3D
3D Cellular Automata are extensions of the more common 1D Cellular Automata and 2D Cellular Automata into the third dimension. Rather than just checking neighbor cells in the X and Y directions, the Z direction is also included.
Neighborhoods in CA refers to which cells around each cell influence it’s birth, survival and death.
The two most common types of cell neighborhoods used in 2D CA are Moore and Von Neumann.
For 3D Moore extends to 26 possible neighbors (think of a Rubik’s cube with the middle of the cube as the current cell). Or consider a 3x3x3 3D grid of little cubes. The interior cube is the current cell, so the remaining 26 cubes around it are the neighbors of the center cube.
3D Von Neumann uses only neighbor cells sharing a face with current cell. This gives the 6 cells in the +/- X, Y and Z axis direction from each cell. Think of a 3D “plus sign” or cross shape.
Rule 445 is the first rule in the video and shown as 4/4/5/M. This is fairly standard survival/birth CA syntax.
The first 4 indicates that a state 1 cell survives if it has 4 neighbor cells.
The second 4 indicates that a cell is born in an empty location if it has 4 neighbors.
The 5 means each cell has 5 total states it can be in (state 4 for newly born which then fades to state 1 and then state 0 for no cell)
M means a Moore neighborhood.
Another rule is Clouds 1 shown as 13-26/13-14,17-19/2/M
Alive cells with 13,14,15,16,17,18,19,20,21,22,23,24,25 or 26 neighbors survive.
Empty cells with 13,14,17,18 or 19 neighbors have a new cell born at that location.
2 states. Cells are either dead or alive. No refractory period they fade from birth to death.
M means a Moore neighborhood.
More than 2 states can be confusing at first. In a 2 state CA when a cell dies it goes immediately from living (state 1) to dead (state 0). In more than 2 states, when a cell dies it does not immediately go to state 0. Instead it fades out to state 0. If there are 5 total states then a live cell with state 4 (4 not 5 as the possible state values are 0,1,2,3 and 4) fades to state 3, then 2, then 1 and finally disappears at state 0.
Here are all the rules I currently include with Visions of Chaos.
3D Brain (Jason Rampe) /4/2/M
445 (Jason Rampe) 4/4/5/M
Amoeba (Jason Rampe) 9-26/5-7,12-13,15/5/M
Architecture (Jason Rampe) 4-6/3/2/M
Builder 1 (Jason Rampe) 2,6,9/4,6,8-9/10/M
Builder 2 (Jason Rampe) 5-7/1/2/M
Clouds 1 (Jason Rampe) 13-26/13-14,17-19/2/M
Clouds 2 (Jason Rampe) 12-26/13-14/2/M
Construction (Jason Rampe) 0-2,4,6-11,13-17,21-26/9-10,16,23-24/2/M
Coral (Jason Rampe) 5-8/6-7,9,12/4/M
Crystal Growth (Jason Rampe) 1 0-6/1,3/2/N
Crystal Growth (Jason Rampe) 2 1-2/1,3/5/N
Diamond Growth (Jason Rampe) 5-6/1-3/7/N
Expanding Shell (Jason Rampe) 6,7-9,11,13,15-16,18.6-10,13-14,16,18-19,22-25/5/M
More Structures (Jason Rampe) 7-26/4/4/M
Pulse Waves (Jason Rampe) 3/1-3/10/M
Pyroclastic (Jason Rampe) 4-7/6-8/10/M
Sample 1 (Jason Rampe) 10-26/5,8-26/4/M
Shells (Jason Rampe) 3,5,7,9,11,15,17,19,21,23-24,26/3,6,8-9,11,14-17,19,24/7/M
Single Point Replication (Jason Rampe) /1/2/M
Slow Decay 1 (Jason Rampe) 13-26/10-26/3/M
Slow Decay 2 (Jason Rampe) 1,4,8,11,13-26/13-26/5/M
Spiky Growth (Jason Rampe) 0-3,7-9,11-13,18,21-22,24,26/13,17,20-26/4/M
Stable Structures (Evan Wallace) 13-26/14-19/2/M
Symmetry (Jason Rampe) /2/10/M
von Neumann Builder (Jason Rampe) 1-3/1,4-5/5/N
Most of the rules that I include with Visions of Chaos were found by trying multiple random rules until something interesting appeared. I am always interested in new rules so if you download Visions of Chaos and discover any new rules let me know.
There are various ways you can assign colors to the CA cells;
RGB Cube. Convert the XYZ coordinates to RGB color values.
Color Palette. Map the distance of each cube from the center to a color palette.
White Only. Color all cubes white. This can be useful when you have multiple colored lights.
State Shading. Color cells based on which state they are in. Shaded between yellow and red for the example movie.
Neighborhood Density. Color based on how dense each cell and its nearest neighboring cells are.
Important Note For Other Coders
You saw my 3D CA video and are making your own 3D CA. Awesome. You have gotten your renders working to display all those little cubes and decide to try a few of the rules in the video. But then you get different results. The rules “almost work” but are not the same. Relax, this is probably my fault and not yours.
When I originally created the 3D CA video for YouTube I was not using the correct cell survival logic. Normally in a (for example) 3 state CA a state 1 cell will survive it is has the required number of neighbors. Cells not in state 1 will automatically fade out no matter what their neighbor configuration is. In my original code I had the logic that a cell of any state can survive. That is what causes the slight differences.
The rules I list in this post under the “Rules Explained” section do all work as expected with the correct survival logic. If you want to confirm your code works against my rules you can download Visions of Chaos and compare the results with yours.
When this error was pointed out to me it had been years that I used the incorrect logic in my 3D and many of my 2D CAs. Just one of those bugs that can go on undiscovered for the longest time in your code.
Answering Questions and Responding to Comments
Some people refer to the 3D CA as the “Game of Life” or “Brian’s Brain”. This is wrong. “Game of Life” is a specific rule of 2D CAs and it does not have a direct equivalent in 3D. The movie above is a 3D Cellular Automaton, not a “3D Game of Life”. When referring to these CAs call them 3D Cellular Automata, not 3D Life or 3D Brain or whatever else.
The music was a quick composition by me using FL Studio.
I am glad most people seem to like the movie. I have to give a shout out to the Mitsuba Renderer. Mitsuba is responsible for rendering the very nicely shaded little cubes that allow the structures of the CA rules to be seen so clearly.
If you have any other 3D CA questions, leave a comment here or in the YouTube video comments and I will try and address them here in the future. Cellular Automata are a fairly simple concept once you understand the basics of how they work.