Math: Cellular Automata

Math: Cellular Automata

You are provided a grid of squares where each square can be clicked on to bring that square to "life". In addition to the selected square changing colors, numbers show how many adjacent squares are alive. For example, if only one square is selected, then all of the squares surrounding it show a 1. The following are some examples:

A single cell of a grid selected with the number 1 indicating how many of the surrounding cells are selected or alive. A grid with selected cells in the shape of a plus with numbers indicating how many of the surrounding cells are selected or alive. A grid with a ring of cells selected with numbers indicating with numbers indicating how many of the surrounding cells are selected or alive.

Try clicking on some of the squares in the grid and then press Advance a few times to see how the grid changes. You can also click Start/Stop to see it continue to run. What causes the squares to appear and disappear?

What makes this game interesting are the rules that govern it. The rules are set on lines 2 and 3 of the code and are set to the following:

Line 2

If the square is alive (highlighted) and there are 2 or 3 adjacent living squares, then the square stays alive or survives.

Line 3

If the square is dead (not highlighed), but is surrounded by 3 or 6 adjacent living squares, then the square comes to life.

Otherwise, the square dies (changes from orange to white). Remember this is only a simulation, no actual squares were harmed! Here are a few examples:

Click on the grid to create any pattern you like and apply the rules either one cycle at a time by pressing Advance over and over or let it run over many cycles by clicking Start. What you are witnessing is an example of complexity where interesting behavior emerges as a result of multiple elements interacting with one another. Such interesting interactions come from arbitrary rules!

These patterns have been studied for years and certain groups have been discovered just as one might discover a type of animal in the wild. Try to recreate these types on your own by creating patterns on the grid and pressing Start:

  • Stable - Patterns that do not change over time

  • Oscillators - Patterns that change over time but repeat themselves every n cycles.

  • Flyers - Patterns that essentially stay the same over time but move across the board like a bird or spaceship.

  • Discover your own type of pattern

Another way to modify the system is to change the rules themselves. The rules used in this simulation are only one example of what is more broadly known as cellular automata and an entirely new set of properties emerge for each type of rules. The simulation uses the "S/B" rule string where S refers to survival and B refers to births. In this simulation the Game of Life S/B is 23/36 which corresponds to a living cell with 2 or 3 adjacent living cells surviving and a dead cell with 3 or 6 adjacent living cells becoming alive. You can see many different rules that have been studied over years and try them out by changing lines 2 and 3 in the simulation. If you change the rules you will need to press the Play button pencil_code_play.png to run the code again.

Mathematics is an interdisciplinary topic and the study of systems and emergent behavior has influenced and initiated new areas of research in the sciences and humanities. New insights and new fields of study are often the result when algorithms are designed and applied.

If you are interested in learning more about this topic, search the Internet for cellular automata and Game of Life. Stephen Wolfram developed a system for creating rules for cellular automata and has studied their properties extensively. You can read more about it on Wolfram's Mathworld or in A New Kind of Science which is free to the public online. Potential standards this activity could align with if used with students.