Level: Medium project
GitHub Repository: https://github.com/JaumeAlbardaner/gameOfLife
Mark: B (8.5 out of 10)


What is "Game of Life"?

John Conway's Game of Life is a "cellular automaton". Given 4 initial rules, the game portrays the evolution in time of how each cell is affected by the rules.


Rules:

The rules that are to be followed by each cell are the following:

  • Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  • Any live cell with two or three live neighbours lives on to the next generation.
  • Any live cell with more than three live neighbours dies, as if by over-population.
  • Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

End scenarios:

In order to end the simulation, it must be detected whether there is a periodicity to the movement of the structures present in the board. Because of the rules specified previously, different stable structures can be generated. They are categorized into three main groups depending if they are static (still lifes), if they don't move but change pattern (oscillators), and the last ones are those that move (spaceships).

Still Lives
Oscillators
Spaceships
Block block gif Blinker (period 2) block gif Glider block gif
Bee-hive Beehive gif Toad (period 2) Toad gif Light-weight spaceship (LWSS) LWSS gif
Loaf Loaf gif Beacon (period 2) Beacon gif Middle-weight spaceship (MWSS) MWSS gif
Boat Boat gif Pulsar (period 3) Pulsar gif Heavy-weight spaceship (HWSS) HWSS gif
Tub Tub gif Penta-decathlon (Period 15) Penta-decathlon gif


Code

One of the important properties of the C code was that the arrays that act as a board were to be implemented using the malloc instructions without causing memory leaks. This was ensured by using the free command on each pointer to a memory location every time the array was not to be used anymore.


The instructions to run the different scenarios are described in the described Github repository.