From 040e25faab8ac818caaa5e3b7ee303b3612686f3 Mon Sep 17 00:00:00 2001 From: jvanvik Date: Sat, 7 Nov 2026 05:06:17 +0100 Subject: [PATCH] Plans: propose a shared session clock for multiplayer --- docs/plans/multiplayer-phase2.md | 4 ++++ docs/plans/next-session.md | 31 +++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/docs/plans/multiplayer-phase2.md b/docs/plans/multiplayer-phase2.md index 346e1c7..ab739aa 100644 --- a/docs/plans/multiplayer-phase2.md +++ b/docs/plans/multiplayer-phase2.md @@ -2,6 +2,10 @@ Status: design only, not built. Phase 1 (sessions, server-side saves, leaderboard) is in `docs/MULTIPLAYER.md`. +Clock: this design assumes each player's game keeps its own time. A shared session clock is proposed in +`docs/plans/next-session.md` (item 3). If it is adopted, the parts timed in real minutes or on each player's own clock +(tenders, `idle`, notice, the soak test) move to game days. + **Conventions:** - Line numbers are `main` at `1e7638c`. - Phase 1 (multiplayer sessions, merged on `main`) provides `S.mp`, `MP`, `mpCard`/`mpCardOk`, and `cleanCard` in `scripts/lib/mp.js`. diff --git a/docs/plans/next-session.md b/docs/plans/next-session.md index deaef46..b46aeb6 100644 --- a/docs/plans/next-session.md +++ b/docs/plans/next-session.md @@ -19,10 +19,37 @@ planned or known, not built. ## Next features -3. **Wave B: #97 co-op companies** (several players run one network with roles, budgets and approvals), host-authoritative +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. +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`. -4. **Wave C: #144 directional traffic**, last and on its own: keep the totals, split them by traffic profile, utilization is +5. **Wave C: #144 directional traffic**, last and on its own: keep the totals, split them by traffic profile, utilization is the busier direction. It comes after #58 because both touch link capacity (express channels now count too). ## Known limitations of what shipped