jevsnes.git / apps / replay-probe / README.md

Chapter 14: replay-probe, proving the same thing happens twice

Chapter 6's whole design rests on one claim: replay the recorded pad and the bot's recorded RAM writes from the same snapshot, and you get the same game, byte for byte, every time. If that is even slightly false (a stray timer, an uninitialised byte, a sound chip that drifts) then seeking shows the wrong frame, a rebuilt bot thinks it is somewhere it is not, and nothing complains. So before any of the seeking, rebuilding or disk-capping code was written, this probe had to pass.

It starts the real bot from your home state, lets it play a warm-up so the recording is real gameplay, then records a window of frames: the pad, the bot's RAM writes, and a hash of work RAM plus the picture for every frame. Then it replays that log from the starting snapshot twice, with no bot, and compares every frame's hash against the recording's and against the other pass.

Aside: it also measured the design into existence. The keyframe tiers and the 1 GiB cap in chapter 6 are not guesses. This probe reports log bytes per hour, keyframe sizes per tier (as the recorder stores them), headless replay throughput in frames a second, and the worst-case seek time at each tier through the real keyframe load. It is also where the discovery that varint snapshots defeat fixed-offset deltas came from: 83 consecutive snapshots in 70 different lengths, which is why Console::snapshot_fixed exists.

On 2026-09-22 two independent 10,000-frame replay passes were byte-identical to the bot-driven recording and to each other.

Try it. With a home state in roms/<rom>.states/ (chapter 11's --make-home, pointed at that directory):

nix develop -c buck2 run //apps/replay-probe:replay-probe -- \
  "roms/Legend of Zelda, The - A Link to the Past (USA).sfc"

The defaults are a 3,000-frame warm-up and a 10,000-frame window.

For the people who maintain it

replay-probe <rom.sfc> [--warmup N] [--frames N]. --frames must be at least three times COARSE_FRAMES, so every keyframe tier's worst case exists. The states directory is always the one beside the ROM; the probe writes into run/replay-probe/, which it empties first.

In this folder

PathWhat
src/main.rsThe probe: warm-up with the real bot, the recorded window, the two replay passes, and the measurements.
BUCKThe rust_binary, over console, replay and zbanks.

← Previous: Chapter 13, jevprobe/ · Up: apps · Next: Chapter 15, hotdemo/ →