About Conway's Game of Life

This is an implementation of Conway's Game of Life. The game starts with an initial "population" of squares, and simulates the advancement and decline of that population. I.e. it's a simulation game, not a board game like Checkers.

To run the game

This version of Game of Life is implemented solely in JavaScript. It is therefore small (around 10K), portable, and completely safe. But, it is therefore also slow, so it uses a small (7 by 10) board. There are many larger implementations of Game of Life written variously in Java, Pearl, C++, etc. You can find them on the web if you search from the websites listed below.

The Rules of Conway's Game of Life

The game board

Each cell has 8 neighbors. Double-click on a cell to see its neighbors, numbered 1-9, from left-to-right, top-to-bottom, with the selected cell as "5". Note: Double-clicking doesn't seem to work on Unix. It works OK on Windows with Netscape or IE.

This version of Game of Life treats the board as if it wrapped around:

To see the wrap-around pattern:

I.e. the game board is effectively spherical. Each cell has 8 neighbors. This keeps the game alive longer with a small board.

Computer nerds: See the formulae for wrap-around cells below.

Rules of the Game

If a cell is populated:

If a cell is empty:


The game runs until either:

The program stops in either of these conditions.

Life can also loop over the same states. For example, try three cells in a straight line. The program doesn't recognize such loops. Detecting them would slow down the Run function too much.

Formulae for the wrap around neighbors (for computer nerds)

Let R and C be the number of rows and columns (7 and 10 in the above layout). Number the cells from 0 to R and 0 to C, so the top-left cell is (0,0) and the bottom right cell is (6,9). The wrap-around formulae for the neighbors of a cell (i, j)are:

  [ (j-1+C)%C]
up: [(i-1+R)%R] [j] up-right:
  [ (j+1+C)%C]
left: [i] [(j-1+C)%C] current: [i] [j] right: [i] [(j+1+C)%C]
  [ (j-1+C)%C]
down: [(i+1+R)%R] [j] down-right:
  [ (j+1+C)%C]

The symbol % is the mod operator:

Source code (for computer nerds)