Game of Life

Conway's Game of Life built as something you play rather than something you watch. A puzzle mode with goals and a countdown, a creative sandbox for the classic patterns, and a randomiser, written in C++ with SFML and TGUI.

Title screen, with a live 50 × 50 simulation running behind the menu.
Title screen, with a live 50 × 50 simulation running behind the menu.
Level 1 before the run: ten cells placed against the goal and the timer.
Level 1 before the run: ten cells placed against the goal and the timer.
Mid-run: 28 alive at 7.2 seconds, a symmetric pattern emerging.
Mid-run: 28 alive at 7.2 seconds, a symmetric pattern emerging.
After ten seconds: a stable forty-cell field of blocks and beehives, level cleared.
After ten seconds: a stable forty-cell field of blocks and beehives, level cleared.
Creative mode with the classic patterns placed: glider, blinker, toad, beacon, block.
Creative mode with the classic patterns placed: glider, blinker, toad, beacon, block.
The same board nineteen generations later: the glider has travelled diagonally, the oscillators still cycling.
The same board nineteen generations later: the glider has travelled diagonally, the oscillators still cycling.
Randomize mode: a random board before starting.
Randomize mode: a random board before starting.
One second later, settled to 63 cells with still lifes and oscillators formed.
One second later, settled to 63 cells with still lifes and oscillators formed.
How the pieces fit together: the architecture behind the game.
How the pieces fit together: the architecture behind the game.
The update step: each cell's eight neighbours evaluated into a new buffer.
The update step: each cell's eight neighbours evaluated into a new buffer.

Turning a simulation into a game

Life is usually a toy you start and stare at. The interesting move was giving it a win condition: Levels mode asks you to place a fixed number of cells so that a target number are still alive when a countdown ends. That turns an automaton into a puzzle, because you have to reason forward about what a seed will grow into.

Three ways in

Levels is the puzzle. Creative is a sandbox for placing the classic patterns (glider, blinker, toad, beacon, block) and watching each behave. Randomize fills the board and lets it settle, which is the fastest way to see still lifes and oscillators emerge out of noise. The title screen runs a live 50 × 50 simulation behind the menu.

Under it

A fixed-timestep frame loop drives the grid so simulation speed stays independent of frame rate, with SFML 3.1 handling rendering and TGUI 1.9 the interface. The update step evaluates each cell's eight neighbours into a new buffer rather than mutating in place, which is the difference between Life and something that merely looks like it.

Highlights

The Level 1 seed shown here was found by a small search script to guarantee a clear, not designed by hand.

More Development