Conway's Life for EDSAC - Program notes.

Michael Behrend, October 2021

Conway's algorithm can be restated as follows: For each cell in the grid, count 2 for each live neighbour, plus 1 iff the cell itself is alive. It follows from Conway's rules that the cell is alive in the next generation iff its count is 5, 6, or 7.

The program does not directly work out a count for each cell by testing whether its neightbours are alive or dead. Instead, each live cell adds a count of 2 to each of its neighbours, and 1 to its own count.

To avoid special action for edge and corner cells, the 16 x 35 display is assumed to be surrounded by a 1-cell border. All cells in the border are assumed to be dead.

The program scans one row of 35 cells at a time, that is, one 35-bit word in the EDSAC store.

We need only keep track of the counts in 3 rows at a time. Also, the maximum count is 17, which fits into 5 bits. Hence 3 counts can be stored in a 17-bit EDSAC word without interfering with each other. The counts are kept in bits 0..4, 5..9, 10..14. Each of the 37 columns (including the borders) has such a 3-count word assigned to it. Bits 5..9 are assigned to the row being scanned; bits 0..4 to the previous row; bits 10..14 to the next row.

To update the pattern for a new generation, all counts are cleared. Then the program scans row 0. If the cell in column X is live, the counts are updated by adding
  00 00010 00010 00010 binary to column X + 1
  00 00010 00001 00010 binary to column X
  00 00010 00010 00010 binary to column X - 1
The counts are now shifted 5 right, so that the count for the border row -1 is discarded, and the count for row 0 comes into the low 5 bits.

Row 1 is now scanned in the same way. The low 5 bits now contain the total count (from rows 0 and 1) needed to build the the new row 0.

When the new row 0 has been built, the counts are again shifted 5 right and row 2 is scanned. The low 5 bits now contain the total count (from rows 0, 1, and 2) needed to build the new row 1.

When the new row 1 has been built, the counts are again shifted 5 right, etc.

After the new row 14 has been built, there is no further scan, but the counts are shifted 5 right and used to build the new row 15.

The current version of the program saves some time (though not as much as was hoped) by grouping the count words in pairs and using 35-bit arithmetic. An extra border column is added on the right, giving 19 pairs of counts, and cells (bit positions) in each row are tested 2 at a time.
