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
$PATH
is set correctly to find the CUDA libraries and thenvcc
binary.
- 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-term
gol-<version> <graphics-cell-size> <height> <width> <transitions> <period> [<fill>]
Where:
graphic-cell-size
is a non-negative integer to indicate the width and height of each cell in SDL graphics.- Use
0
for terminal mode. (Required for*-term
versions.)
- Use
height
is the number of rows in the field.width
is the number of columns in the field.transitions
is the number of transitions/cycles/iterations of the Game of Life.- Use
-1
for infinite transitions.
- Use
period
is the number of milliseconds between transitions.fill
is 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-C
to interrupt and quit. - If in graphics mode, pressing
q
or 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.