The Game of Life - A study of Simple Lifeform Simulation
The Game of Life is a computer simulation program originally devised by the British mathematician John Horton Conway in 1970. When the first computers became available to the public, it became possible to experiment with math and simulations that generated a visual feedback instead of just numbers. One of those early simulations was the Game of Life. As it turns out, it is not really a game but a cellular life simulation based on a set of rules that cause the cells to grow into more cells, or die. There are many possible versions of the simulation, but one of the standard set of rules is as follows:
- Any live cell with fewer than two live neighbors dies, as if caused by underpopulation.
- Any live cell with two or three live neighbors lives on to the next generation.
- Any live cell with more than three live neighbors dies, as if by overpopulation.
- Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.
We will build our game with the easily available 8x8 Led matrix display. We will use two switches, one will be to randomize the display to start, and the second will be used to start or stop the simulation. See the diagram to the right for the component hookup.
Specifically, the Led matrix has the following connections: pin 12 is connected to the DataIn pin 11 is connected to the CLK pin 10 is connected to CS Switch 1 (Randomize) Pin 8 and GND Switch 2 (Start/Stop) Pin 9 and GND |

Lay the circuit out however you wish (I used a convenient breadboard proto shield). The Randomize switch stops the simulation and resets the display to a random set of cells. Press the Randomize button until you like the initial pattern. The Start/Stop button then starts the simulation running. At any time, press the Start/Stop button to start and stop the simulation progress.
Click the file below to download the completed sketch

gameoflife.ino |
After initialization of the pinModes for the switches ( we use INPUT_PULLUP so we don't need external pullup resistors) and the LED matrix, the code looks to see if the buttons are pressed.
The code then waits for the START switch to be pressed. When the simulation is running, the math is done to evaluate the cell growth/demise of the cells and updates the next life-state. When one second has passed, that new state is shown and the next is processed.
The Randomize button stops the simulation and fills the 8x8 field with random cells.
To "play" this game, press the Randomize button until you have an initial set of cells that you like. Then press the Start/Stop button to run the simulation.
The code then waits for the START switch to be pressed. When the simulation is running, the math is done to evaluate the cell growth/demise of the cells and updates the next life-state. When one second has passed, that new state is shown and the next is processed.
The Randomize button stops the simulation and fills the 8x8 field with random cells.
To "play" this game, press the Randomize button until you have an initial set of cells that you like. Then press the Start/Stop button to run the simulation.