An implementation of Conway's Game of Life in C++ and CUDA for the terminal and SDL Graphics.
Some things are easy to configure.
There are five color stages for cells: alive, dead, and three dying stages in between. They're configured in colours.h. By default, the CPU and CUDA versions have some clever colours.
Additionally, by default the original rules from Conway's Game of Life are used, and they're configured in rules.h, which is used by all versions.
Install the following dependencies:
- g++ or clang++.
- Prepend
CXX=<compiler>to your make command to specify.
- Prepend
- nvcc (CUDA only)
- Make sure the
$PATHis set correctly to find the CUDA libraries and thenvccbinary.
- Make sure the
- sdl2 and sdl2-image (optional)
And run Make rule for the desired version.
make gol-cpu
make gol-cuda
# If you do not have sdl2/sdl2-image
make gol-cpu-term
make gol-cuda-termgol-<version> <graphics-cell-size> <height> <width> <transitions> <period> [<fill>]Where:
graphic-cell-sizeis a non-negative integer to indicate the width and height of each cell in SDL graphics.- Use
0for terminal mode. (Required for*-termversions.)
- Use
heightis the number of rows in the field.widthis the number of columns in the field.transitionsis the number of transitions/cycles/iterations of the Game of Life.- Use
-1for infinite transitions.
- Use
periodis the number of milliseconds between transitions.fillis the percentage of the field that is filled at the start. This is a probabilistic randomized initiation.- Use a value between
[0-100].
- Use a value between
- In the terminal, issue
Ctrl-Cto interrupt and quit. - If in graphics mode, pressing
qor closing the window as normal (i.e. click red x) will also work.
- fsan/cuda_on_sdl for guidance on SDL graphics and CUDA rendering.