Overview
Differential testing ensures the rewrite matches the original by:- Capturing a gameplay session from the original with Frida
- Replaying the same inputs in the rewrite (headless)
- Comparing state checkpoints tick-by-tick
- Reporting divergences with field-level granularity
Workflow
Capture Original Run
Instrument the original game to record inputs and state:Captures:
- Input events (keyboard, mouse)
- RNG seed and call sequence
- State snapshots every N ticks
- Final score, kills, time
gameplay_diff_capture.jsonReplay in Rewrite
Run the rewrite in headless mode with captured inputs:The rewrite:
- Seeds RNG with captured seed
- Feeds inputs from capture file
- Steps simulation tick-by-tick
- Generates state checkpoints
Compare State
The verifier compares each checkpoint field-by-field:Tolerance:
1e-5 for floats, exact match for integers.Capture Format
The differential capture file contains:Checkpoint Fields
Player State
Creature Pool
Projectile Pool
Global Counters
Divergence Analysis
Example Report
Root Cause Process
-
Identify First Divergence
- Tick 347,
pos_xdiffers by 0.001 - RNG call count differs (+1 call)
- Tick 347,
-
Trace RNG Call
- Extra RNG call between tick 346 and 347
- Search rewrite for
rand()calls in player/creature/projectile update
-
Find the Culprit
-
Fix and Re-verify
Test Coverage
Mode Coverage
Survival
Full parity across 1000+ tick runs
Rush
Verified spawn timing and wave logic
Quests
All 90 quest levels verified
Tutorial
Scripted sequence matches original
Subsystem Coverage
- Player movement and combat
- Creature AI and pathfinding
- Projectile physics and collision
- Weapon fire rate and reload
- Perk effects and stacking
- Bonus spawn and timers
- Experience and leveling
- Score calculation
Automated Tests
The test suite includes differential replay tests:Capture Guidelines
Deterministic Captures
For reproducible verification:-
Use fixed seed
-
Record full input state
- Every key press/release
- Mouse position every frame
- Timestamp or tick number
-
Checkpoint frequently
- Every 10-100 ticks
- After major events (level up, weapon pickup)
-
Capture metadata
- Game version/build
- Mode and difficulty
- Player config (keybinds, resolution)
Quest-Specific Captures
Quest mode requires per-stage files:- Quest-specific spawn scripts
- Stage completion criteria
- Expected final stats
Headless Simulation
The rewrite’s headless mode:Float Precision Handling
Float comparison uses epsilon tolerance:epsilon=0 (exact match).
CI Integration
Differential tests run on every commit:Related Pages
Frida Capture
Capturing differential testing inputs
Replay System
Deterministic replay architecture
Float Parity Policy
Float32 precision contracts