If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

What is the Game of Life?
The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. The game is really a zero-player simulation, meaning that its evolution is determined by its initial state, requiring no further input.

Conway chose the rules of the simulation after trying many possibilities, some of which caused the cells to die too fast and others which caused too many cells to be born. Life balances these tendencies, making it hard to predict whether a pattern will die out completely, form a stable population, or continue to grow forever.

Rules of the Game of Life.Life is played on a grid of square cells (24 x 16 in our case). A cell (pixel) can be alive or dead. A live cell is shown by illuminating a pixel in its grid location, and a dead cell is shown by extinguishing the pixel in it's grid location. Each cell in the grid has a neighbourhood consisting of the eight cells in every direction including diagonals.

To apply one step of the rules, we count the number of live neighbours for each cell. What happens next depends on this value.

A dead cell with exactly three live neighbours becomes a live cell (Birth).

A live cell with two or three live neighbours stays alive (survival).

In all other cases, a cell dies or remains dead (overcrowding or loneliness).

The number of live neighbours is always based on the cells before the rules are applied. In other words, we must first find all of the cells that change before changing any of them. Which is why the BASIC source code uses a double buffer. The rules are applied to the shadow buffer, then transferred to the main buffer for display on the LEDs.

Proton implementation.
The code for the Life game is far from complex in its operation, as it must follow the strict rules of the game. Its relative complexity comes from the double buffering method that must be used, as outlined in the above paragraph.

This is normally accomplished by creating two arrays, however, this is rather wasteful of RAM and cumbersome in operation, especially when we're using an interface that already has its display mapped to RAM. Therefore we only require a single shadow RAM area. i.e. a byte array.

The shadow RAM is manipulated in the same manner as the display RAM, by versions of the HT_Plot, and HT_Pixel routines. These are named Shadow_Plot and Shadow_Pixel. This makes for an easier to follow program flow.

The Proton BASIC source codes for the Game of Life can be downloaded from here: Game_Of_Life_Code.zip
There are two versions within the folder, the first is named "Game_Of_Life.bas" and uses a fixed pseudo random number generator for its initial startup pattern. The second version is named "Game_Of_Life_Button.bas", and this uses a 16-bit timer to seed the pseudo random number generator based upon when the button is pressed. The second version also has a scrolling text start-up screen, which you may find interesting.

A circuit for the addition of the button to the existing companion shield to Sure 2416 display is shown below: