M4: Bot navigation
NavGrid is the map bots plan on: a point per 2 m terrain sample, solid on cliffs and where solids stand between step and head height, and costlier where the water is deeper than wading. Path search uses Godot's AStarGrid2D. The grid syncs every tick: new solids (walls, pieces) block points at once, removed ones are found by a rolling scan, and points turn wet as the tide and flood reach them. Each change is stamped with its tick. NavBot follows a path with ordinary PlayerCommands: it steers at waypoints, sprints on long dry stretches, jumps when stalled, and marks a point blocked after repeated stalls. Every half second it checks its remaining path against the change stamps and plans again if water or a wall now crosses it. One path is planned per server tick across all bots. The server builds the grid while the lobby waits and its bots now roam between random reachable places, replacing the placeholder wander bot. Tests: 150 of 150 random reachable targets reached on 50 islands in the sweep; the test runs 2 per island and needs 95%. New walls and rising water both cause a new path around them; a broken wall opens the grid again; with no dry way round, the bot swims. 23 roaming bots on an island: p99 tick 1.6 ms against the 12 ms budget. Closes #27 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -120,6 +120,28 @@ sent on a reliable ordered event stream, since a dropped wall is a gameplay lie.
|
||||
| `src/audio/` | Sound playback, music | `src/sim/` (read only) |
|
||||
| `src/app/` | Startup and mode selection | Everything |
|
||||
|
||||
## Bots
|
||||
|
||||
Bots live in `src/bots/` and play through the same door as humans: each tick a bot
|
||||
reads the simulation and returns one `PlayerCommand`, which the server submits like
|
||||
any other. They never write to the simulation.
|
||||
|
||||
`NavGrid` is the shared map they plan on: one point per 2 m terrain sample, solid
|
||||
where the ground is a cliff or a solid stands between step and head height, and eight
|
||||
times as costly where the water is deeper than wading. Path search is Godot's
|
||||
`AStarGrid2D`. The server builds the grid while the lobby waits (about 0.4 s, next to
|
||||
the island's own generation) and syncs it every tick before bots think: new solids
|
||||
block points at once, removed solids are found by a rolling scan within a few ticks,
|
||||
and points turn wet as the tide and flood reach them. Every change is stamped with its
|
||||
tick, and each bot checks its remaining path against the stamps twice a second, so a
|
||||
new wall or rising water across a path makes it plan again. Only one path is planned
|
||||
per server tick across all bots; others wait their turn.
|
||||
|
||||
`NavBot` follows a path: it steers at the next waypoint, sprints on long dry stretches,
|
||||
jumps when it stops making progress, and after a few tries marks the point blocked and
|
||||
plans around it. The brains in M5 choose its goals; until then the server's bots roam
|
||||
between random reachable places.
|
||||
|
||||
## Terrain
|
||||
|
||||
The island's heightfield (`Island`, in `src/sim/`) is the only terrain collision, on
|
||||
|
||||
Reference in New Issue
Block a user