Visualizations
185 / 500

185 · Emergence

Wireworld Circuits

A four-rule cellular automaton runs a six-bit counter and logic gates on a PCB.

Every cell is empty, copper, an electron head or a tail: heads become tails, tails become copper, and copper fires when one or two of its eight neighbours are heads. From that alone, a loop becomes a clock, a forked kink becomes a diode and a tiny ring becomes an XOR gate. The counter board chains six toggle stages, each storing its bit as an electron circling a 42-cell loop through an XOR, with the carry computed as (x OR s') XOR s' and every wire length tuned by simulation so electrons meet in the right generation. The gates board feeds clocks of period 20 and 30 into OR, XOR and AND-NOT with a logic analyzer, and the playground has diodes, a fan-out tree and room to solder.

Try it. Press Count +1 (or the red button on the board) to send one pulse, or Free run to pipeline them. Spark drops electrons on copper, Copper paints traces, Erase or right-drag removes them, and the wheel or a pinch zooms. Space pauses, N steps one generation, 1 to 3 switch boards.

  • Wireworld cellular automaton
  • Event-driven stepping
  • Afterglow light map

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a Wireworld cellular automaton playground with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a canvas that fills the window and stays sharp on high-DPI screens. Use a grid of about 120 x 75 cells stored in a Uint8Array, with four states: empty, copper (conductor), electron head and electron tail.
- Each generation, build a new grid from the old one: a head becomes a tail, a tail becomes copper, copper becomes a head if exactly one or two of its eight neighbours are heads, and empty stays empty. Run about 20 generations per second with requestAnimationFrame and an accumulator.
- Draw empty cells dark green, copper gold, heads bright cyan and tails orange.
- Let me paint copper by dragging, erase with right-drag, and click copper to drop an electron head there.
- Preload a few classic parts from ASCII strings: a clock (a small rectangular loop with one head and its tail), a diode, and a wire running from the clock through the diode.

Once that works, make it beautiful:
- Draw copper as connected traces (a line from each copper cell to its copper neighbours) instead of squares, on a printed-circuit-board background with silkscreen labels.
- Give electrons a glow: keep a fading heat value per cell, write it into a one-pixel-per-cell ImageData, and draw that scaled up with smoothing and additive blending.
- Add an XOR gate, then an OR gate made of two diodes, and a lamp that lights when a pulse reaches the end of a wire.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as a binary counter built from XOR loops, a logic analyzer that plots chosen cells over time, or only updating cells next to heads so huge circuits stay fast.
PreviousNormalizing FlowAn invertible network trains live and bends a Gaussian and its grid like taffy. NextAgate BandsLiesegang precipitation grows the concentric bands of a polished agate slab.

Related visualizations

  • Automaton OrchestraEmergence Elementary cellular automata woven into cloth on a loom and played as music.
  • Self-Replicating LoopsEmergence Langton's 1984 loops copy their own genome and tile the plane with a glass colony.
  • Breadboard CPURetro A microcoded 8-bit breadboard computer paints cellular automata on a 16x16 LED matrix.
  • PCB AnnealerAlgorithms Simulated annealing places chips on a circuit board, then a maze router lays copper.
  • Sorting NetworkAlgorithms A sorting network as a wooden marble run: brass gates swap marbles into order.
  • Circuit SimulatorPhysics A SPICE-style solver runs a live schematic: LEDs blink, capacitors charge, current flows.
  • CooperationEmergence A few defectors in a sea of cooperators unfold into an endless symmetric kaleidoscope.
  • Marble ComputerPhysics A wooden pegboard computer where falling marbles count, add and multiply in binary.
  • Lights Out AlgebraMath The toggle-tile puzzle solved instantly at any size by linear algebra over GF(2).

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs