Skip to content
← Projects

Game of Life

Conway's Game of Life in the browser. Infinite pan-and-zoom canvas grid, a library of classic patterns, and a couple of easter eggs.

next.jsreacttypescriptcanvastailwind#webapp#simulation

Web implementation of Conway's classic cellular automaton. The grid is not a fixed-size board, it is an infinite plane you navigate with pan and zoom. Rendering is done straight to <canvas> and only paints cells inside the camera, so the simulation stays smooth even with large active patterns.

Mechanics#

  1. Middle-click drag pans the camera. Mouse wheel zooms (between 0.5x and 5x). A button recenters the camera at the origin.

  2. Three speeds (slow 500ms, medium 100ms, fast 50ms). The stats panel shows generations and alive-cell count in real time.

Keyboard shortcuts: Space play/pause, C clear, R random.

Under the hood#

The grid is not a fixed matrix, it is a Map<string, boolean> keyed by "x,y". That makes it effectively infinite without paying memory for empty cells, and simplifies zoom and pan. Each tick walks only the live cells and their 8 neighbours to compute the next generation. The renderer applies a zoom + camera transform to the canvas 2D context and only fills the cells inside the visible rectangle.

The UI is built on Radix primitives (sliders, tooltips, popovers, dropdowns), Tailwind for styling and framer-motion for a couple of transitions. There is an easter egg tucked away in there. I'll let you find it.