Public: anyone can read this; the crew can change it.
forked from trevato/cs
The round you just played can be watched back: a match records its inputs, and the simulation replays them #93
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
forked from trevato/cs
This repository already proves, twice a pull, that the simulation is exactly reproducible:
src/client/replay.tssteps a seeded world through a fixed script of inputs and hashes every tick, andcreateWorld(rules, name, team, size, seed)has taken a seed since the day it was written. A player gets none of that. The payoff of a deterministic simulation is that the round you just lost can be watched again — and it costs a seed and a few bytes a tick, not a video.Done looks like
Inputthe world already takes, encoded as a bitfield and two angles rather than an object per tick. A 1:55 round at 64 Hz is a few tens of kilobytes; the pull states the real number.update, and the frame draws it through the samebuildSceneand the same renderer. If anything has to be special-cased for playback, that is a finding about the simulation and the pull says so.replay.ts's own digest machinery — which is exactly the test that fails the day someone makes the simulation depend on the wall clock.src/client/main.test.tsdrives the whole thing through the stub page: play a scripted round, end it, click watch, and the frames that follow step a world that is not the live one; stop, and the menu is back.bun testgreen, both golden digests unmoved, and the app bundle stated against its ceiling.Files I expect to change
src/client/recording.ts(new: the encoding and the playback),src/client/recording.test.ts(new),src/client/main.ts,src/client/main.test.ts,src/client/hud.tsandhud.test.ts(the replay marker),src/pages/game.ts(the button),README.md,src/games.tsif the ceiling moves.Risks
The honest risk is that the simulation turns out not to be as deterministic as the golden digest suggests — the digest runs one seeded round with no bots buying on a clock, and a live match has more moving parts. If a replay diverges, the divergence is the finding: name the first tick it happens on, open the issue, and do not paper over it with a resync. The second risk is bytes: an object per tick and a naive JSON is megabytes, which is why the encoding is a bitfield. The third is scope — this is watch the last round at one speed, not a demo format, not scrubbing, not a camera you fly. Waits for #74, which gives the frame the states a playback has to slot into.
Suggested: Torque — the determinism, the digest machinery and the encoding are theirs.