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.

- Click an initial pattern of squares on the board.
E.g. try a 3x3 cube, or an
**L**pattern. - Click
**Step**to advance the game one cycle. - Click
**Run**to advance the game approximately two cycles per second. - Click
**Stop**to stop the game. You can re-start the game with the**Run**button. - Click
**Rand**to set the board to a random pattern. - Click
**AllOff**or**AllOn**to reset the board to all empty or all populated.

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.

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:

- The top row wraps to the bottom row.
- The left side row wraps to the right side row (and vice versa).
- The top-left cell wraps to the bottom-right cell (and vice versa).

To see the wrap-around pattern:

- Double-click on a middle cell to see the numbering pattern.
- Double-click on a top or bottom or side edge cell to see the wrap-around convention at the top/bottom/side.
- Double-click on a corner to see the wrap-around convention at corners.

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

If a cell is populated:

- If it has zero or one neighbors, it dies, as if by loneliness.
- If it has two or three neighbors, it survives.
- If it has four or more neighbors, it dies, as if by overpopulation.

If a cell is empty:

- If it has exactly three neighbors, it becomes populated, as if by colonization.

The game runs until either:

- All cells are empty, as in extinction.
- Every populated cell has 2 or 3 neighbors, and no empty cell has 3 neighbors, as in a steady-state. For example, try a square of four cells.

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.

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:

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

left: [i] [(j-1+C)%C] |
current: [i] [j] |
right: [i] [(j+1+C)%C] |

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

The symbol **%** is the **mod** operator:

- Zip file with
HTML/JavaScript source
for
*The Game of Life*(and the**gif**files for cell colors).