TinyMipsWithRam: Conway's game of life

The image above shows a thumbnail of the interactive Java applet embedded into this page. Unfortunately, your browser is not Java-aware or Java is disabled in the browser preferences. To start the applet, please enable Java and reload this page. (You might have to restart the browser.)

Circuit Description

This applet shows Conway's Game of Life, a famous mathematical puzzle, running on the TinyMips (with on-chip memory) connected to a KS0108-controlled display.

#### The Game of Life algorithm

The algorithm demonstrated in this applet was first presented by mathematician John H. Conway in 1970. See the Wikipedia article for a concise description and some links. A rectangular game-board of arbitrary size is used, where each position on the board can be occupied (live) or empty. The total set of occupied positions is called a population or generation, and the following rules are applied to calculate the new generation at time step (i+1) from the generation at time step i:

• Any live cell with fewer than two neighbours dies (loneliness).
• Any live cell with more than three neighbours dies (overcrowding).
• Any live cell with two or three neighbours survives to the next generation.
• An empty cell with exactly three live neighbours is occupied on the next generation (birth).

A random initial population then evolves under the above rules until a steady state is reached. This can take a long time, on the order of 1000 iterations or more, because the rules are deliberately chosen to avoid premature extinction or overpopulation. While the gaming rules are simple, the evolution of the game often shows complex and interesting patterns. The following screenshot of the display shows a typical position:

The C source code of the game algorithm is shown below. The game board is represented as a large array, where shifts and adds are used to access the individual positions. One whole memory-word is used to store one bit of the game board; this representation wastes some memory, but allows watching the data in the memory editor during the program execution. For the same reason, shifts are used instead of multiplications. Naturally, shifts would also be a lot faster than multiplications on most low-end hardware.

Usage

Wait until the applet is loaded, then use the popup-menu (via popup > edit) to open the user-interface of the processor. Also, click on the symbol of the display (or use the popup again) to open the user-interface of the graphics display. Watch the evolution of the game positions.

The binary program running on the processor was compiled and linked with the GNU gcc (2.7.2.3) and binutils cross-compiler toolchain on a Linux x86 host, with the final ELF loading and relocation done via the Hades Elf2rom tool. See

for details.

Print version | Run this demo in the Hades editor (via Java WebStart)
Usage | FAQ | About | License | Feedback | Tutorial (PDF) | Referenzkarte (PDF, in German)