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.
Amazing work! I’d love to see more of this.
Please someone make a Minecraft-like mining game with underground levels generated with the Clouds 1&2 rules !
I’ll be doing it, when I can understand better c#
Awesome work. 🙂 I have a question about the “refractory period”. If a cell with 5 possible states goes from state 4 to state 3 to state 2, and at that point there are the right number of cells around it for it to survive, does it snap back to state 4 “fully alive”? Or does it increase one state back to state 3? I would assume the first – also I wonder if it would make a large difference in the simulation to change how the refractory period is used.
Only newly born cells are counted in the rules. Cells that are “dying off” in the refractory period do not count as living cells in the rules. So once a cell enters the refractory period it continues fading out that way until it dies.
A fading cell cannot be suddenly changed to a newly born cell. Only state 0 fully dead empty cells can be born (based on the number of newly born neighbor cells).
The refractory cells act more as a “delay” to the cells slowing the time a cell takes to die before the possibility of a new cell being born in that location.
Hope that helps.
how do you choose which colors each cell gets?
I updated the post with a quick explanation of the methods I use.
Hey, thanks for your explanation.
I am a web developer and you inspired me to implement a 3D cellular automata in the browser, I have finished coding the logic but I don’t have any starting conditions to test the system.
Do you mind sharing a couple of your automatons details?
Pingback: Cave generation using cellular automata – Windows Questions
would you please give a detailed instruction on how to run the code on a local computer?
1. Start Visions of Chaos
2. Mode->Cellular Automata->3D->3D Generations Cellular Automata
3. Click OK to start
There are samples included. Click Open and then select “Visions of Chaos Presets”.
Ive been coding a 3D cellular automata program on Unity but I am having trouble implementing the 445 rule… Maybe I am misunderstanding the instructions but whatever I try by tweaking a little I either get a quick disappearance or a quick growth that fills up my entire cube and stabilizes. Could you maybe rephrase the 445 rule? I got the cloud 1 rule to work so I thought it was that I was just misunderstanding 445.
Here is how I am currently trying to apply the rule, where count is the number of live moore neighbors and state is the state of the current cell under consideration:
if (count == 4 && state == 4)
else if (count == 4 && state == 0)
else if (state > 0)
return state – 1;
(Also before you tell me this is hella inefficient and slow, note that im running this on a shader).
Moore neighborhood is the surrounding 26 cells.
The 4/4/5 rule logic is;
If cell is empty (state 0) and has 4 neighbors then a new cell is born (change to state 1)
If a cell is state 1 and has 4 neighbors it survives and remains state 1, else it goes to state 2
State 2 cells go to state 3
State 3 cells go to state 4
State 4 cells go to state 0
State 0 are empty/dead cells. State 1 are newly born cells. States 2 to 4 are the dying/refractory cells.
Initialize the grid with a central small random cluster of state 1 cells.
Hope that helps.
After messing around with my unity 3d cellular automata program i found that the ru;e 4-7/4-20/10/C yields cool results that can unexpectedly terminate depending on initial conditions (Im messing around with spheres centered that strat at state 10 of different sizes). C is a custom neighborhood which is just the difference of a moore neighborhood and von neumann neighborhood. Try it out.
This is amazing and it has inspired me to make my own 3d cellular automata simulator. I’ve made really good progress but I’m noticing your rules do not behave in my program like they do in your video. This is my logic:
If a cell has state 0, check see if it has the right amount of neighbors to come alive. Set state to 1 if so.
If a cell has state 1, check if it has enough neighbors. If not, add one to state, starting dying process. If state equals the total number of states, then set state to 0.
If a cell is not 1 or 0, increment it and check if equal to total number of states.
Do you see anything that could be wrong with my logic? I believe I’m close to correct because my simulation with your rules comes close but is not exact.
Yes, there was a bug in my logic when I originally made the video. In my case a cell in any state would survive if it had the right number of neighbors. This is wrong and only cells of state 1 should follow the survival rules, otherwise the cell should go through the usual refractory/dying states.
The rules I list in the post are correct and do work with the right CA logic. If you want to compare your results with mine take a look at the latest 3D CA mode in Visions of Chaos. It uses the listed rules.
Apologies for any confusion. I couldn’t believe I had that error in my CA code (not just the 3D CA) for many years until it was pointed out to me.
As part of my PhD research I’m exploring 3D CA, and love your animations. How did you create them?? Is the code available?
Created using Visions of Chaos. No source code available, but if you are researching CA you already know the algorithms.