C.Coleman-Smith (chris.colemansmith@gmail.com)
Exploring Conway's game of life, curses and maybe some real graphics.
Copied from the Wikipedia article 1, charmingly this is described as a single player game.
Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
- 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 overcrowding.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
To avoid decisions and branches in the counting loop, the rules can be rearranged from an egocentric approach of the inner field regarding its neighbors to a scientific observers point: if the sum of all nine fields is 3, the inner field state for the next generation will be life (no matter of its previous contents); if the all-field sum is 4, the inner field retains its current state and every other sum sets the inner field to death.
This project uses CMAKE to generate Makefiles and run tests, it is canonical to do out of place builds using cmake. An "out of place" builds puts all the temporary files and compiler junk into a directory that is outside the source tree.
From the project root do:
mkdir ./build
cd ./build
cmake ..
make && make install
Cmake defaults to installing things in /usr/local, if you don't want that you should set invoke cmake as
cmake -DCMAKE_INSTALL_PREFIX:PATH=/your/install/path ..
Check backed unit tests can also be built by enabling the BUILD_TESTING
cmake option, from the build directory
cmake -DBUILD_TESTING=on ..
The tests can be run from the make test
target or by directly invoking ctest
.
- Tests!
- Make game board size dynamic
- Separate the game logic and lifecycle from the main loop of the program
- Use curses for drawing a viewport into the game world that fills the terminal (http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/)
- Allow some user navigation and interaction with the world
- Try smooth life: http://arxiv.org/abs/1111.1567