Plans: the server runs every multiplayer game, at 1x with a speed vote
Some checks are pending
CI / test 1/4 (push) Waiting to run
CI / test 2/4 (push) Waiting to run
CI / test 3/4 (push) Waiting to run
CI / test 4/4 (push) Waiting to run
CI / build (push) Waiting to run
CI / test (push) Blocked by required conditions
CI / translations (push) Waiting to run

This commit is contained in:
jvanvik 2026-11-07 06:55:24 +01:00
parent fbae6fc3ed
commit 3bc1641a46

View file

@ -12,33 +12,21 @@ planned or known, not built.
## Next features
3. **Wave B starts with a shared session clock.** Proposed on 2026-11-07, not decided yet: it changes how every
multiplayer game plays. Today each player's game runs in their own browser at their own speed (pause, 0.5× to 8×), so
players in one session are on different days. The proposal: the server keeps the time and every game in the session
follows it. The simulation stays in the browser.
- **Server:** a session gets a pace when it is created: one game day every 30 s to 5 min (agent mode's list). Never the
normal 2.5 s, which is 1,440 game days an hour. The day only moves while at least one player was seen recently (the
roster already keeps `seen`), so nobody comes back to years of unattended play. Every roster answer carries the
server's time and the session day.
- **Browser:** the clock is locked to the session. `UI.clockLocked` and `HOOKS.speed()` (`50-state.js`) already hide
the speed buttons and refuse pause, and `save()` already leaves `uiSpeed` alone while locked. The code goes in
`src/game/`, because `src/agent/` does not ship (ADR 0004), so it needs its own copy of agent mode's worker ticker
(`src/agent/85-ticker.js`) to keep time in hidden tabs. Agent mode also sets `HOOKS.speed`: the session wins, and
agent mode is off in a multiplayer game.
- **Catching up:** a game behind the session day runs days until it matches, a few per frame, with its progress
shown. It needs its own loop: with the route worker, `runClock` holds one day at a time. A day takes about 30 ms on
the big test network, so 400 missed days take about 12 s on a desktop and longer on phones. Late joiners start on
the session's current day (to check: what in the world depends on the day a game started).
- **Nobody can pause or speed up.** That is what "the same day" means.
- **Later, optional: the server plays absent players.** It opens an offline player's save in a headless game (jsdom,
as `scripts/lib/mcp-game.js` already does with its realtime clock) and runs their days with the intern. The
browser takes the save back on return through phase 1's save numbers, so the server is just one more device. Up to
about 0.5 GB of RAM per absent player. Without it, other players see an absent network stand still.
- **Not proposed: a server that runs every game** with the browser only showing it. Every click would be a round
trip, and the page reads `S` and `R` directly everywhere, so it would be a rewrite. Its one gain over the above is
verified cards (today the server trusts them).
- **Phase 2 gets simpler:** its wall-clock timing (tenders that close after 10 real minutes, `idle` ≥ 300 s, notice on
each player's own clock, the soak test's "own speed") can move to game days.
3. **The server runs every game of a multiplayer build** (decided 2026-11-07, being designed and built). In a page built
with `MP_API`, each network's days run on the session server, not in the browser, so every player of a session is on
the same day at the same speed. A single-player game in that build is a session of one and runs there too; old local
saves keep working in the browser, and the plain build stays exactly as it is (static, no server, no requests).
- **Speed:** 1× by default (one day per `DAY_MS`, 2.5 s). Players vote for another speed, pause included; alone in a
session your vote decides at once. The world pauses while no player is connected.
- **Absent players:** while anyone plays, the networks of those away keep running on the server (their intern's
standing orders help), so nobody falls behind.
- **Why:** the same day for everyone, which phase 2's trades need, and less work for phones at higher speeds (at 1× the
day is about 10–15% of a phone's CPU on the big test network, at 8× about half; map and panels stay in the browser).
- **What stays in the browser:** map drawing and panels. The flow tables (`R.ef`/`R.fl`, about 3 MB per routing on the
big network) cannot be shipped every day, so what reads them (a selected link on the map, the link panel, PNI value,
puzzles) has to ask for them.
- **Phase 2 gets simpler:** with every world in one server process, its wall-clock timing (tenders that close after 10
real minutes, `idle` ≥ 300 s, notice on each player's own clock) can move to game days.
4. **Wave B: #97 co-op companies** (several players run one network with roles, budgets and approvals), host-authoritative
over the multiplayer server, and **multiplayer phase 2** (players as carriers in each other's simulations: transit,
peering, PNIs, shared fiber): design in `docs/plans/multiplayer-phase2.md`.
@ -75,7 +63,5 @@ planned or known, not built.
## Housekeeping
- `npm run perf -- --browser` needs Chromium (`sudo pacman -S chromium`, then `PERF_CHROME=/usr/bin/chromium`); only the
jsdom benchmark has been run.
- Upstream release tags are not on `vanvik` yet: `git push vanvik --tags` if wanted.
- `npm run perf -- --browser` runs with `PERF_CHROME=/usr/bin/chromium`.
- The merged worktrees under `.claude/worktrees/` and their `worktree-wf_*` branches can be removed.