A parallel Conway's Game of Life in Zig 0.16 and raylib 6.0 (via raylib-zig).
The simulation runs on a CPU grid (default 100×100, one cell per pixel) and is upscaled to the window. Each worker thread owns a horizontal band of rows and paints its live cells a unique color. Edges wrap (toroidal topology). The framebuffer is overwritten from game state each generation — deaths are cleaned up by B3/S23, not by clearing the image.
zig build runOptional flags:
zig build run -- --grid 1024 --threads 8 --pattern gosper| Flag | Meaning |
|---|---|
--grid N |
Square grid size (default 100) |
--threads N |
Worker bands (default: CPU count, clamped for visibility) |
--pattern NAME |
Starting organism (showcase, glider, gosper, …) |
zig build test| Input | Action |
|---|---|
| Space | Pause / resume |
. |
Step one generation while paused |
[ / ] |
Slower / faster (delay between generations) |
1–9, 0 |
Load a pattern |
R |
Reset the current pattern |
H |
Toggle 100×100 and 1024×1024 |
| WASD / arrows | Pan |
| Mouse drag | Pan |
| Mouse wheel | Zoom toward cursor |
The HUD reports generation, predicted fate (still life or oscillator period ≤ 60), grid size, thread count, delay, and pattern name.
Each organism is a function that returns live-cell coordinates, stamped with wrap-around.
| Key | Pattern |
|---|---|
1 |
Showcase — gliders, spaceships, a block, a blinker |
2 |
Oscillators and still lifes |
3 |
Glider |
4 |
LWSS / MWSS / HWSS |
5 |
Gosper glider gun |
6 |
Pulsar |
7 |
R-pentomino |
8 |
Switch engine (100²) or puffer 1 (1024²) |
9 |
Acorn |
0 |
Gosper gun + eater (glider stream absorbed) |
Sources: Conway's Game of Life and LifeWiki.
src/world.zig— toroidal B3/S23, double buffer,std.Io.Grouprow bandssrc/patterns.zig— one organism per functionsrc/render.zig— 1:1 framebuffer, per-thread colors, texture blitsrc/predict.zig— hash-ring cycle detectorsrc/main.zig— window, camera, speed, pattern keys