Making Cellular Automata Planets in MATLAB With a 3-body Simulation

Francisco Sebastiano
2 min readJul 12, 2023

--

No, the title was not randomly generated.

Continuing from my previous article on cellular automata, In this article I aim to simulate a full ecosystem using Conway's game of life. That means I want to simulate organisms, their environment, and the interactions between the two. Lastly, I’ll use the game of life to liven up the surface of planets in a 3-body simulation, producing a neat little solar system simulation in MATLAB.

All of the programs I wrote for this article are in a Github repository: https://github.com/franciscoSebastiano

3D Version

To create a cellular automata ecosystem I needed to determine the components of that ecosystem and how they would interact. I decided that there would be three types of cells: water, land, and plant. Within those types of cells there would be differences in cell height and color, hopefully giving enough variation to my ecosystem for it to look alive. The thing that differentiates cell types are their values. Each cell has a 2D matrix coordinate and is made 3D by the value associated with that cell. Higher cell values indicate a higher elevation. This means that the ocean should be made up of low values (sea level) and anything above sea level should be a plant or animal. I decided that a plant would be represented by any decimal number above sea level and that land would be represented by any whole number above sea level. The game of life would run by adding or subtracting health points form the value of a cell based on its neighbors, producing cells with decimal number (plant) and whole number (land) states. The result of these ideas plus a lot of fine tuning is shown in the above and below videos.

2D Version

The next step wasto generate a set of spherical coordinates, then convert said coordinates to cartesian coordinates using the sph2cart() function in MATLAB. The cartesian coordinates can be used to plot the cellular automata simulation spherically, as is seen in the below video.

Hey! That’s starting to look like a planet! To make the simulation a bit cooler I wrote a 3-body problem numerical approximation and used it to move planets around. The below video is of the solver performing the famous figure-eight solution.

Lastly, I added my cellular automata planets into the 3-body orbit simulation. I have an earth-like planet running the ecosystem, a sun running Conway’s Game of Life, and the moon is just a static grey ball not running any cellular automata.

--

--