M8: Complete offline match

`make match` plays one whole match from the lobby to the results and back to the
lobby: one scripted player and 23 bots on a local server, with no script errors.

- CommandLog records the seed, the rules and every command the server is given.
  MatchReplay plays a log again with nobody thinking and ends on the same state
  hash; `make match` saves the log, reads it back and checks that.
- ServerLoop.submit() is now the one way commands reach the simulation, so a
  recording server sees them all.
- ScriptedPlayer plays a human seat: it drops, loots, fights and flees as a bot
  does, and also cuts driftwood and builds a breakwater and a wall.
- Bots draw randomness from their own per-bot generators, not the simulation's
  streams. A bot thinking no longer changes the simulation's state, which a
  replay without bots needs.
- MatchView and EntityView draw a match from one Simulation: terrain, sea,
  points of interest, props, pieces, players, the barge, items and chests, with
  stand-in shapes for the art pass to replace.
- `make match-captures` renders eight stages of the recorded match.

Closes #31

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-12 05:35:32 -05:00
co-authored by Claude Opus 5.5
parent 8cf164d562
commit 1d6a24ab64
38 changed files with 1633 additions and 15 deletions
+33 -1
View File
@@ -77,8 +77,10 @@ deterministic.
- A match has one `u64` seed, always logged.
- Gameplay randomness comes only from named streams, created from the match seed and a
stable name: `rng.stream("loot")`, `"weapons"`, `"bots"`, `"worldgen"`, and so on, on one `SimRng`.
stable name: `rng.stream("loot")`, `"weapons"`, `"drop"`, `"worldgen"`, and so on, on one `SimRng`.
One system's extra rolls can't disturb another's.
- Bots don't draw from those streams. Each bot has its own generator, seeded from the
match seed and its player ID, so nothing a bot thinks changes the simulation's state.
- Simulation code **never** calls `randf`, `randi`, `Time`, or anything else that varies
between runs. Presentation can use whatever randomness it likes, for effects.
- The same seed and the same command log produce the same state hash, on the same engine
@@ -91,6 +93,27 @@ to millimetres.
Determinism is for tests, replays and worldgen. Clients don't rely on bit-exact matches
with the server. Reconciliation corrects any difference.
## Command log and replay
`CommandLog` (`src/server/`) holds a match's seed, its rules and every command the
server was given: the simulation tick it arrived on, the handle it came from and the
command's 14 bytes. `ServerLoop.submit()` is the one way commands get in, for people,
scripts and bots alike, so a recording server logs them all, accepted or not. On disk
it is a JSON header and the records compressed with Zstandard, about 0.6 MB for a
24-player match.
`MatchReplay` plays a log again: the same seed and rules, the same commands on the same
ticks, and nobody thinking. It ends on the same state hash as the recording, which
`make match` checks after every run. A replay can stop at any tick, which is how the
match captures draw a moment of a real match. Replays are exact only on the same engine
build, like everything else that relies on determinism.
`ScriptedPlayer` (`src/bots/`) is a stand-in for a person at the controls. It plays a
human seat as a bot would, and also cuts driftwood and builds a breakwater and a wall,
so a scripted match covers the drop, loot, combat, harvesting, building and the tide
from a player's seat. `ServerLoop.play_humans_by_script()` turns it on; no shipped mode
uses it.
## Snapshot format
A snapshot is a binary, little-endian packet:
@@ -178,6 +201,15 @@ full-resolution heightfield at every level, so lighting doesn't change across a
The terrain shader blends procedural sand, marsh, grass and rock layers using splat
weights from the island's elevation bands, with rock on steep ground.
## The match view
`MatchView` (`src/client/`) is the client's picture of one match: sky, sun, terrain,
sea, points of interest, props, built pieces and `EntityView`, which draws players, the
barge, items and chests. All of it reads one `Simulation` and never writes to it, and a
new match gets a new view. The camera sits on a player's shoulder through `CameraRig`.
Until snapshots arrive, the simulation it reads is a local server's or a replay's; the
figures, barge and items are stand-in shapes for the art pass to replace.
## Performance budgets
| Budget | Target |