Colossus
Colossus is the world's first programmable electronic digital computer, and this is an original, from-scratch simulation of it in the browser. Built by Tommy Flowers at the Post Office Research Station and operated at Bletchley Park, it broke the German Lorenz ("Tunny") cipher — not by decrypting directly, but by counting Bill Tutte's double-delta coincidences off a ciphertext paper-tape loop until the correct chi-wheel setting made the count climb far above the mean. It is a special-purpose machine with no memory of instructions: its "program" is set on switches and a plug panel. Because there is no processor and no stored program, in place of a CPU debugger it exposes the wheels, the counter and the found setting as machine state.
Runs on: Web browser
Colossus Online Emulator
Play Colossus using JavaScript directly in your browser.
Controls
Configurations
| Configuration | Emulator | Machine | OS | Legal | |
|---|---|---|---|---|---|
| Wheel-setting run — the setting revealed | Colossus | Colossus | open | Open ⛶ | |
| Sweep the settings — hunt the peak | Colossus | Colossus | open | Open ⛶ |
Notes
Embedding
Colossus is modelled from scratch in plain JavaScript. There is no CPU and no stored program — the "program" is the wheel start positions plus the Boolean function on the switches. An authored sample message is enciphered with the real SZ40 algorithm to make a ciphertext tape; Colossus then counts double-delta coincidences to recover the chi-wheel setting. Change a wheel pattern or the key in colossus.js and the break follows.
The tape loop is the input. Each single-step reads one ciphertext character; a full pass of the loop scores one trial setting. The host owns the "loop": the run / step controls call mach.step() (advance one character) and the switches call mach.setSetting() / mach.setPair().
var mach = new Colossus();
mach.setSetting(12, 3); // trial start of the chi pair under test
mach.step(); // read one tape char; count a "dot" if the double delta is 0
var st = mach.state(); // tape pos, counter, the found peak, solved?
| Member | Kind | What it does |
|---|---|---|
mach.cipher / mach.N | field | The ciphertext tape (loop of five-channel characters) and its length. |
mach.chiPat / psiPat / m61Pat / m37Pat | field | The twelve Lorenz wheel cam patterns (chi 41/31/29/26/23, psi 43/47/51/53/59, motor 61/37). |
mach.step() | method | Read one tape character at the current setting; count a dot when the double delta is a "dot" (0). |
mach.setSetting(s1,s2) | method | Set the trial start of the two chi wheels under test (the switches). |
mach.setPair(i) | method | Choose the Q-panel Boolean function (which channel pair to count); re-sweeps the landscape. |
mach.state() | method | Live read-out: tape position, counter, mean, the found peak setting + deviation, and whether it matches the key. |
mach.decodeMessage() | method | Decipher the whole tape with all twelve wheels set — the plain message. |
Debugger integration
colossus-debug.js reads window.EMU_BOOT and hands the shared debugger a machine whose "CPU" is the electronic counting logic. Every debugger feature maps onto the machine.
- Registers = live machine state. The two trial
χ STARTswitches and theTAPEposition (all settable — type a value and the run jumps to it), then the read-onlyCOUNT/PROJ/MEANcounters and the foundPEAK.χsetting,DEVandSOLVED, grouped as switches / counter / found. - Single-step = one tape character. The Step control calls
transport.stepInsn, which reads one character and updates the ring counter; Run/pause free-runs the tape. - Breakpoints & watchpoints. Execution breakpoints match the tape character position as the loop runs; watchpoints fire when a watched position is reached — real checks in the tape loop, not stubs.
- Disassembly = the wheels. A new
colossusdecoder (debugger/src/cpus/colossus.js) renders one row per Lorenz wheel — name, pin count, start, current cam bit — then the Q logic and the counter, so the "code" window literally lists the machine and updates as the tape runs. - Memory. Two chips: the wheel/logic list (colossus-disasm) and the five channel bits of the ciphertext character under the reading head (hex/bits), read side-effect-free.
- Controls. The Controls window carries Run / Stop, single-Step, the chi-start jog switches, Jump-to-peak, a Q-logic selector and a reset — the same handlers the page keys and buttons use.
Architecture
Colossus (first working, December 1943; Mark 2 June 1944) was designed and built by Tommy Flowers and his team at the Post Office Research Station, Dollis Hill, and operated by the Newmanry at Bletchley Park. It was the world's first large-scale programmable electronic digital computer, using around 1,600 (Mk 1) to 2,400 (Mk 2) thermionic valves at a time when engineers doubted so many valves could run reliably — Flowers' insight was to leave them powered on continuously.
It is not a stored-program computer. Colossus was a special-purpose machine with no memory of instructions: its "program" was set on switches, a plug panel (the Q-panel / K rack) and the choice of which counters to gate. It could not be told to do arbitrary computation — it did one thing, extremely fast: read a paper-tape loop and count Boolean coincidences. (The stored-program idea came later, with the Manchester Baby, 1948.)
The target: the Lorenz SZ40/42 ("Tunny"). Lorenz was a 12-wheel online teleprinter cipher attached to Hitler's high command links, far more complex than Enigma. Each 5-bit teleprinter character was enciphered by XOR with a key stream made of five chi (χ) wheels (41, 31, 29, 26, 23 pins) that step every character, five psi (ψ) wheels (43, 47, 51, 53, 59) that step only sometimes, and two motor (μ) wheels (61, 37) that control the psi stepping — 501 pins in all.
How the break works (Bill Tutte's double delta). Because the psi wheels often do not move, the difference between successive key characters is dominated by the chi wheels. Colossus forms the "double delta" of two channels — Δ(Zi) ⊕ Δ(Zj) ⊕ Δ(χi) ⊕ Δ(χj) — for a trial chi-wheel start, and counts how often it is a dot (0) across the whole tape. At the correct setting the count deviates sharply from half the tape length; at wrong settings it hovers near the mean. The operator selected the most-biased channel combination (the famous "1 + 2 break-in", or here χ2 + χ3) on the switches, and the machine swept the chi-wheel start positions, printing the counts. This model authors a CC0 sample message, enciphers it, and reproduces exactly that run: the counter climbs to a clear peak and the chi setting is revealed; with every wheel then set, the tape deciphers back to the plain text.
Faithful vs modelled. The wheel pin counts, the SZ40 stepping (chi every character, psi gated by the μ37 basic motor, μ37 stepped by μ61) and the double-delta counting are modelled faithfully. The cam patterns, the wheel key and the message are authored (CC0) rather than a wartime intercept, and the tape runs at animation speed rather than the real 5,000 characters a second. Ten Colossi were built; all but two were destroyed after the war and the work stayed secret until the 1970s, which is why Flowers received little recognition in his lifetime.