Game of Life
Conway's Game of Life is a classic example of cellular automata, with incredibly simple rules giving rise to surprising levels of complexity. It takes place on a grid, where each cell has a live and a dead state. The behavior of a cell each tick is determined by the following rules:
- Any live cell with two or three neighbors survives.
- Any dead cell with three live neighbors becomes a live cell.
- All other live cells die in the next generation. Similarly, all other dead cells stay dead.
Beyond this, the game can be expanded to include coloured cells, which requires additional rules and states.
Migration (2-color)
The basic case involves giving all living cells two colors. In order to keep behavior consistent with the basic game of life, the rules for living and dying remain the same, with new rules for color being added.
- When a cell becomes alive, it takes on the majority color if its neighbors. Since a dead cell needs three living neighbors, there is always a majority color.
- All living cells keep their color.
Quad (4-color)
Extending the 2-color rule-set into 4 colors is straightforward. The only difference is that majority color is no longer guaranteed, since a 3-way tie can occur. In this case, the tie is resolved by setting the color of the new cell to the one that is not currently present among the three neighbors.
- When a cell becomes alive, it takes on the majority color if its neighbors. If there is no majority color, it takes on the color that is not present among the neighbors.
Multicolor
This is a generalization of the previous rule-sets into a continuous color space. Each cell has a color determined by a hue, which can be interpreted as an angle on the color wheel. When a new cell is born, it takes on the average color of all its neighbors. Since each color is essentially an angle, in practice this means averaging the angles of the neighbors. In the simulation below, dead cells also keep their last color when they were alive, although dimmed. This produces a good aesthetic effect, and gives a sense of the amount of space cell interaction cover.
- When a cell becomes alive, it takes on the average color of its neighbors.
Demo
The initial state is generated by setting a random number of cells to a living state, and optionally giving them a random color if necessary. The board wraps on the x and y axes, which topologically produces a toroid.