The Game of Life is a simulated 2 dimensional universe containing a grid of cells. As the cells are born and die, they form ever evolving patterns. The rules of the game are very simple, but the behaviour can be complex and fascinating.

In this section we will develop a very simple text based game in Python.

The rules

Each cell has 8 immediate neighbours. The fate of each cell depends on its current state, and how many living neighbours it has.

If a cell is currently alive:

  • If the cell has 0 or 1 living neighbours, it dies of loneliness.
  • If it has 2 or 3 living neighbours, it remains alive.
  • If it has 4 or more living neighbours, it dies of overcrowding.

If a cell is currently dead:

  • If the cell has 3 living neighbours, it comes to life (cells have 3 "parents").
  • Otherwise, it remains dead.

Some examples

Here are some examples of well known patterns. They are just examples, there are other pattern which have similar behaviour.

Still lifes

Some patterns are static, never changing. This pattern is called the Block:

Every living (black) cell has 3 living neighbours, so it stays alive. Every dead (white) cell has at most 2 living neighbours, so it cannot come to life. So the pattern never changes.

Oscillators

Some patterns switch between two or more patterns, over and over again. This pattern is called the Toad:

This pattern, the Pulsar, is a little more complex, and switches between three states:

Space ships

Space ships are a bit like oscillators, in that they switch between several different states. But they also move, so that they gradually drift across the screen. Here is the Lightweight Space Ship:

Random patterns

If you start with a random pattern of live cells, it will usually settle down to a fixed state eventually. This can happen after a few cycles, or it can take longer. Starting out with a lot of live cells doesn't necessarily mean that the decay will take longer. Here is what often happens:

  • The pattern will decay to nothing (all the cells will die).
  • Some cells will survive, in the form of Still Lifes or Oscillators, which are too far apart to interact. It will stay like that forever.
  • Some space ships will escape, while the rest of the universe will decay into one of the first two states. The space ships will drift off into the emptiness.

Complex patterns

There are numerous more sophisticated patterns which might appear quite simple but are actually very carefully designed.

Look up:
  • The Acorn - a simple arrangement of 7 live cells which lasts for over 5000 generation and spreads over a large area before stabilising.
  • The Gosper Glider Gun - a slightly more complex oscillator which shoots out a glider every so often.

Exercises

Using graph paper and a pencil, work out what these patterns do. You can check your answers after writing a Python program to run the game (next section).

Example 1

Example 2

Example 3

Note

You will need a very large piece of graph paper to try out the final example - it is the Acorn pattern. Just try the first few iterations or you will be drawing it for a week.