M2: The rising tide

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>
This commit is contained in:
2026-11-11 20:48:41 -05:00
co-authored by Claude Opus 5.5
parent c6f3c19004
commit 8a6fb93b50
18 changed files with 1194 additions and 21 deletions
+26
View File
@@ -143,6 +143,32 @@ sky barge or the packet ship and mortar of the core loop above, are open in #72.
- `level`: the sea height in metres at the end of the rise;
- `drown_dps`: damage per second to anyone in water above their head.
The tide starts with the drop. Each island plans its own levels from its terrain
(`SafeGround`): a phase's table level is lowered, if it must be, to
`TIDE_SAFE_MARGIN_METRES` under the top of the largest piece of land still dry when the
phase begins, while every phase still rises at least `TIDE_MIN_RISE_METRES`. So safe
ground never vanishes from under the main landmass early. The island sweep checks, over
100 seeds, that every phase that leaves land leaves it within reach of the whole main
landmass on foot within the phase's hold and rise.
**Flooding.** Water only reaches ground it can flow to ([`src/sim/flood.gd`](../src/sim/flood.gd)):
from the world's edge, across 4 m cells whose lowest ground is under the sea, and over
cell edges no breakwater seals. Low ground cut off by higher land or a breakwater ring
stays dry until the sea overtops what holds it back or a breakwater breaks. Then the
water pours in and the cut-off ground fills at `BREACH_FLOW_METRES_PER_SECOND` until it
is level with the sea. Water never drains. Players, drowning and the wear on pieces all
use the water where they are, not the sea level.
**Storm surges.** When a phase's rise begins, its `surge` damage hits once every built
piece whose base is less than `TIDE_SURGE_HEIGHT_METRES` above the water that reaches it.
**Sudden death.** When the last rise ends, everyone still standing loses
`TIDE_SUDDEN_DEATH_DPS` health a second, armor or not. After
`TIDE_SUDDEN_DEATH_SECONDS` the match ends whatever happens. If several players are still
standing then, or the last ones fall on the same tick, the winner is the one with the most
health, then the highest feet, then the earliest to join. So every match has a winner
within the tide's total time plus sudden death.
The last phase raises the sea above the highest ground, so every match ends. Players
standing in shallow water wade and slow down. Underwater, they lose breath over
`BREATH_SECONDS`, and then take the phase's `drown_dps`. Swimming is slow and leaves a