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).
Block | Blinker (period 2) | Glider | |||
Bee-hive | Toad (period 2) | Light-weight spaceship (LWSS) | |||
Loaf | Beacon (period 2) | Middle-weight spaceship (MWSS) | |||
Boat | Pulsar (period 3) | Heavy-weight spaceship (HWSS) | |||
Tub | Penta-decathlon (Period 15) |
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.