the next generation

We're now ready to produce the next generation acording to the rules:

  1. Any live cell with fewer than two live neighbours dies, as if caused by underpopulation
  2. Any live cell with more than three live neighbours dies, as if by overcrowding.
  3. Any live cell with two or three live neighbours lives on to the next generation.
  4. Any dead cell with exactly three live neighbours becomes a live cell.

The trick is to set up an empty temp array and to generate the next generation in it.

When complete, overwrite g_squares with the contents of temp.

Why not have a go before looking at my gen() function?

One tip: I avoided the problem of the neighbours function on the edges by not including the edges in my checking of each cell.