I’m trying to write code for Conway’s Game of Life to determine the immediate next pattern for a given pattern of cells, but I’m not sure whether I really understand the steps. So for example consider the below toad pattern. The cells marked x are alive and those marked – are dead.
-XXX
XXX-
The above should transpose into the following
--x-
x--x
x--x
-x--
The rules as we know are:
- A live cell with less than 2 or more than 3 neighbours dies
- A live cell with exactly 2 or 3 neighbours survives
- A dead cell with exactly 3 neighbours comes to life.
So, the first cell in the input c[0,0] is – and it has 3 live neigbours (one horizontally,vertically and diagonally each), so it should be alive in the output, but it’s not. Can someone please explain?
The middle two rows in your output are the ones that correspond to the two rows in your input. The upper left cell in the input corresponds to the second row extreme left in the output, and as you can see, it’s alive.