When a match's results begin, Match starts the next match's Simulation on a
WorkerThreadPool task (its seed is fixed by then) and collects it when the
lobby opens. The same task plans the island's tide levels
(Simulation.plan_tide) and runs a prepare_next hook, which ServerLoop uses
to build the bots' NavGrid and BotWorld for the island. All of these read
only the new simulation, so the results are the ones the main thread would
have made: tests compare the state hash, terrain, solids, props, tide
levels and navigation with fresh ones, and the ten-matches test still
matches its references. A Match freed while its task runs waits for it.
Measured: a 24-bot server paced in real time through the results, lobby,
countdown and 3 s of the next drop has a worst tick of 5.4 ms; it was 1.8 s.
In the 24-client soak at 2% loss, moving the island alone left a 0.82 s tick
(the bots' navigation) and moving that too left 74 ms at the next match's
start (planning the tide), which this also moves. The soak hasn't been run
again since that last step.
Closes#79
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- LAN discovery: a listening server answers QUERY packets on its game port
plus one (ServerBeacon, off with --no-lan). ServerBrowser scans eight game
ports from 24650 by broadcast.
- A self-hostable list server: --list-server [--port=N] (ListServer,
default UDP 24660). Game servers register with --list=HOST[:PORT] and
--name=NAME; they are listed under their source address only after
echoing a CHALLENGE token. Entries expire after 45 s, 8 per address,
256 in all; every source is rate-limited (SourceLimiter).
- NetDiscovery messages: every QUERY is padded to 512 bytes and no answer
is bigger, so neither service amplifies spoofed requests.
- tidewall --browse [--list=...] [--lan-target=IP] [--lan-port=N] prints
the servers found as JSON until menus (A10) show them.
- People who connect mid-match or during results watch a living player
(Match.watch) and take places ahead of bots in the next lobby, instead
of being told the server is full. Bots fill only the places left when
the match starts.
- Tests: codec round trips, size limits and a 40,000-message fuzz; list
server with fake servers (challenge, stolen and wrong tokens, renewal,
expiry, caps, flood); LAN scan over loopback; watchers over UDP; lobby
backfill. make discovery-check runs it all as real processes.
Closes#37
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tide now runs every match, from the drop on, and water flows along the
terrain instead of standing everywhere under one level.
- Tide (src/sim/tide.gd): Tuning.TIDE_PHASES as a schedule of holds and
rises. Level, forecast (each hold announces its level), stage, drowning
rate, surge timing and the time limit are pure functions of the tick.
- SafeGround (src/sim/safe_ground.gd): safe ground from elevation on an 8 m
grid, and per-island planned levels. A phase's level is lowered, when it
must be, to just under the top of the largest piece of land still dry when
the phase begins; every phase still rises at least TIDE_MIN_RISE_METRES and
the last keeps its table level.
- Flood (src/sim/flood.gd): a 4 m grid aligned with building cells. Water
reaches cells from the world's edge through ground under the sea and edges
no breakwater stack seals. Cut-off ground stays dry until overtopped or
breached, then fills at BREACH_FLOW_METRES_PER_SECOND. Incremental: only
the edges where water stopped are re-tested, once a second.
- Players, drowning and structure wear use the local water. Breakwaters wear
by head and fail past BREAKWATER_MAX_HEAD; a breach floods what's behind.
- Storm surges: each phase's `surge` damage hits pieces near the water when
its rise begins.
- Sudden death after the last rise, then a time limit. Match breaks ties
(most health, highest feet, earliest join) at the limit and when the last
players fall together, so every match ends with a winner.
Tests: test_tide (18) covers the schedule and forecasts, planned levels,
overtopping, a sealed ring, breach and fill rate, spill-over, pressure wear
and head failure, dry pieces, surges, drowning under the real tide, sudden
death, the time limit and simultaneous eliminations. test_island's 100-seed
sweep now checks that every phase leaves safe ground reachable on foot from
the whole main landmass within the phase's time (closest margin 14 s).
A full rise with 24 bots measured p99 1.5 ms, max 1.9 ms per tick.
Closes#25
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Match (src/sim/match.gd) runs a server's matches back to back: lobby,
countdown, drop, play and results, then a fresh island and the lobby again.
It is stepped once per server tick and has no scene-tree or clock dependency.
- MatchRules holds max and min players, team size, the lobby, countdown and
results timers (defaults in Tuning.MATCH_*) and whether bots fill empty
places.
- Participants are server-chosen handles. Joining during a match waits for
the next; leaving during the drop or play places the leaver as eliminated.
- Placements, winners (last team standing) and events for phase changes,
joins, leaves, places, match start and end.
- Match 0 uses the server's seed; later matches derive their seed from it and
their index. The next match's Simulation is built when the lobby opens.
- ServerLoop now drives a Match (immediate rules by default, so the smoke
match is unchanged: same state hash), rebuilds bots each match, and counts
server ticks across matches. The headless server logs match events.
Tests: test_match (13) covers every transition, leaving in each phase, an
empty lobby, an empty match, teams, late joiners, and ten consecutive matches
that each start identical to a freshly built simulation. A ServerLoop test
checks the server goes back to the lobby and starts the next match.
Closes#24
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>