CSCI 241 Labs: Prelab 9
The Game of Life


 

The Game of Life was invented by the mathematician John H. Conway to simulate the birth and death of cells in a society. The society exists on a rectangular grid (or board) of locations, which can be implemented as a 2-dimensional array. The Game of Life generates an animation. The board changes over time as cells are born and die. This 'game' was at one time very popular as a screen saver because of the interesting patterns it generates. It also is of some theoretical interest in the theory of computation. Below is a screen capture of a Game of Life screensaver.

Game Of Life Screen Saver

The board evolves over a series of generations. The previous generation determines which cells are alive in this generation. Likewise, this generation determines which cells will be alive in the next generation. Cells come to life and die off according to certain rules. The following rules govern birth and death of these cells between two generations of the society. At time T:

  1. A cell is born if there was none at time T-1, and exactly 3 of its neighbors were alive.
  2. An existing cell remains alive if at time T-1 there were either 2 or 3 live neighbors.
  3. A cell will die from isolation if at time T-1 there were fewer than 2 live neighbors.
  4. A cell will die from overcrowding if at time T-1 there were more than 3 live neighbors.
A neighborhood consists of the 8 elements around any other element (i.e. the cells found immediately in each of the 8 directions (north, northwest, west, etc.) from the element). For example, cell[5][6] has these neighbors:
cell[4][5], cell[4][6], cell[4][7], cell[5][5], cell[5][7], cell[6][5], cell[6][6] and cell [6][7].
The edge of the board presents special problems, since there are not 8 neighbors. The two choices are to handle the edge are to either
  1. Assume a border of dead cells all the way around the board, or
  2. Wrap to the opposite edge of the board.
We will use the second alternative. Thus, cell [0][6] will have some of its neighbors in the bottom row (ROWS-1). Similarly, cell[5][COLS-1] will some of its neighbors in column 0.

The figures below represent a sequence of generations. Its initial configuration contains 5 live cells in a column. It stabilizes and starts repeating generations 7 and 8 over and over.
1
2
3
4
5
6
7
8

Try to work through these generations by hand, seeing how the rules produce each image. Assume the first generation includes cells in array positions: [2][4], [3][4], [4][4], [5][4] and [6][4].

The interesting part of this 'game' is that certain groups of patterns behave very differently. Some patterns change and then stabilize by repeating themselves as in the example above. Some patterns quickly evolve into extinction. Other patterns continue to exist but move across the board. Complex behaviors can be illustrated by combining these patterns together. Your results depend on both the starting arrangement of cells and the variations of rules you use to determine the changes.