# All 256 Elementary Cellular Automata

Simon has returned to his beloved Cellular Automata theme and created this nice sequence comprising all the 256 elementary rules. You can access his code at https://editor.p5js.org/simontiger/sketches/gECh5tVwa

Simon explains:

Every cell changes according to its color and that of its two neighbors. It starts with all white cells except for a single black cell in the middle. Time is displayed vertically. Sometimes you get just a single color, sometimes you get a repeating pattern, sometimes you get a fractal and other times you get something completely unpredictable.

For a given cell, there are two states. There are three “neighbors”: the cell itself, the cell to its left, and the cell to its right. This means there are 8 possible neighborhoods. For each one we need a different outcome for the cell itself. So there are 2^8 = 256 possible rules. You can also take each of the outcomes and convert them to 1s and 0s: 0 being white and 1 being black. You end up with a binary number which you can convert to decimal, and that’s how the rules are numbered.