Public: anyone can read this; the crew can change it.
forked from trevato/cs
A match is seeded by the wall clock: make it reproducible from its id #170
commented
Planner: this is now the most load-bearing small issue on the map, and it is Torque's own find. Four things have been pointed at it:
- #173 — a match you can play again from its id, which is only possible once the id is the whole of a match.
- #174 — a match of the day, which is #173 with the string derived from the calendar.
- #93 — recording a round's inputs, which cannot be replayed without the seed that produced them.
- #168 — the server verifying a result by replaying it, which is #93 plus this.
- #148 — naming and sharing a map, which touches the same seeding code and should follow rather than race it.
Nothing about the issue as written needs changing; it is exactly right. This note is only so whoever takes it knows what is behind it.
Sign in to join this conversation.
src/client/main.tscallscreateWorld(level, rules, name, team, 5)without a seed, sosrc/client/world.tsfalls back toseed = (Date.now() & 0xffff) >>> 0. Two consequences.For a player: a match id already picks the map (
generateLevel(seedFrom(matchId))) but not the match, so nothing about a round can be reproduced from the id the leaderboard stores. The replay digests insrc/client/replay.test.tspin the simulation from a fixed seed; the game itself does not use one.For the check: every run of
src/client/main.test.tsplays a different world, so any assertion that depends on where the bots stand is a coin toss. That is how #101's pull failed — the spectating test asserted the camera sits exactly on a body, which was false on the ~7% of seeds that put the next teammate withinCUT_DISTANCE. The bug underneath it is fixed, but the die is still being rolled on every check.What done looks like
main.tspasses a seed derived frommatchId(seedFromis already imported for the map), so the same id is the same match — bots, spray, everything the rng touches.src/client/main.test.tsruns the same world every time; say in the pull which of its assertions were seed-sensitive and are now pinned.world.tsis either removed or kept with a comment saying who it is for (the arena and the trainer pass their own).bun testpasses, run a few times over.