Engineering journal
How to Find the First Difference Between Two Game Replays
Verify both histories, compare their first meaningful boundary, and keep damaged evidence separate from a gameplay difference. A worked LudoWeave recording shows why.
Source: https://louijiecompo.com/writing/how-to-find-the-first-difference-between-two-game-replays/
About 4 min read

Two replays can reach the same final state through different inputs. Two files can also have different hashes while describing the same gameplay. A useful replay debugger needs more than a comparison of the last frame or the artifact checksum.
LudoWeave's replay-history comparator (opens in a new tab), merged in PR #266, starts with a stronger question: are both complete histories valid for this composition? Only then does it locate their first meaningful difference.
Verify before comparing
A recording contains an initial snapshot, consumed inputs, command transactions, receipt hashes and optional checkpoints. The verifier reconstructs the world and checks the history against those contracts. Both sides receive independent, complete verification before the paired comparison starts.
That ordering matters. Suppose an input differs near the beginning, but a later receipt is damaged. Reporting the early input as the answer would hide the fact that one history cannot be trusted. In the retained example below, a deliberately damaged final post-state hash produces invalid, with no divergence payload, even though the input at tick 60 also differs.
An incompatible platform or schema is another distinct outcome. It is not a valid run that happened to play differently. Hashes establish identities and consistency checks here; they are not signatures identifying a trusted author.
Walk the histories together
After verification, the comparator creates fresh initial sessions and advances them in a linear paired walk. At each boundary it considers canonical state, checkpoint presence, history length, the next transaction's tick range, consumed inputs and transaction content. Timeline labels alone do not count as meaningful differences.
The walk does not assume a mismatch remains visible forever. Worlds can diverge and later reconverge. Repeated prefix reconstruction and a binary search based on persistent disagreement would answer a different question.
A change at input tick 60
For this article, I recorded two 180-tick Clockwork Arena histories from the pinned merged implementation. The second recording changes one consumed move.x value at tick 60 from +1 to -1. Both histories independently verify. No GPU or audio device was used.
| Boundary | Retained observation |
|---|---|
| Initial state | Same canonical world |
| After 60 batches, at tick 60 | Same state; the next consumed movement input differs |
| After the changed input, at tick 61 | Canonical states differ |
| Final tick 180 | Both histories still verify independently |
The report's after_batch: 60 identifies completed paired work. Its input_tick: 60 identifies the consumed input about to advance that state. Calling this simply "frame 60" would blur those two meanings. The report locates a boundary; it does not diagnose an engine bug or establish the root cause of a real incident.
Inspect the recording and comparison lab. The lab includes the exact changed-input report, original histories and a capture manifest. Its world display is a derived plot of saved positions, not the engine renderer or a new browser simulation.
Speed belongs to presentation
PR #265 adds 0.25x, 0.5x, 1x, 2x and 4x playback presets. Windowed presentation uses absolute scaled deadlines. Pausing, seeking and changing presentation pace do not introduce new world inputs.
The local evidence runs the same recording through the upstream Null renderer at all five accepted presets. Every summary is identical. Null playback is deliberately unpaced, so this check establishes unchanged recorded results, not window timing or GPU performance. The browser lab animates the saved positions at the selected pace, with manual stepping and a static result available too.
Keep the answer bounded and inspectable
The CLI accepts at most 64 MiB per file and 3,600 ticks and batches. Its public difference detail has a global 128-node budget and 128-character text and key limits, with a truncation flag. Those reporting limits do not promise bounded internal diff latency.
Results are identical, different, invalid or incompatible. The process exits with 0, 1 or 2 respectively, with both invalid and incompatible using 2. Keeping those categories explicit makes the report useful in automation without treating every nonzero result as the same failure.
The source contract (opens in a new tab) remains experimental. These features merged into main; that is not evidence of a new packaged release, cross-version compatibility or production readiness.