Weather.at(tide, tick) derives the weather from the tide's schedule
alone, so every client sees the same sky with nothing new on the wire:
the storm builds from calm at the first tide to a gale at sudden death,
and the light runs from mid-afternoon to dusk at the time limit.
WeatherView applies it each sync to the sky, sun, fog, ambient light,
the sea's roughness and rain around the camera (CPUParticles3D, for
both renderers). Under water the view closes into SEA_MURK, the rain
stops and the surface is a rippled ceiling seen from below.
The sea shader darkens open water and adds chop and whitecaps with the
storm, and keeps a breathing foam band at the waterline with a fainter
line beyond. In the Compatibility renderer, whose depth texture the
shader can't read (the sea came out all foam), water depth comes from
a texture of the terrain's heights instead. Sea colours move into
Palette; the rain and wind beds follow the weather.
Tests: test_weather (7). make check passes (611 tests). Captures:
make sea-captures (every tide phase, calm beach, the last land in the
gale, under water, and three in the Compatibility renderer).
Closes#46
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The islander is built in headless Blender (tools/models/figure.py,
`make figure`, `make art`) as twelve rigid parts with their origins at
their joints: an oilskin coat, a sou'wester, sea boots, a bedding roll
and the canvas wing-sail. Debian's Blender can't write glTF, so the
figure is jointed rather than skinned.
FigureRig hangs the parts on pivots, paints them from Palette with the
coat in the player's own oilskin, and plays FigurePoses' hand-written
key poses through one AnimationTree: idle, walk and run by speed,
crouch and creep, air, skydive, glide, swim and aboard; long, short and
carried holds; reload and use layers; fire, boathook swing, keg throw
and building as one-shots; and a flinch when health drops. The chest
takes a third of the pitch and the held item all of it.
Figures animate from replicated state only: positions, look, health,
the held item and the FLAG_ bits (reloading and using now reach
mirrored players), with actions from FX. Every boathook swing is now a
sim "swing" event, sent as a SHOT with no item, so misses are seen and
heard; the new FX kind PLACE shows pieces placed. Protocol version 4.
Tests: test_figure_rig (15), plus swing and PLACE cases in test_harvest
and test_net_fx. make check passes (604 tests); make client-check
passes. Captures: figure_states, figure_actions, figure_close
(make figure-captures), client_glide and client_landed.
Closes#42
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/models/items.py builds every item in headless Blender from
primitives: the boathook, the eight weapons and powder keg, four
consumables and five kinds of ammo, each with its own outline. It
writes an OBJ per item (the Debian Blender's glTF exporter needs numpy),
a JSON with the grip and the left hand's support point, and a 128 px
Cycles icon rendered on the CPU. Materials are named after Palette
colours, and TRIM2_/TRIM3_ surfaces are the tier treatment: rope
whipping from tier 2, brass bands from tier 3; tier 0 is faded.
ItemModels paints the models from Palette by tier. EntityView puts the
held item's grip in each figure's right hand, turned with the player's
pitch and put away aboard, falling, gliding or swimming, and draws
items lying in the world with their models, one MultiMesh per model
and tier. The hotbar shows each slot's icon.
make models rebuilds them; make item-captures renders the items held,
over the shoulder, on the ground and by tier.
Closes#44
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every sound is made by scripts in tools/audio/ and committed as a WAV in
assets/audio/ with a manifest of hashes and levels:
- dsp.gd: seeded noise, wavetable oscillators, filters, envelopes and
struck modes. recipes.gd: 50 effects (footsteps on five surfaces,
a report per weapon, impacts, carpentry building and breaking, the
tide's bell, foghorn, surge and lighthouse, player, ambience, menus).
- score.gd: an original eight-bar tune and chords in D Dorian, 6/8,
rendered as four looping layers (drone, frame drum, concertina,
fiddle).
- loudness.gd and check.gd: per-category loudness targets, a -1 dBFS
peak ceiling and the mix order (the tide loudest). make audio and
make audio-check.
In the client, SoundDirector turns FX records, footsteps, building,
the tide and the player's own hurts into sounds, placed on 3D voices
at the event so gunfire and footsteps come from their direction.
MusicDirector fades the score's layers with the tide on an
AudioStreamSynchronized, full in menus. MenuSounds knocks for buttons.
Closes#48
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a client's world hash differs from the server's, the soak report
now names the part that differs (tide, props, pieces or loot), the
client's ClientWorld tick, and each piece whose entry differs on the
two sides, so the next transient mismatch can be traced.
- NetWorld.world_detail(): part hashes and a piece list. world_hash()
is unchanged: the same bytes, hashed in four parts.
- The server's world_hash log lines and the soak clients' hash lines
carry the detail.
A full soak with this (24 clients, 2 matches) compared 3,743 hashes
with 0 differing, so the mismatch didn't come back to trace yet.
Refs #80
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The island as a hand-drawn nautical chart: paper land with ink contours
every 5 m (heavier every 25 m) and a coastline, the sea in the sea's
ink, place names drawn from the seed, the barge's route, and the
player's mark. The land the coming tide will flood is hatched, and land
the sea has already taken is washed with the sea, so the forecast isn't
told by colour alone.
- Flood.forecast(level, structures): a copy of the flood spread to a
level as update() would, with today's breakwaters. Changes nothing.
- ChartMap: FULL (opened and closed with the new "map" binding, M) and
MINI (240 m around the player, top left, during the drop and play).
The paper is drawn once per world (about 270 ms) and shared; the
forecast overlay is redrawn at most once a second, and only when the
forecast level, the flood or the pieces changed.
- PlaceNames: names from original coastal words and a word for each
kind of place, the same for every player of a match.
- make chart-captures renders the chart before and after the first tide.
Solo matches have no teammates; ChartMap draws `mates` when duos (M7)
give it some.
Closes#51
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The game now opens on a main menu when it has a window: practice
against bots (count and skill), join a server (by address, or from a
LAN search list), settings, and quit. In a match, Escape brings up a
pause menu (the match goes on) with settings and leave; when a match
the player was in ends, a results screen shows their place,
eliminations and the last of the feed.
- KeyBindings: every action rebindable to a key or mouse button.
bind() refuses an input another action uses and names it; Escape is
reserved. ClientInput reads keys through the bindings.
- GameSettings: bindings, mouse, graphics (quality preset and the
print pass), audio (master, music and effects buses), display
(window mode, vsync, frame cap), name, last server and practice
choices, saved in user://settings.cfg. Missing, unreadable or
corrupt files and bad values fall back to defaults, value by value;
hand-edited key clashes are repaired on load.
- Menus (src/ui): paper-and-ink panels, brass focus edge, keyboard
navigable; a drawn sea-and-tide-post backdrop, or an ink wash over
a match. AppShell runs menus and the session.
- LocalServer takes a bot difficulty.
- make menu-captures renders every screen.
Closes#50
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The soak's client memory growth (17 to 20 MB, about five islands, in some
processes) came from SoakPlayer keeping a strong reference to the last world it
played on. It let go only when its client next asked it for a command on the
new world, so finished islands stayed alive across a match change. It now keeps
only the island's seed.
LiveCount counts live Simulations and SimGrounds, which are made on worker
threads too, so it is thread-safe. The soak clients log the counts, and the
soak report fails if, a minute into a match, any island is alive that isn't a
client's world or one being made. That makes a leak name itself instead of
showing up as bytes.
Refs #39
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The HUD (src/client/hud) is drawn in the paper-and-ink motifs of the style
guide:
- top centre: the tide post, the most prominent thing on screen. It is a
notched post with the sea filled in, the next level's rust notch and the
player's own height. Beside it are the phase, the time to the rise, both
levels and how far the player stands above or below the next line;
- top right: how many are standing, and the kill feed in words;
- bottom left: health and armour, each with a number, a word, quarter notches
and its own hatching. Low health adds LOW;
- bottom centre: the boathook and five slots, with names on two lines, rounds
and reserve or counts, and tier pips;
- bottom right: materials, and the build line ("NOT ENOUGH" when short).
Snapshots only carry nearby players, so the server now sends FEED (NetFeed,
reliable) when anyone is placed and at each phase change. It carries who is
standing, the match size and the newest 16 entries with names. Bots get crew
names (CrewNames). HudState works out what to show from the client, or from a
server's match for captures and tests, so the drawing never reaches into
either.
The project now stretches canvas items from a 1280x720 base, so the HUD scales
to any screen. make hud-captures renders it at 1280x720 and 3840x2160. The
parser fuzzer covers FEED.
Closes#49
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/STYLE.md sets Tidewall's look: a drowned coast printed by hand. It has the
palette, shape language, character proportions, shading, UI motifs, audio
palette and a do-not-do list.
- Palette (src/client/style/palette.gd) is the one table of client colours.
Every colour that was scattered over the views now names its entry, with
values unchanged. test_palette fails on a colour literal anywhere else in
src/client or src/app, and on a palette colour the guide doesn't list.
- Look sets up the sky, the salt-faded grading (saturation 0.86, contrast
1.05), the sun and the print pass, for the match view and the capture scenes.
- folk_print.gdshader is one full-screen quad multiplied over the frame. It
draws ink lines at depth jumps and creases (fading with distance, scaled with
screen height), diagonal hatching cut into real shadow, and faint paper
grain. Ground under the sea gets none.
- make style-captures renders a hamlet and a dock with and without the pass.
Closes#41
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Build ghost: ClientSession shows a BuildGhost in build mode while the
client plays, asking Building.check() of its own world and predicted
player with the mouse's newest look, so it agrees with the server.
- Flooded basins: ClientMirror.follow_flood() spreads the client's flood
as the server's tide tick does, from the tide and the pieces it has.
WaterView passes a mask of flooded cells (Flood.pours says when it
changed) to the sea shader, which leaves dry cells undrawn.
- Shots, impacts and swings: a new FX message (NetFx) goes unreliably on
the state channel next to each snapshot, with what happened within
NET_FX_RADIUS_METRES of what the client watches or involving that
player. ClientGame keeps them in `fx` for views and sound. They change
no state, so a lost one is a missed flash; sending them reliably would
add to the traffic a bad link can least afford (N8). The fuzzer covers
the new parser.
- Captures: client_build and client_build_refused show the ghost in its
allowed and refused tints; client_basin rings shore ground with
breakwaters and plays until the tide stands over it, and the server,
the client's flood and the drawn sea all keep the basin dry.
- Tests: NetFx round trips, limits and malformed input; a landed player's
shots and impacts reach a client, each matching a server event; the
client keeps a ringed basin dry through the first rise, floods it with
no ring, catches up after a long frame; the water mask follows pours.
The held item is still not drawn; that needs the models (A4, #44).
Closes#78
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each client process now also logs the engine's object count and how many
distinct worlds and prediction grounds its clients reach, at the start of
each match's play and again a minute later (memory_late). This is for
finding the client memory growth the soak still reports (#39); the
checks are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The soak's drops under loss came from stalls: the server's island (#79) and
each client process making islands on its main thread fed ENet second-long
round-trip samples, its retransmission timer grew, and two losses of one
reliable message in the busy drop that followed reached the 15 s timeout.
- ClientGame.build_in_background makes a new match's island on a
WorkerThreadPool task and holds the packets that arrive meanwhile, then
takes them in order. The networked client and the soak's clients use it;
the soak's own one-island-a-frame holding is gone.
- NetServer.close(grace_msec) sends the shutdown notice reliably and
services the socket while clients acknowledge it. The headless server
waits up to 2 s. A notice sent once was lost under 2% loss, and that
client timed out instead of hearing the server stop.
- Tests: background island holding and ordering, freeing mid-build, a
graceful shutdown reaching four clients behind 50% loss (it fails with
the old one-shot notice), and the scripted UDP match and client capture
wait for the client's island the way a real 20 s lobby would.
The soak at 2% loss and +/-20 ms now keeps all 24 clients for both matches,
with 0 of 3,758 world hashes differing and every client told of the stop.
It still fails on client memory growth between matches in two of three
processes (17 and 20 MB), which is not yet explained, so #39 stays open.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
tools/smoke.sh now starts the server through packaging/server/tidewall-server,
sends the wrapper SIGTERM once the server has started, and checks it writes its
stats and stop lines and exits 0, as H7 asked. make check runs it.
Refs #70
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- packaging/server/tidewall-server: a wrapper that turns SIGTERM and SIGINT
into a clean stop through the server's new --stop-file, since the engine
can't catch signals. The server tells everyone it shut down, logs its
statistics and exits 0; the wrapper kills it only after 15 s.
- --config=PATH reads options from a file (packaging/server/server.cfg);
options after it on the command line win.
- --health-port answers GET /health with JSON (phase, players, tick, uptime)
on loopback by default. HealthServer is non-blocking and bounded.
- packaging/docker: a debian:13 image that checks the engine against
tools/engine.sha512, imports the game at build time, runs as an unprivileged
user, and works with a read-only root and a small /tmp. compose.yaml is
project and container tidewall-server, read-only, no capabilities.
- packaging/systemd: a hardened unit with a dynamic user.
- make server-package-check: compose up, healthy, non-root, read-only, a real
headless client joins over UDP into the drop, then SIGTERM stops it cleanly.
This also covers H7 (graceful shutdown on SIGTERM).
Closes#38Closes#70
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
make soak runs a real server and 24 headless clients in three processes for
two whole matches in real time. Each client reaches the server through its own
UdpRelay, which adds 60 ms, +/-20 ms jitter and 2% loss each way, so ENet runs
unchanged over a bad link. SoakPlayer drives each client from what a client
knows: it drops, glides, heads for high ground, harvests and tries to build.
tools/soak_report.gd checks world hashes against the server's, errors,
unreadable packets, every client playing every match with its connection
intact, memory between matches, and the p99 tick with the network's share.
make soak-selfcheck proves a drifted client world is caught.
Server changes: --matches=N, --world-hash-every=N, tick timing that includes
after_tick, and memory in match and progress lines.
What the soak found and fixed:
- Snapshot building for 24 clients took the p99 tick to 13.8 ms, over the
12 ms budget, against a 2.8 ms simulation. Encoded records are now shared
between clients for the tick, unchanged records skip the field diff, and
clients are spread over the snapshot interval by handle. p99 is 7.3 ms.
- ENet peers had a timeout limit of 0, which gives up on a peer as soon as any
reliable message has waited the minimum timeout. Now ENet's default, 32.
Not fixed: one or two clients still lose their connection about 15 s into the
second match's drop in each run (see the issue), so the soak still fails and
N8 stays open.
Refs #39
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A hostile test client crafts INPUT packets byte by byte and sends them
through NetGame.take_input() into a real match: extreme axes, the same
tick claimed repeatedly, the whole lead window at once, past, far-future
and maximum ticks, fire toggled every tick with slot swaps, builds aimed
anywhere with junk kinds and materials and no materials, and
pickup/drop/select tricks. Speed stays within sprint speed per tick,
shots within the weapon's rate, pieces within build reach and paid for,
and every item is conserved.
- Fix: a command tick beyond the simulation's lead window no longer moves
NetGame's dedupe marker, so one bogus far-future tick can't lock out a
player's real commands.
- Connections are rate-limited per address (32 per 10 s, 8 handshakes in
progress) with a new REASON_BUSY and a message for it.
- ParserFuzz mutates real messages from a bot match and random bytes and
feeds them to every network decoder, the snapshot receiver and the list
server. 20,000 per make check; make fuzz runs 1,000,000 (about 40 s):
no errors, 2.9 KB of memory growth.
- ARCHITECTURE.md: "Trusting nothing from clients".
Closes#40
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 client program now turns a connection into a match someone can play.
- ClientSession: a ClientGame, the keyboard and mouse as commands
(ClientInput), and a MatchView of the client's own copy of the world.
- ClientMirror writes what the client is showing into that world every
frame: other players from the recent past, its own player where it was
predicted, items, the barge, the clock and the sea. The existing views
draw it unchanged.
- LocalServer: offline play is the same ServerLoop and NetGame in the same
process, with packets handed across in memory, so there is one path.
- main.gd: --connect=HOST[:PORT] joins a server, otherwise an offline
match; --autoplay and --client-seconds=N for scripts and checks.
- The camera aboard the barge follows the player's own place on the deck.
Tests drive a scripted client through a whole match on a real server over
loopback UDP, lobby to results, and through an offline match. `make
client-check` does it with two real processes, and `make client-captures`
renders what the client sees.
Closes#77
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Built pieces, props' health, opened chests and the tide's schedule now reach
clients as WORLD messages on the reliable channel, and each player is told
what they carry as OWN messages.
- NetWorld: the WORLD and OWN wire formats, and world_hash(), a digest of
everything replicated this way.
- WorldSender: one message after each tick in which something changed, the
same for everyone, and the whole state for someone joining or a new match.
StructureSet and PropSet keep the change lists it reads.
- ClientWorld: applies them to the client's world, so pieces and broken props
are solid for prediction. A piece's health follows from its building and
damage, so building costs nothing on the wire.
- Placing ahead of the server: a provisional piece goes up with the command
and is replaced by the server's, or taken back once a snapshot shows the
server had its chance. Snapshots carry the newest WORLD number for that.
- Protocol version 3.
A test plays a whole scripted match on a real island with a ClientGame
attached and compares the two worlds' hashes throughout.
Closes#36
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A network client draws other players in the past and its commands take time
to arrive, so by the time the server fires a shot the target has moved on:
8 ticks at a 50 ms round trip, 12 at 200 ms.
Each PlayerCommand now carries view_lag: how far back its player was seeing
everyone else, in quarter ticks. The simulation keeps where every player's
body has been for the last 15 ticks (HitHistory), and a hitscan shot is
traced against other players where they were at the moment the shooter saw,
and against the world as it is now. Projectiles aren't rewound.
The client claims only when it was looking and where it aimed; the server
works out the hit from its own record. The moment is never more than
Tuning.LAG_COMPENSATION_MAX_TICKS back, never in the future, and never
earlier than a moment the same player has already claimed.
Commands are 15 bytes, so the command log's version is 2. The lag is in the
log, and replays judge every shot as the match did.
Measured in test/net/test_lag_compensation_link.gd over a simulated link:
a client firing at a walking target as drawn on its own screen hits 41 of
41 shots at 50, 100 and 200 ms round trips, 0 of 41 with the lag ignored,
and 0 of 41 at 500 ms, past the cap.
Closes#35
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The client's side of a networked match, in src/net/:
- ClientGame takes the server's notices and snapshots, generates the island
from the seed and answers with commands. It works on packets, so it runs
over a NetClient or a test's simulated link.
- ClientClock decides which tick the next command is for, from the server's
echo of the newest command tick it has received, holding three commands
waiting at the server.
- ClientPrediction runs each command on a copy of the client's own player
with the server's movement code, and compares every snapshot with what it
predicted. A difference is replayed from the server's state and eased in.
- SnapshotInterpolator draws everyone else four ticks in the past, between
snapshots, on a clock steered gently by arrivals.
Snapshots now carry the client's own block: exact position and velocity,
the water around the player, stamina and state flags, so a prediction can
match the server to the bit. The command echo is now the newest tick
received rather than taken. Protocol version 2.
Snapshots go out every second tick. The interval was three ticks, which is
10 a second, not the 20 the documents claimed; 15 a second is the nearest
even spacing and what interpolation is tuned for.
Drop.ride() holds the barge ride for the server and the client alike, and
NetGame's joining, input and snapshot steps can be called without a socket.
Measured in test/net/test_prediction_link.gd over a simulated link with
100 ms each way, 20 ms jitter and 2% loss: no corrections to own movement
in about 1,400 snapshots per client, and the other player drawn 0.4 mm on
average from where a perfect link would draw them.
Closes#34
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NetSnapshot defines the game traffic after the handshake: delta snapshots of
quantized entity records, the client's input packet and a reliable match
notice. SnapshotSender builds each client's snapshot against the newest one
it acknowledged, tells it only about entities near the player it is watching,
and keeps every snapshot under 1,200 bytes, nearest first, with a staleness
bonus so nothing starves. SnapshotReceiver rebuilds the picture, ignores old
and repeated snapshots and asks for a fresh start if it is ever sent a delta
on something it doesn't hold.
NetGame joins the transport to the match: people who connect become
participants, their inputs go through ServerLoop.submit() once per tick, and
snapshots go out 20 times a second. `--server --listen` makes the headless
server take network players and wait in the lobby for the first of them.
Measured by test on a 24-player match start with every player a client, a
tenth of packets lost and late acknowledgements: 2.4 KB/s mean and 2.5 KB/s
for the worst client, packet headers included, against a 40 KB/s limit.
Closes#33
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`make bot-matches` failed on its default seeds because its difficulty checks
(easy places worst, hard takes the most eliminations) are noisier than the
differences they look for over 20 matches.
Measured on three 20-seed batches (seeds 1-20, 21-40, 101-120): easy bots won
0, 4 and 2 matches against an even share of 6.7, and took the fewest
eliminations every time. Mean place doesn't separate the levels, and hard is
not reliably ahead of normal by any whole-match measure.
The batch now checks that easy bots win less than an even share and take the
fewest eliminations, and skips the difficulty checks under 20 matches, where
they mean nothing. Hard against easy stays covered by the duel test.
Closes#76
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ENet over UDP, used directly through ENetConnection, with a handshake before a
connection counts as a player.
- NetProtocol: HELLO, WELCOME and REJECT layouts, the protocol version, name
cleaning, the reasons a connection ends and a sentence for the player about
each. Decoders return nothing for malformed input and never raise an error.
- NetServer: listens, takes each guest through the handshake, and reports
joined, left and refused. It refuses a different protocol version, a full
server, a malformed HELLO and a guest that stays silent, each with its own
reason. Handles are never reused; duplicate names get a number.
- NetClient: connects, introduces itself, and ends up joined or closed with a
reason. Leaving says goodbye so the server knows at once; a client that
vanishes is dropped by ENet's timeout.
- Tests run a real server and clients over loopback UDP, with bare ENet peers
sending malformed and random packets.
The headless server doesn't listen yet; N2 connects this to the match.
Closes#32
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`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>
BotBrain plays a match with the commands a player sends: it picks a landing
marker near the barge's route, loots points of interest (following their own
walking routes into huts, lofts and piers), fights opponents it can see,
bandages itself, and gets to ground the coming tide will leave dry. BotWorld
is the map every bot shares: loot markers, routes, and each tide phase's safe
ground, which is the dry land joined to the island's highest walkable ground.
Three difficulties (Tuning.BOT_DIFFICULTIES) set reaction time, sight range
and aim error. The server mixes them unless --bot-difficulty says otherwise.
NavGrid labels connected regions when it is built, so a goal that is cut off
is turned down without a search of the whole island (about 70 ms each).
make bot-matches plays 20 bot-only matches and checks winners, drownings and
difficulty. Seeds 101 to 120: 20 of 20 with a winner, 7 of 460 deaths were
drownings (1.5%), easy bots placed worst (13.7 against 11.8 and 12.0) and
hard bots took the most eliminations (186 against 137 and 132).
Closes#28
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
The simulation now names what ended each player: weapon, fall, drown or tide, from
the cause of the blow that took the last health. Hits carry the weapon's item code.
Match keeps a kill feed (eliminator, cause, weapon, tick), per-player stats (damage
dealt and taken between opponents, eliminations, never teammates), and a summary()
with place, eliminations, damage and survival time. Players who fall on the same
tick share the better place and are marked tied. When the last players fall
together, the tie-break raises one team to first and the rest share the next place.
Eliminated players spectate: first whoever knocked them out, then a living
teammate, then the next living player in join order. When a target falls or
leaves, the view follows its eliminator or moves on, on the same step. Spectators
can cycle forwards and back. In results everyone watches the winner.
The headless server logs every placement and the match summary.
Closes#26
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>