Replay: deterministic record & playback #4
Reference in New Issue
Block a user
Delete Branch "feature/replay"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds deterministic record/playback for a run. Recording captures
(seed, config hash, ordered tick-tagged commands)and re-simulates on playback — no state snapshots.DotaFactory.exe --replay <file>re-plays a recorded run view-only with manual speed/pause.Implemented phase-by-phase per
docs/replay_design.md:Hasher, RNG fingerprint, per-subsystem/ECScomputeStateChecksum, and a 2000-tick double-run determinism test.Commandbase + derived types,CommandManager(FIFO drain once per frame), and the singleSimulation::applymutation path. UI rewired to enqueue commands instead of mutating the sim directly..replayfile (header + tick-tagged commands + periodic/after-command RNG checksums), config hashing,ReplayRecorder.parseCommand,ReplayReader,ReplayPlayer(applies commands at their exact recorded tick, verifies checksums in file order, reports the first desync tick),--replayCLI, and a REPLAY/desync overlay.Compile-enforced command chokepoint
The
Simulationplayer-action mutators (tryPlaceBuilding,demolish,applySchematicChoice) and the mutable subsystem accessors (buildingsMutable()/beltsMutable(); only the constbuildings()/belts()stay public) are now private. Production's only handle to a subsystem is throughSimulation, and every production accessor call is a const query — so gameplay is structurally locked out of any command-bypassing mutation path. Such code now fails to compile instead of silently desyncing replays.Tests reach the private mutators through
SimulationTestAccess(afriend structundersrc/test, off the lib/ui/app include path), so they keep calling the real mutators and keep their return values. TheBuildingSystemsubsystem mutators stay public (unit-tested via a bare subsystem; unreachable from production anyway).Verification
lib,app,balancing,tests.--replay— reproduces correctly.Notes
🤖 Generated with Claude Code