In this project, we will implement Conways's Game of Life, and attempt to make the implementation as fast as possible
The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves. (Source: Wikipedia)
The universe of the Game of Life is an infinite, two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead. Every cell interacts with its eight neighbors, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
• Any live cell with two or three live neighbors survives.
• Any dead cell with three live neighbors becomes a live cell.
• All other live cells die in the next generation. Similarly, all other dead cells stay dead. (Source: Wikipedia)
To make the program just run the Makefile
$ make
Usage:
$ ./life <map> <iterations>
e.g.
$ ./life states/tests/diehard 1000
the last locations of the cells after 1000 iterations will be printed out.
Our biggest optimization was to stop the iteration if there is a circular pattern in our world. There is for example a pattern called Blinkers with just two different states. Decent ammount of maps eventually arive to this point after a while. We use bitwise operations to check that. Turning on specific bits will check if the cell is alive or dead and what was the previous state of the cell. We also use it to predict the upcoming state of the cell when we check the neighbours of the cells. (look at the file game_of_life/sources/iterate_opti.c that file and game_of_life/sources/game_of_life.c run our game of life world) The file game_of_life/sources/iterate_slow.c does not have aforementioned optimizations, but it will be faster on maps that do not reach blinking stage. To compile, use:
$ make
Usage:
$ ./life_opti <map> <iterations>
Usage:
$ ./life_gi states/tests/diehard
'r' = reset
'esc' = exit
'space' = pause
(you can draw with the mouse on the maps!)
Usage:
$ ./life_gi states/big_map
Usage:
$ ./life_gi states/tests/dinnertable
Usage:
$ ./life_gi states/fullscreen.txt
Pulsar
Penta-decathlon
Glider
Light-weight spaceship
Heavy-weight spaceship








