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.
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.
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.
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: [(i-1+R)%R] [j]||up-right:
|left: [i] [(j-1+C)%C]||current: [i] [j]||right: [i] [(j+1+C)%C]|
|down: [(i+1+R)%R] [j]||down-right:
The symbol % is the mod operator: