DEV Community

Cover image for I rebuilt Alan Turing's Bombe as a game where code-breaking turns dark to light
chintanonweb
chintanonweb Subscriber

Posted on

I rebuilt Alan Turing's Bombe as a game where code-breaking turns dark to light

June Solstice Game Jam Submission

This is a submission for the June Solstice Game Jam

What I Built

The Longest Day is a code-breaking game for the longest day of the year — and an ode to Alan Turing.

You play a cryptanalyst working a single solstice day, from dawn to the long midsummer midnight. Intercepted messages arrive as cold, dim letters against the dark. You decrypt them by hand — and the instant a key falls into place, the message warms from blue to gold and the whole scene fills with light. Decryption is illumination. That one idea ties the jam's themes together: light and darkness, and the passage of a single, lengthening day.

It's built around the theme on three levels at once:

  • Light and darkness — you literally turn dark into light by solving each cipher.
  • The passage of time — the sun arcs across the sky as your clock; the palette shifts dawn → noon → dusk → night as you progress.
  • An ode to Turing — every cipher is real, the finale faithfully recreates Turing's Bombe, and the story honours the man himself. June is his birth month; the jam is held during Pride; and his story is inseparable from light and dark.

Video Demo

Code

🌅 The Longest Day

A code-breaking game for the longest day of the year. An ode to Alan Turing.

A submission for the DEV June Solstice Game Jam — prize category: Best Ode to Alan Turing.

You play a cryptanalyst working a single solstice day, from dawn to the long midsummer midnight. Intercepted signals arrive as pulses of light. You decrypt them by hand — and as each correct key falls into place, the dark message warms into gold. The day is a ladder through the real history of cryptanalysis, ending at the machine Turing built to win the war: the Bombe.

Play

npm install
npm run dev      # play locally
npm test         # run the cryptanalysis + UI test suite
npm run build    # production build (dist/)
Enter fullscreen mode Exit fullscreen mode

The day, hour by hour

Time Cipher What you learn
Dawn Caesar shift Turn a dial to undo a uniform shift.

How I Built It

No framework, no API keys — vanilla JS, an HTML5 Canvas for the atmosphere, and Vite. I wanted the repo to be clean enough to read top-to-bottom, and the game to run anywhere from a single static build.

The architecture is split by responsibility, and the hard part is tested.

  • cipher/ holds pure, unit-tested implementations of each cipher: Caesar, substitution (with frequency analysis), Vigenère, a simplified rotor machine (mini-Enigma), and the Bombe logic.
  • engine/ is a tiny event-driven state machine: level progression, the day-clock, save/resume.
  • render/ draws the canvas atmosphere — a gradient sky, a sun riding an arc, a star field that emerges at dusk, and a prism that splits light into a spectrum at the end.
  • ui/ is the interactive workbench: a rotary dial, a frequency histogram, rotor wheels, the Bombe lattice, and the message display that lights letter by letter.

The day is a history of cryptanalysis. Each level steps forward in time:

  1. Dawn — Caesar. A dial undoes a uniform shift. It teaches the core feel: get it right, and the message blooms.
  2. Morning — Substitution. Every letter wears a mask. You break it with frequency analysis — the game shows how often each cipher letter appears against typical English, and you map the tallest bars (E, T, A, O…) until words resolve.
  3. Midday — Rotor machine. A new alphabet for every letter. Unreadable by hand — but you're given a crib, a word you know must appear, and you set the rotors until it surfaces.
  4. Dusk — The Light Bombe. The finale, and the part I'm proudest of.

Recreating the Bombe. Turing's Bombe didn't find the Enigma key by trying to be right; it found it by ruling out everything that was wrong. I rebuilt that idea honestly:

  • An Enigma reflector means no letter can ever encrypt to itself. So if you place a crib against the ciphertext and any crib letter sits above its own twin, that placement is impossible — a "clash." In the game you slide the crib until there are no clashes. (This is a real technique the codebreakers used.)
  • Then you run the Bombe: it sweeps all 676 rotor start positions, and every setting that contradicts the crib flares red and dies. The single consistent setting survives, glowing white. You click it, and the final message dawns.

One nice problem I had to solve: with my finale message there are 27 clash-free crib placements but only one actually yields a consistent rotor setting — so a naïve player could face 27 full Bombe runs. Rather than hand them the answer, I made a failed run report whether the true placement lies earlier or later. That turns a blind linear search into a quick binary search — which felt fitting for a game about Turing.

Testing. The cryptography was built test-first (31 tests in total): encrypt/decrypt round-trips, the rotor machine's self-reciprocity and its no-fixed-point reflector, the Bombe's contradiction elimination and clash rule, the engine's progression to completion, and DOM integration tests that solve each level through real user interaction and assert the message lights up.

The ending. When the last cipher breaks, the longest day tips into the shortest night, and the game closes quietly on Turing himself — the dawn he helped win for the world, and the darkness that later took him, persecuted for being gay. The final image is light refracting through a prism. The solstice always turns; the light comes back.

Prize Category

Best Ode to Alan Turing. The game is a tribute to Turing through its mechanics, its narrative, and its design:

  • Mechanics — real ciphers, culminating in a faithful, playable recreation of his Bombe: the crib, the no-self-encryption rule, and deduction by elimination of contradictions.
  • Narrative — his story is woven through the light: code-breaking in secrecy, the dawn he won, and the injustice that followed. Held with dignity, never sensationalised.
  • Design — set on the solstice in his birth month, during Pride, with light and darkness as both the puzzle and the metaphor.

Images

Thanks for playing.

Top comments (0)