Neal.Rame.

The Game of Life

I wanted to learn how to use WASM with Rust so I followed the dedicated tutorial which takes the game of life as support.

I quickly wanted to add some features such as import/export of patterns that can be found in RLE or Life 1.06 formats, or draw on html canvas element from Rust code, etc.

The code is available here: NealRame/wasm-game-of-life.

What is a cellular automaton?

A cellular automaton is a theoretically infinite grid of cells that can take a finite number of states. Each cell of the grid evolves according to the state of its neighbors.

What is the game of life?

The Game of Life is a cellular automaton imagined by John Horton Conway in 1970 and which is probably the best known of all cellular automata.

In the Game of Life each cell can be in two states: alive or dead.

Each cell has 8 neighbors, which are the directly adjacent cells (see Moore neighborhood on Wikipedia).

At each stage, the evolution of each cell is determined by the rules following:

  • a dead cell with exactly three living neighbors will become alive,
  • an alive cell with two or three living neighbors will stay alive,
  • an alive cell having strictly less than two or more than three living neighbors will die.

Let see what happen with a random grid when we apply the rules of the game of life.

As the simulation runs, we quickly see patterns emerge, some are stable, some oscillate, and so on.

Patterns

Oscillators

Oscillators are patterns that repeat themselves without moving after a given number of steps. The number of step need to return to the initial state is called the period.

Blinker

The blinker has a period of 2 and is the simplest oscillator.

Monogram

This oscillator has a period of 4.

Trans Queen Bee Shuttle

The Queen Bee Shuttle is a period 30 oscillator.

Spaceships

Spaceships are like oscillators, however spaceships move.

Glider

Lightweight spaceship

Still lifes

Still lifes are Oscillators with a period of 1, and, thus, they do not change from one generation to the next.

Block

The block is the simplest still life.

Beehive

The beehive is a still life with 6 cells.

Eaters

Eaters are particularly useful to destroy spaceships, especially in toroidal grids where gliders can destroy other patterns.

Gun

Guns are patterns that create spaceships.

Gospel Glider Gun

Gospel Glider Gun is the first gun discovered. He emits a glider every 30 generations. It was discovered by Bill Gosper in 1970.

The eater in the bottom right corner is used to destroy the gliders that would otherwise destroy the gun.

P24 gliderless LWSS gun

Again the eater in the bottom right corner is used to destroy the spaceships that would otherwise destroy the gun.

Complex patterns

Queen Bee Turn

Gunstar

Make your own

Now, go click right and left, run the simulation and see where it takes you.

Controls

launch the simulation
pause the simulation
step forward the simulation
toggle the grid on/off
reset the simulation
clear the simulation
randomize the simulation

More about the Game of Life

More details on the Game of Life is available by following the links following: