v0.8.2 — every district opens on a Depot, and the docs are pages now

A second-digit bump for a playtest read back against the save file. Nine questions
were asked of one three-Day game; three were bugs, three were the rules working
and undocumented, three were decisions. Every save on the test server was replayed
against this build BEFORE release, which is how the cost of each rule was known
before it was chosen rather than discovered after.

EVERY DISTRICT OPENS ON A DEPOT. A Whistle Post has one A/D track and is not a
Passenger Facility, so the opening of every game was spent unable to work a
passenger and one arrival away from a collision. Two A/D tracks and passengers
from Stage 1 now; "Players start with Whistle Posts, not Depots" is the harder
game, set when the game is created. The deck follows the choice — starting on
Depots the four Depot upgrade cards are left out, because an upgrade must be to
the next tier and a Depot card at a table of Depots is a dead draw. How much
easier it is showed up as a test failure rather than an argument: the cue-coverage
pool needed widening from 24 seeded games to 60 before it held one collision.

NO SAVE WAS STRANDED BY IT, which took care. This is the one house rule that
changes how a game is DEALT rather than how it plays, so replaying a save under
the wrong opening is a different railroad from intent one — silently, with no
error. `withSavedOpening` fills it on the replay paths ONLY. Putting it in the
resolver instead made a fresh Cutthroat game deal Whistle Posts and read as
Custom, which is how the distinction was found.

THREE BUGS, ALL REPORTED FROM ONE GAME AND ALL CONFIRMED ON ITS SAVE.

An Office held TWO TRAINS ON ONE A/D TRACK. The capacity test passed with nothing
standing, the train the Interlocking had been holding at the Limits was moved into
the free slot, and the arriving train was pushed in after it without anyone asking
again whether there was room — so the collision §8.3 calls for never happened. The
held train keeps priority; the newcomer now takes the consequence it would have
met had the held train arrived first.

THE HISTORY FROZE, permanently, and the log cap was not really the cause. Each
seat's "what have I sent you" bookmark was an INDEX into an array the game trims,
so once a seat's bookmark reached the limit the slice returned nothing for the
rest of the game — at a different moment per seat, because each holds its own.
That game's log ended at exactly the cap. Lines carry a sequence number now, which
survives trimming; proven by pushing twice the cap through a simulated seat.

§8.1 ASKED THE WRONG QUESTION TWICE. "Trains may pass" returned `clear` before the
Subdivision was looked at, so a train entering a Double Track was released however
busy the rest of it was — that, not anything about Control Points, is what let
Train 8 out with no ruling. And a train standing at an Office was invisible to the
scan, so one about to re-enter the very Subdivision being entered counted for
nothing. Capacity is the test, not presence: a Depot with a track free is not in
the way; a Whistle Post with its one track taken is.

THINGS THAT HAPPENED SILENTLY NOW SAY SO — a train held against a facing one, a
train released from the Limits (a side effect of somebody else's arrival, so it
simply appeared at the Office), and the train an Interlocking is holding, whose
explanatory tooltip has existed since #99 with NO renderer ever reading the flag.

WHERE A MOVE IS REFUSED, AND WHY. `exploreMoves` decides where the rails go and the
pick-up restrictions are enforced afterwards in `check`, so a square the rails
reached and the card forbade was reachable, un-offered, and absent from the block
list with nothing said. Those squares are blocked with the rule that blocks them
now, and the reasons are got by ASKING `check` rather than re-deriving: a second
implementation of the rules is exactly the failure the block list exists to avoid.
A train may also always recover its own caboose — X13 prints "may drop but not
pick up anything", and a train needs its caboose to be made up, so one that parted
with it could never legally leave again.

RULES DECIDED IN SEPTEMBER AND APPLIED HERE. A Modifier must sit square against its
host, no diagonals. A passenger Modifier may not be played at a Whistle Post. Both
were built, measured, held back for a fortnight so a playtest could finish, and
applied now. A Second Section costs its card: `SECOND_SECTION` was declared in
content.ts and never dealt, so the action was free and the bot ordered 26
accidental ones in a measured round. The card is dealt and spent — gating on a card
the deck never holds would have deleted the mechanic rather than fixed it.

THE DOCUMENTATION IS A SET OF PAGES, not five text files served as text/plain — a
card reference is mostly tables, and as plain text a table is rows of pipes.
Markdown is still the one copy; the build renders it, and publishes the .md beside
each page. No Markdown library: this project has no runtime dependencies and one
would be a poor first. The pages add what Markdown cannot carry without drifting —
a nav across the set, a contents list built from the headings actually rendered,
an anchor on every heading, a 70-character measure, and tables that are tables.
They print as ink on paper.

The references caught up with the rules, checked rather than assumed: two
statements had gone from stale to misleading (the Quickstart told a new player to
"get a Depot down as soon as one appears"), and four rules nobody could look up
are written down — the Office tier table, §8.1 in practice, what the Circus Train
pays for, and that a Realignment can be a card with no legal target.

Adding one card to the deck reshuffles every seeded deal, which broke five
fixtures. Each was a seed meaning "a game like this" — TODO #84, exactly — so
seeds moved and pools widened rather than assertions weakening, and the clearance
fixture pins its terrain the way `enhancements.test.ts` already does. The three
published replays were re-recorded.

Closes TODO #40, #42a, #108, #109 and #110.

1046 fast tests and 35 sim tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MUizFYCMHRWhbWwXhp7WPR
This commit is contained in:
Jesse.Markowitz
2026-09-23 07:07:21 -04:00
co-authored by Claude Opus 5
parent 517238a727
commit 3befc420da
66 changed files with 6828 additions and 3324 deletions
+47 -31
View File
@@ -14,6 +14,9 @@ import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync,
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { DOC_PAGES, docPage } from './docs-page.ts';
import { renderMarkdown } from './markdown.ts';
const root = join(dirname(fileURLToPath(import.meta.url)), '..');
/**
* Overridable so a test can point the build at an isolated directory instead of the shared
@@ -189,41 +192,46 @@ if (existsSync(imageSrc)) {
}
/**
* The player-facing documentation, published beside the game so a tester can reach it from the box.
* The player-facing documentation, RENDERED and published beside the game.
*
* COPIED, NOT RE-WRITTEN. The Markdown in `docs/` is the one copy; a hand-written HTML twin would
* drift from it on the first edit, which is the whole lesson of TODO #15a and of the 2026-09-20
* documentation pass that found four references a month out of date.
* MARKDOWN IS STILL THE ONE COPY. `docs/*.md` is what is written and reviewed; this turns it into
* a page at build time. A hand-written HTML twin would drift from it on the first edit, which is
* the whole lesson of TODO #15a and of the documentation pass that found four references a month
* out of date.
*
* THE WHOLE SET, NOT ONLY THE QUICKSTART. v0.8.0.16 published the guide alone, and the guide's own
* §8 "Where to read more" links five further documents by relative path — so every one of them
* 404'd on the package (verified on the box: 5 of 6 paths missing). Publishing the guide without
* what it points at is the same broken-link failure the test below was written to catch, one hop
* further out. The names are kept exactly as the guide writes them, because those links are what
* has to resolve.
* WHY RENDER AT ALL. They were served as `text/plain`, which is honest and unreadable: a card
* reference is mostly tables, and as plain text a table is rows of pipes. That was TODO #109, taken
* deliberately as the short version to get the references in front of testers for one round.
*
* SERVED AS PLAIN TEXT for now, which is honest rather than good: tables render as pipes and the
* links do not click. Rendering them into styled pages needs a small Markdown converter and is
* filed as TODO #109 — this is the version that gets the references in front of testers for this
* round rather than leaving them without any.
* NO MARKDOWN LIBRARY. `scripts/markdown.ts` covers the subset these five documents use, and this
* project has no runtime dependencies at all — one would be a poor first.
*
* PUBLISHED UNDER THEIR OWN NAMES, which since v0.8.0.17 carry no version: the documents are kept
* current with every release rather than published as editions, so `docs/rules.md` is served as
* `rules.md` and the splash page and the This Game card link it by that name. Four of them were
* `StationMaster-<name>-v0.4.5.md` until then — the prototype edition they were first written
* against, never the version they described.
* THE `.md` IS PUBLISHED TOO, beside the page. It costs nothing, it is what a reader who wants the
* source or a diff actually wants, and it keeps every link that was handed out while the documents
* were served as text working rather than 404ing.
*/
const GUIDE_DOCS: readonly string[] = [
'quickstart.md',
'rules.md',
'home-deck.md',
'mainline-deck.md',
'components.md',
// Generated by `build:cards` and checked in; a test fails when it disagrees with the code, which
// is why it is the one reference that has never drifted. Its `rules/` directory is preserved
// because that is the path the Quickstart links it by.
'rules/as-built.md',
];
const GUIDE_DOCS: readonly string[] = DOC_PAGES.map((d) => `${d.slug}.md`);
/** `rules.md` → `rules.html`, so a link between documents lands on the rendered page. */
const docLink = (href: string): string =>
/^https?:/.test(href) || href.startsWith('#') ? href : href.replace(/\.md(#|$)/, '.html$1');
/**
* The title and version line, lifted out of the Markdown body.
*
* The documents open with `# Title` then `**Version x.y.z** · date`, and the page draws both in its
* own header — so rendering them again in the body would print each twice. Taken by pattern rather
* than by line count, and the body is only trimmed where the pattern actually matched.
*/
function splitHead(src: string): { title: string; version: string; body: string } {
const m = /^#\s+(.+?)\n+\*\*Version\s+([^*]+)\*\*\s*·\s*([^\n]+)\n/.exec(src);
if (!m) return { title: 'Station Master', version: '', body: src };
return {
title: m[1]!.replace(/^Station Master\s*[—-]\s*/, '').trim(),
version: `<b>Version ${m[2]!.trim()}</b> · ${m[3]!.trim()}`,
body: src.slice(m[0].length),
};
}
for (const rel of GUIDE_DOCS) {
const src = join(root, 'docs', rel);
@@ -233,9 +241,17 @@ for (const rel of GUIDE_DOCS) {
console.error(`WARNING: docs/${rel} is missing — a published link will 404`);
continue;
}
const md = readFileSync(src, 'utf8');
const out = join(dist, rel);
mkdirSync(dirname(out), { recursive: true });
copyFileSync(src, out);
writeFileSync(out, md);
const { title, version, body } = splitHead(md);
const { html, headings } = renderMarkdown(body, docLink);
writeFileSync(
join(dist, rel.replace(/\.md$/, '.html')),
docPage({ slug: rel.replace(/\.md$/, ''), title, version, body: html, headings }),
);
}
// A tiny note for whoever unzips this later and wonders what it needs.