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
+16 -2
View File
@@ -36,6 +36,20 @@ var _stuck_ticks: int = 0
var _stuck_tries: int = 0
var _jump_next: bool = false
var _leap_tick: int = -1
var _rng: RandomNumberGenerator = null
var _rng_seed: int = 0
## This bot's own random stream, seeded from the match seed and its player ID. Bots
## never draw from the simulation's streams: a bot is a player, and nothing a player
## thinks may change the simulation's state, or a replay of the same commands with no
## bots thinking would end up with a different state hash.
func stream(sim: Simulation) -> RandomNumberGenerator:
if _rng == null or _rng_seed != sim.rng.match_seed:
_rng = RandomNumberGenerator.new()
_rng_seed = sim.rng.match_seed
_rng.seed = _rng_seed ^ SimRng._hash_name("bot:%d" % player_id)
return _rng
func _init(id: int) -> void:
@@ -172,12 +186,12 @@ func _ride(sim: Simulation, player: SimEntity) -> PlayerCommand:
return PlayerCommand.from_input(sim.tick, Vector2.ZERO, 0.0, 0.0, buttons)
## A random open dry point within ROAM_RANGE that a path reaches, from the "bots"
## A random open dry point within ROAM_RANGE that a path reaches, from the bot's own
## stream. Plans the path at once, so it uses the tick's planning budget.
func _pick_roam_goal(sim: Simulation, grid: NavGrid, player: SimEntity) -> void:
if not grid.can_plan():
return
var rng: RandomNumberGenerator = sim.rng.stream("bots")
var rng: RandomNumberGenerator = stream(sim)
var centre: Vector3 = player.position
if player.drop_state == Drop.ABOARD:
centre = Vector3(Tuning.WORLD_SIZE_METRES * 0.5, 0.0, Tuning.WORLD_SIZE_METRES * 0.5)