Visualizations
142 / 500

142 · Retro

Turing Machine

A brass Turing machine runs busy beavers, including all 47 million steps of BB(5).

A read/write head with a rolling state drum sits over a paper tape. Each step it reads the symbol under its lens, looks up the transition table, stamps a new symbol, slides the tape one cell and turns the drum. The shelf holds the 2, 3, 4 and 5-state busy beaver champions, a binary counter and a palindrome checker. The 5-state champion, proved optimal in 2024, really runs all 47,176,870 steps here, its rate ramping up to hundreds of thousands of steps per frame in a tight typed-array loop until it halts with 4,098 ones. Below, a space-time diagram lays each tape state out as a column with the head's path traced in its state colors; long runs keep at most 1,024 columns by dropping every other one and doubling the sampling interval.

Try it. Pick a machine from the shelf (or press 1 to 6), and click any part of a transition cell to change what it writes, which way it moves or which state comes next. Step with the button, the right arrow or a click on the bench. Space runs or pauses, plus and minus change speed, R resets and X builds a random machine.

  • Turing machine simulation
  • Space-time diagrams
  • Adaptive history sampling
  • Gradient-shaded brass

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 an animated Turing machine 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, stays sharp on high-DPI screens (scale by devicePixelRatio), and resizes with the window.
- Represent the machine as data: a tape (an array that can grow in both directions, or a big array starting in the middle), a head position, a current state, and a transition table that maps (state, symbol read) to (symbol to write, move left or right, next state). One next state is HALT.
- Load the 4-state busy beaver: A: 0 to 1RB, 1 to 1LB; B: 0 to 1LA, 1 to 0LC; C: 0 to 1RH (halt), 1 to 1LD; D: 0 to 1RD, 1 to 0RA. On a blank tape it should halt after 107 steps with 13 ones.
- Draw the tape as a horizontal strip of cells across the middle of the screen, with the head as a marker over the current cell showing the state letter. Keep the head centered and scroll the tape under it.
- Step a few times per second with requestAnimationFrame, and show the step count and number of ones. Stop with a clear HALT label.
- Draw the transition table and highlight the rule that just fired.

Once that works, make it beautiful:
- Animate each step in phases: the head stamps the new symbol, then the tape slides smoothly one cell.
- Add a space-time diagram below: one row per step showing the whole tape, with the head's position marked, so its zigzag becomes a picture.
- Style it like a physical machine: a paper tape with sprocket holes, a brass head drawn with gradients, and a state drum that rolls to the next letter.

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 running the 5-state champion's 47 million steps in a fast loop, clicking the table to edit rules, or a palindrome checker with more symbols.
PreviousPool Trick ShotsBilliards with real spin physics and an AI that plans by simulating every shot. NextLagrange LandscapeThe restricted three-body problem as a plaster relief, Trojans looping on its summits.

Related visualizations

  • Rotor Cipher MachineRetro A brass and walnut rotor machine whose current you can follow through every wire.
  • Difference EngineRetro Brass figure wheels tabulate a polynomial with nothing but addition and rippling carries.
  • Breadboard CPURetro A microcoded 8-bit breadboard computer paints cellular automata on a 16x16 LED matrix.
  • CPU PipelineRetro A five-stage RISC pipeline as an isometric factory: bubbles, bypasses and flushes.
  • Marble ComputerPhysics A wooden pegboard computer where falling marbles count, add and multiply in binary.
  • Bytebeat MachineSound Whole songs from one line of bit arithmetic, drawn as a tapestry of bytes.
  • Tiny CompilerAlgorithms A whole compiler, from source to running bytecode, rebuilt on every keystroke.
  • Tide MachineMath A brass Kelvin tide predictor sums ten cosines with one wire and a pen.
  • Self-Replicating LoopsEmergence Langton's 1984 loops copy their own genome and tile the plane with a glass colony.

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

← More from Emergent Mind Labs