User:Pluke/gameoflife

CC3.0 from: http://community.computingatschool.org.uk/resources/281#likes

Conway’s Game of Life
Conway was a Computer Scientist in the 1970s, he was interested in simulating life of simple bacteria colonies. The "game" has no players, its evolution is determined by its initial state. You setup an initial configuration, or seed, and watch it evolve. In order to write the Game of Life, you need to do the following:
 * 1) Define a large 2D array, in which your individual cells will be either alive or dead.  This is their world.
 * 2) Populate a few small areas with small groups of cells, initially statically.  This is your seed, different seeds have different effects.
 * 3) Write a subroutine that looks at each cell in the world and determines whether or not that particular cell will be alive or not using the following rules:
 * 4) Any live cell with fewer than two live neighbours dies, loneliness.
 * 5) Any live cell with two or three live neighbours lives on to the next generation.
 * 6) Any live cell with more than three live neighbours dies, overcrowding.
 * 7) Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

The tricky bit comes when you have to look at each cell in turn and then look at each of its neighbours. That is fine for cells in the middle of the world, however you must cope with the edges too. HINT: ignore elements that would be outside your world. In the diagram below, we are looking at the centre cell, it’s not on any edge. It has 3 live neighbours. So it becomes live ( even if it was empty before, or not ). HINT: You will need a separate temporary array to place your newly calculated values in…


 * 1) There should be a user-defined limit to the number of times the simulation goes around.
 * 2) The user will want to see how many times the simulation has been run, and the total number of living cells.
 * 3) Try a selection of seeds and see what happens.  For example:

EXTENSION

 * 1) Automatically generate random seeds.
 * 2) Can you find any stable seed patterns?
 * 3) Can you find any oscillating seed patterns?
 * 4) Can you alter the rules to get a life-like growth that doesn’t just die?  Hint try using another birth from more neighbours.