A clone of John Conway's Game of life written in C and powered by SDL 2.
The Game of Life is a cellular automaton created by John Conway (rest in peace) that was created with a goal of demonstrating the possibility of emergent behavior with four simple rules:
- Any live cell with fewer than two live neighbours dies, as if by underpopulation.
- 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 overpopulation.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
Unlike the original, this clone of Game of Life does not actually house an infinite universe. Instead, it runs on a configurable grid. For more details on configuration, check the Configuration section.
- SDL 2
- SDL 2 - TTF
- make
- cmake
- gcc
I you are running a Linux distribution that uses apt
as it's package manager, you should be able to obtain
all the required dependencies by running the following command:
sudo apt install libsdl2-ttf-2.0-0 libsdl2-dev libsdl2-ttf-2.0-0 libsdl2-ttf-dev make cmake gcc
If you are on some other distribution, you are probably experienced enough to find your own way of obtaining the dependencies. If not, do a few searches, it won't hurt.
In order to compile the program, make sure you satisfy all the development dependencies and follow these steps:
git clone https://github.com/DigitalCyan/game-of-life --recurse-submodules
cd game-of-life
cmake -S . -B build && make --directory=build && cp -vr assets/ build/
The last line builds the program and copies the assets
folder from the project root to the build folder. It's
important to keep the assets
folder next to the compiled binary so the binary can access it.
The program can be configured by editing config.h
pre-compilation. Feel free to update these fields as you please (just don't touch the computed ones unless you know what you're doing).
#define WORLD_EDGE_SIZE 64
#define CELL_SIZE 16
#define THINK_DELAY 50