[LIFE6.BBX 7KB]
Life is a mathematical game invented by John Horton Conway, described in October 1970 in Martin Gardner's Scientific American column, "Mathematical Games". It is played on a rectangular grid whose pixels live and die according to a simple set of rules, designed to allow figures to survive and grow without encouraging wild expansion. It has nothing to do with the board game of the same name.
After the initial states of the pixels is specified, each pixel's fate depends on the states of its eight horizontal, vertical and diagonal neighbours. A living pixel survives to the next generation if it has exactly two or three neighbours. Too few neighbours leads to death by loneliness, while too many cause death by overcrowding. A new pixel is born into any empty pixel with exactly three neighbours. During a single generation, a pixel's neighbours are the pixels that were alive in the previous generation; births and deaths in the current generation do not affect their neighbours until the next generation.
Neighbours | Next state |
---|---|
0 | Dead |
1 | Dead |
2 | No change |
3 | Alive |
4-8 | Dead |
Life is fascinating because even a very simple figure can produce startling, beautiful patterns. Most figures eventually reach a steady state, either static or cycling through several configurations. A simple cyclic figure is the Blinker: three pixels in a horizontal or vertical row. It "blinks" between a horizontal and a vertical line. While the end pixels die of loneliness, new pixels are born in the positions adjacent to the midpixel, since they each have three neighbours. A more interesting pattern is the Glider. It slowly moves diagonally across the grid requiring four generations to move by one pixel. This is the pattern that is displayed when Life6 is loaded.
Life6 implements a 6x6 square grid of Life using a neural network. Each pixel of the grid is made up of three neurons in a triangular group. The lower two determine if the pixel will be alive or dead (death has priority) in the next generation. The top neuron reflects the current state of the pixel.
Each Life generation takes two execution steps. To change the grid's pattern one may have to single step the net once so that the top neurons are the active ones, then their states may be toggled. An interesting side-effect of the two-step generation is that a second Life pattern can be run concurrent with the first, without any interference between the two -- as long as they are half a generation out of phase. The second pattern doesn't slow down the network at all because every neuron must compute its state each step anyway.
See also Life6T, which is the same as Life6 but with the addition of wrap-around links to make the 6x6 playing field toroidal.