Hades logo    Hades applet banner

TAMS / Java / Hades / applets (print version): contents | previous | next

TinyMipsWithRam: Conway's game of life

TinyMipsWithRam: Conway's game of life screenshot

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:

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:

screenshot of game board

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.

Run the applet | Run the editor (via Webstart)


Impressum | 24.11.06
http://tams.informatik.uni-hamburg.de/applets/hades/webdemos/76-mips/31-life-onchip/life_print.html