Cave Story · Best Ending · tool-assisted speedrun

Cave Story in 49:57.16

The published record for Cave Story's Best Ending TAS, nitsuja's 2011 run, is 50:10.30. This run beats it by 657 frames, or 13.14 seconds, and as far as we know it's the first Best Ending TAS under 50 minutes. Nearly all of the searching was done in six days by AI agents and a pile of GPUs.

The whole run, all 49:57 from the title screen to the credits, with chapters. Captions (CC) give commentary on what's different from nitsuja's run, room by room. Also on YouTube.
49:57.160
this run (149,858 frames at 50 fps)
50:10.300
nitsuja's TASVideos publication 1917M (150,515 frames)
−657
frames: 65 rooms faster, 81 identical, 2 slower on purpose
129
successive records, each re-verified on the original game

Status: unofficial. Every record was checked frame for frame against the original Doukutsu.exe (Japanese freeware 1.0.0.6, the version nitsuja used). It also plays back in sync to the ending in Hourglass r77, the tool the published run was made with (149,858 frames, no desync warnings). It hasn't been submitted to TASVideos yet. The movie file, the data and the write-up are on GitHub.

New: Cave Story from scratch. A machine played the whole game to the Best Ending from a new game with no human inputs or routes, verified frame for frame on the original game.

Watch

Three of the biggest single-room gains, played from the new run with nitsuja's Quote racing alongside as a translucent ghost. The panel on the right keeps score. Sound on.

Graveyard (−261), Outer Wall (−33) and Ballos (−28), 1 min 24 s. Balfrog and the Core are in the evolution video below. Both runs are aligned at each room's entry, so the gap you see is the time saved in that room. Rendered from the run in the twin engine, with the game's own sound.

What this is

A tool-assisted speedrun (TAS) is a list of button presses, one entry per frame, built with savestates and search tools instead of human reflexes. Played back into the game, it beats the game as fast as the inputs allow. The goal here is Cave Story's Best Ending, the longest route: it rescues Curly, collects what the true ending needs, and clears Sacred Ground (the hell levels) and its final boss.

The bar was high. nitsuja's 2011 run is the TASVideos publication for this category and stood for 15 years. It already takes damage boosts, manipulates luck and kills bosses with frame-tight timing. Finding 657 frames in it meant shaving 1–30 frames off dozens of rooms, plus two big pieces: a route idea from periwinkle (below) and a way to drown faster in the Core.

The race, room by room

Both runs visit the same 148 rooms in the same order, so you can line them up door by door. This is how far ahead the new run is at each room entry. Hover or tap the chart for details.

frames ahead of nitsuja at each room entry
x: time into nitsuja's run (logic frames ÷ 50, so it omits the 24 s of music-change lag both runs share). The jump near minute 3 is the Graveyard: 261 frames in one room.

Whose inputs are these?

Not ours, mostly. Every frame below is colored by where its button presses came from. It's a bit like gene editing: the run is nitsuja's genome with one big graft and many small edits.

"From nitsuja" counts only stretches of 200+ frames identical to his movie. The new run is ahead of him from the Graveyard on, so those stretches sit at earlier frame numbers in the new run than in his. Gold covers re-solved segments, short splices and the edits that keep the luck in sync.

periwinkle, a Cave Story speedrunner, left a work-in-progress TAS on TASVideos in 2022. It reaches the first Egg Corridor and has one huge idea: in the Graveyard, take a hit from a Pignon (the mushroom enemy) at the right moment and the knockback launches Quote up the shaft. That room alone drops from 907 to 646 frames. The new run's first 10,470 frames (3½ minutes) are his inputs, unchanged.

The catch: nobody could attach his opening to nitsuja's run. Cave Story has a single random-number stream, and the Graveyard line draws 532 more random numbers than nitsuja's. Every enemy, drop and boss pattern after that comes out differently, and nitsuja's later inputs fall apart. Worse, under the new luck the Grasstown enemies left the Missile Launcher at level 2 instead of 3 for the Balfrog fight, which measured at roughly 700–845 frames slower. The bridge that finally worked is described under "Why you can't just cut a frame".

nitsuja's inputs make up most of the rest. Once the luck lines up again at a door, his movie can be replayed from that point, frame for frame, to the end of the game.

129 records in six days

The project started on October 15, 2026. The first record (3 frames) landed on the 16th, sub-50 on the 19th at 01:31 (US Eastern). Every dot is a record that played to the ending and matched the original game frame for frame.

The dashed line is 516 frames under nitsuja, the threshold for 49:59.98. Hover a dot for that record's commit message. Full list.

Here's the same story in motion. The newest record plays, and about 18 older records race through each room as ghosts, colored from oldest (blue) to newest (gold). Every gap between ghosts is frames someone found.

Evolution of the record, 4 min 34 s, record-597 with 17 older records as ghosts. Rooms: Graveyard, Santa's House (watch the 57-frame health refill come and go), Mimiga Village, Balfrog, the Core (4×, then real time at the end), Outer Wall, Plantation, the Hideout, the Undead Core and Ballos.

Every room, both runs

All 148 room visits, from the title screen to the ending. The bar is the whole run, one block per room: green rooms are faster (brighter is more), gray are identical, red are slower on purpose. Pick one to replay both runs in it, in sync, on the real map: blue is nitsuja, red is the new run. Underneath is a piano roll of the actual button presses, one column per frame. In the Graveyard (#16), blue takes the long loop to the right while red takes a Pignon hit and rides the knockback up the shaft.

Positions are Quote's, one point per frame (every 2nd or 3rd in long rooms), from the game's own state. The piano roll scrolls with the replay; the white line is now. "weapon" is the two weapon-switch keys.

Why you can't just cut a frame

Say you find a way through a room that's 2 frames faster. You can't just splice it in. Cave Story pulls its randomness from one generator, the C library's rand(): seed = seed × 214013 + 2531011. Many rooms draw from it every frame (Start Point's water drips take 2 per frame). Two fewer frames means 4 fewer draws. Every later random event shifts along the stream: which enemy drops a heart, where a boss jumps. The rest of nitsuja's inputs then play against a different world and die.

The key insight is about doors. When Quote enters a room, the game reloads all of its enemies from the map file. So at a door, the whole world reduces to three things: Quote, the carried state (HP, weapons, ammo, flags, two hidden animation and weapon timers), and the RNG seed. Match all three to nitsuja's at some door and his inputs replay from there, frame for frame. So the frames you saved are only banked once the run walks through a door in sync with his.

To get back in sync you burn random numbers. A head bonk on a ceiling spawns two little particles and costs exactly 4 draws. A Machine Gun shot costs 1, a splash 32–500. Or you skip draws: kill an enemy sooner, avoid triggering one, fire one fewer missile. Try it:

Toy room: 2 random draws per frame, an enemy dies at frame 300 and rolls a drop, the door is at frame 420

nitsuja
new line
A simplified model. The real generator, drop rule (Random(1,5): 1 = heart, 2 = missile, otherwise EXP) and +4 head bonk are the game's. Real rooms mix dozens of sources. Two frames saved plus one head bonk is the actual fix that worked in Mimiga Village.

That's how periwinkle's Graveyard finally joined nitsuja's run. A GPU luck search re-solved Grasstown so that the RNG at the door into Santa's House (room 41) matched nitsuja's exactly, and from there his inputs replay to the end. At first that needed a detour of nearly 60 frames to refill health at Santa's house. A later search found a line that picks up one more heart and skips the refill, worth 53 frames. The full-run records keep using this "converge at a door" trick: about 100 frames came from luck re-solves and burns.

The real thing: where the new run's luck sits, door by door

How many random numbers the new run has drawn, minus nitsuja's, at each room entry, recovered from the game's generator state frame by frame. Through periwinkle's opening it drifts by hundreds. At the door into Santa's House it lands on exactly 0, and nitsuja's inputs take over.

Drowning faster

After the Core boss, the story has Quote run out of air. So the run wants to drown as early as possible. The drown comes exactly 1,000 frames after Quote's last dive, plus 972 frames of scripts that freeze the game. Diving earlier means drowning earlier, as long as the boss is dead in time and Quote never surfaces in between.

The water isn't still. Its level is a little machine that ignores Quote: every frame, it accelerates 4/512 pixel per frame² toward its rest line. That makes a fixed oscillation of ±16 px with a 256-frame period, the same on every attempt. An agent built an exact model of it (0 mismatches over 1,366 frames) and planned the fight around the tide: dive while the floor is dry and only the pit is underwater, and keep enough missiles for the rest of the game. The first tide line dove 24 frames earlier. The second, a dive-first line, went 46 frames earlier. After paying for the luck repairs, they banked 24 and 16 frames, and the first one took the run under 50:00.

Reconstructed from the rule above with the phase matched to the record. Green bands: the arena floor is dry, so Quote has to be in the pit to stay under. The flood after frame 1,000 is drawn approximately.

Watch it in the evolution video: the Core plays at 4× with every record's ghost, so you can see each new line dive and drown sooner.

Where the 657 frames came from

Summed over all 129 records' own deltas (frames vs the previous record), so a room re-solved several times counts each improvement. "esc" is the enemy-aware GPU shortcut search; "re-sweeps" re-run it on rooms a new record changed.

How it was found

The short version (the long one is on How it works):

From the lab

Clips recorded during the hunt for tricks and glitches. Most of them didn't make it into the run, which is the point: this is what "everything was tried" looks like. Clips marked cheat edit the game state to show what would happen. They aren't legal in the run.

The last mile

Once the big ideas were banked, the record moved a frame or two at a time. Three things kept it moving.

One night the home internet went out. The laptop moved to a phone hotspot, the cloud GPUs kept searching, and the laptop itself became the original-exe checker (a 15-minute Wine replay instead of the usual 3). Nine records were banked before the internet came back.

Checked, measured, dead

Ideas that sound like they should work, and the reason each one doesn't. Every verdict here comes from a measurement, not a hunch.

How much is left?

Probably half a second to two seconds on this route, spread thin. One agent hunted for route-level skips worth hundreds or thousands of frames (sequence breaks, death and reset tricks, a developer warp in Hell, wall clips, knockback launches like the Graveyard's) and found every one blocked for a structural reason, not a search-effort one. Splitting the run's time three ways:

That puts this route's floor somewhere around 49:55 to 49:57. Some of the run is proven optimal outright: an exact GPU breadth-first search shows nitsuja's own inputs can't be beaten on 153 short segments (280 with one extra assumption about pushing into corners). But proofs cover only about a tenth of the time Quote is under control, so "solved" here means "close to the limit", not "proven".

The search is paused, not finished: records were still arriving about once an hour when we stopped. Every search's state, coverage and best open leads are written down, so it can pick up where it left off.

By the numbers

Commits per hour, October 15–19 (green ticks: new records)

Every commit to the working repo, by the hour. The searches and the agents ran around the clock.

Cloud GPUs running, by the hour (same axis)

From the two cloud providers' billing records (Runpod hourly; Vast.ai per machine, placed by when each one was shut down): every rented GPU, by the fraction of each hour it ran, colored by model. The 8 "unrecorded" pods (about 10 GPU-hours) are short-lived ones whose model isn't in our logs. They start on day 2, when the searches outgrew the desktop 4090 and the DGX Spark; on the last day most of the fleet moved to Vast.ai, about twice the search per dollar.

Credits

Cave Story is by Daisuke "Pixel" Amaya / Studio Pixel. The maps and clips on this page are rendered from the Japanese freeware release; its graphics and music are his.