← Blog

Midnight Machine — I Gave the British a Brain

My third and final entry for Built on Yesterday, the last week of Summer into AI. The first two times, "yesterday" was my own work. This time I built on someone else's — the way the theme is really asking. A few weeks back Adam shipped Ride, Revere, Ride!, a tight little Paul Revere arcade game: gallop a four-lane road, throw broadsides at houses to warn them, dodge redcoats until dawn. He kept it pure arcade — the redcoats spawn at random. That's the thread I couldn't stop pulling. What if they didn't?

The MIDNIGHT MACHINE poster intro — a gold-and-red arcade title over the line "Paul Revere's midnight ride, except the British aren't scripted. They run a learning model."

What it is

Midnight Machine is Adam's ride with the one thing arcade games never have: an enemy that learns you. Behind it sits a little learning model I wrote from scratch — no libraries, no AI API, just math in one file. Four times a second it notes which lane you're in and how you move between them, building a picture of your habits. Then every redcoat that spawns doesn't roll dice — it predicts where you're about to be and appears there. The longer you ride, the better it reads you. Warn every town, dodge the redcoats, beat the dawn.

How it’s built

  • The part I'm happiest with is that you can watch it think. Bottom-right is a panel called the Crown's Mind — four bars that are its live guess of your next lane, plus a running tally of how often it's caught you. When you keep getting boxed into the same lane, that panel is why.
  • A claim like "it's really learning" is worth nothing unless you can check it, so there's a Freeze the Crown button: hit it and the model switches off, the redcoats go back to Adam's original blind random spawns, the bars go dark and the read-rate reads BLIND. Play thirty seconds each way and you feel the difference.
  • I ran it headless a few thousand times against a "habitual" rider with lane preferences. Blind, the Crown catches that rider about 25% of the time — exactly what random guessing over four lanes gets you. With its brain on, it climbs to ~41%, on every seed I tried. But the part I didn't plan and like most: it only works on patterns. Throw a perfectly unpredictable rider at it and its read-rate collapses to nothing. The game quietly teaches something true — the way to beat a machine studying you is to stop being predictable. That fell out of the math; I didn't design it in.
  • Two last touches make it feel like a real cartridge. When you die, the end screen shows what the Crown actually learned about you — your favourite lane, which way you bolt, how often you freeze — reconstructed straight from its transition counts, so the model's read of you doesn't vanish with the run. And it's all wired for sound (procedural Web Audio, no files: gallop hoofbeats, a chime when a town wakes, a swell at dawn) with last-frame near-miss slow-mo for the juice.
The moonlit four-lane road: Paul Revere on horseback with a glowing lantern, redcoats staggered across the lanes, one town warned with its window aglow, and the Crown's Mind panel bottom-right showing its live lane prediction.
The Crown's Mind panel (bottom-right) is the model's live guess of your next lane, plus its running read-rate. Those redcoats aren't random — they're placed where it thinks you'll be.
The same scene with the Crown's Mind panel turned red, reading "BLIND" and "CROWN FROZEN — riding blind".
Freeze the Crown and the model switches off — the redcoats go back to spawning blind. The toggle that proves the intelligence is real, not scripted.
The game-over screen reading CAUGHT, with a panel titled "What the Crown learned about you": you lived in lane 3, you bolted LEFT 50% of the time, you held your lane 33% — that's the habit it read.
When you die, the model tells you what it learned: your favourite lane, your dodge-direction bias, how often you held still — reconstructed from its real transition counts.

On the theme

Built on yesterday, literally: Adam's game with one idea bolted on that he'd deliberately left off. I kept his whole feel — the four lanes, the broadsides, the dash for dawn — because it was already good, and rebuilt it as my own single file so I could open up the guts and put a mind inside the enemy. The best kind of "build on yesterday" isn't fixing someone's work; it's finding the one door they left closed and seeing what's behind it.

Try it →Code →All the builds →

Shout-out

Part of the competition is cross-referencing other builders. So: shout-out to Adam — whose Ride, Revere, Ride! is the whole foundation here. His is the charming, complete arcade ride; I just found the one door he left closed — what if the redcoats learned you — and walked through it. Play his first. Thanks for the ride, Adam.

Built for Summer Into AI 2026 (Competition #2), hosted by Eric Rhea. More in the build log.