Game of Life

What is it

This model demonstrates how to implement a two-dimensional cellular automaton using Xholon. A cellular automaton performs actions based on specific rules. The two-dimensional grid is divided into cells. Each cell can be in either the "alive" or "dead" state, depending on what happened to its neighbors in the previous time step.

The Game of Life is a particularly well-known cellular automaton. The rules of the Game of Life are:

  • Each time step, each cell checks its state and that of its eight immediate neighbors. Based on this evaluation, it sets itself to either alive or dead.
  • If it has fewer than two alive neighbors, the cell dies.
  • If it has more than three alive neighbors, it dies.
  • If it has exactly two alive neighbors, the cell remains in its current state.
  • If it has exactly three alive neighbors, it becomes alive.

There are certain recurring shapes in Life, for example, the "glider" and the "blinker". The glider wiggles across the world, retaining its shape. A blinker is a block of three cells (either up and down or left and right) that rotates between horizontal and vertical orientations. The glider is composed of 5 cells which form a small arrow-headed shape, like this:


How to use it

Run it:

  1. Run the Java application through the Xhn GUI (, and select File --> Open --> GameOfLife --> GameOfLife_xhn.xml.
  2. A grid viewer and tree viewer will appear. The grid viewer will display a random initial pattern.
  3. Expand the Controller node in the tree viewer.
  4. Press the Start node.
  5. The grid viewer will show a constantly changing pattern of alive and dead cells.

Pause and Step the model:

  1. Press Pause to pause and un-pause the executing model. Press Step to advance the paused model by one time step. Press Start to un-pause the paused model.

Things to notice

Find some objects that are alive but that don't move or change.

Things to try

Are there any recurring shapes other than gliders and blinkers?

Extending the model

Alter the rules and see what happens. The rules are implemented by postAct() within

Experiment with using 4 neighbors for each cell instead of 8 neighbors. Change config instruction="Gmt" to config instruction="Gvt" in ClassDetails.xml. This changes it from a Moore type grid to a von Neumann type grid.

The grid is currently a torus meaning that cells along the top, bottom, right and left edges include as neighbors cells that are along the opposite edge. Make it a true grid with hard edges by changing config instruction="Gmt" to config instruction="Gmg" in ClassDetails.xml.

Allow the model to read in an initial arrangement of alive and dead cells. See the AntTrails model for an example of how to do this.

Xholon features

This application demonstrates how to implement a 2-D grid within a Xholon tree. See and its superclass AbstractGrid.

It also demonstrates how to visualize the 2-D grid. See sections bracketed by if(useGridViewer) in, and see also and

Credits and references

Some of the information in this document is taken from: Wilensky, U. (1998). NetLogo Life model. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

The Game of Life was invented by John Horton Conway.

See also:

Martin Gardner, "Mathematical Games: The fantastic combinations of John Conway's new solitaire game `life',", Scientific American, October, 1970, pp. 120-123.

Martin Gardner, "Mathematical Games: On cellular automata, self-reproduction, the Garden of Eden, and the game `life',", Scientific American, February, 1971, pp. 112-117.

William Poundstone, The Recursive Universe, William Morrow: New York, 1985.