Skip to content

About

My own "Game of Life". Created using Zig 0.16 and Raylib 0.6

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conway's Game of Life

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.

Requirements

Build and run

zig build run

Optional 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

Controls

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.

Patterns

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.

Layout

  • src/world.zig — toroidal B3/S23, double buffer, std.Io.Group row bands
  • src/patterns.zig — one organism per function
  • src/render.zig — 1:1 framebuffer, per-thread colors, texture blit
  • src/predict.zig — hash-ring cycle detector
  • src/main.zig — window, camera, speed, pattern keys

About

My own "Game of Life". Created using Zig 0.16 and Raylib 0.6

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages