v0.8.0.14 — the coaches that never come back, and a district that ends at its own sign

Six reports from the Day 2-3 playtest of v0.8.0.13.

GAMES IN PROGRESS DO NOT SURVIVE THIS ONE. Modifiers are now bounded by the
Limits, which makes a once-legal move illegal, so a save holding one is refused
at that move: whistle-6945.day3.stage10 stops at intent 528 of 539. Jesse's call,
knowing it strands the game on the box. The file is untouched and v0.8.0.13
still finishes it.

The Sparrow running empty and Tom unable to unload his passengers are the same
shortage from opposite ends, and both are the rules working as printed. §9.2
boarding discards the emptied coach into the CLASSIFICATION yard, detraining
draws a fresh empty out of the DIVISION yard, and §2.2 sends Classification back
only when the Division Yard runs bare — so coaches move one way. Measured over
the save: sixteen in the Division Yard at setup, zero from Day 2 Stage 8 to the
end, fifteen piled in Classification, the Division Yard steady at 46-47 freight
cars with no prospect of going bare. Jesse's ruling is Gitea#2's: the shortage
stays and the game says so. A train made up short now reports what its card
wanted and why none is coming (`makeUpShort` — `trainNeedingCars` answered null
for "done" and for "cannot be done" alike, so the phase moved on in silence); the
yard panel warns while the condition lasts; the Depot's blocked panel was right
all along.

The modifier outside the Limits was working as designed and the design was
Jesse's own call, now reversed. What decided it is what the board shows — a card
beyond your own sign, in territory §8.1 and §10 reason about. The case that
motivated the exemption was checked on the reported move rather than argued away:
the Power Plant sat at (-1,3) against a sign at column 3 and two spots inside
were free, legal and adjacent.

Switching filled the history with coordinates — a line per move, plus one per
mandatory coupling. It is still LOGGED in full; what the panel draws is the line
saying somebody switched, the first move, work at an INDUSTRY (named, not a
coordinate), the Small Yard sort, and a closing summary. The suppressed lines are
still WRITTEN, marked `trace`: dropping them outright was the first attempt and
the step-queue suite caught it, because dwellForStep pays nothing for a step that
said nothing, so the board stopped replaying switching at all. The last move
rides in the closing line rather than being kept in place — nothing knows a move
was the last until the turn is over, by which time the line has been streamed to
every client and cannot be revised. Two things fell out of reading those lines:
every move ended with a tutorial sentence the opener already gives, and the move
count said "of 6" with the six hardcoded, which is wrong on a night Stage.

Make-up lines name their train — they all read "the train being made up", so
looking back for train 10 found nothing under that name — and "a empty tank" is
now "an empty tank". The Small Yard's options read as the train they would build
instead of `[1,2,3,0]`; the one Jesse wanted was the first of five and unreadable.
Two of those five were junk: bringing the last car to the end is the identity and
would have spent a Move, and a two-car reversal duplicated its only real option.
Both are filtered by the resulting order, not by the case that made them.

A Small Yard may now put cars AHEAD of the engine, which was Jesse's own open
question. Two sources disagreed and the design notes won: the v0.4.5 card text
says the sort puts the engine at the nose, implications.md says "any order,
including cars ahead of the engine". `engineAt` is optional on the intent, so
older saves replay to the same train. The menu did not multiply — the engine is a
separate short list against the consist as it stands, eight options for a
four-car train rather than twenty. §8.2 needed no new code: badlyMadeUp is
deliberately direction-free, so a PUSHING train is fit to run and only a
broken-backed one is held. The button warns by asking that predicate rather than
copying it, and immediately earned itself — every one of train 10's eight options
is refused, the one asked for at the table included, because that train carries a
caboose and each sort moves it off the rear. That is the right answer rather than
a gap: the train is already made up, so every offer would break it, and the labels
say which is which. A made-up order is always on the menu for a train that needs
one, because "bring car k to the tail" is enumerated for every car and the caboose
is one of them.

Labels read WEST TO EAST, with the engine drawn as the board's own ◀ / ▶ arrow.
"Front to back" is not a direction a table can read — which end is the front
depends on which way the train points — and board-svg has reversed east-facing
consists since v0.8.0, so the button now describes the same train as the picture.

The Freight Agent, Porter and Laborer groups now say what the role is for, where
the role is chosen. Tom reached for the Freight Agent to detrain passengers,
which is a Porter's action in the Cargo phase; both halves were working and
neither was visible.

TODO closes #107 (the nose sort) and gains #108 (the coach ratchet, with the
measurement, to revisit on a second game's data).

999 fast tests and 35 sim tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmdqqCNoiqE7GBo6wthBnR
This commit is contained in:
Jesse.Markowitz
2026-09-17 20:49:31 -04:00
co-authored by Claude Opus 5
parent ad277fb994
commit a6657241de
23 changed files with 1367 additions and 69 deletions
+161
View File
@@ -12,6 +12,9 @@ import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { applyIntent, areaOf, check } from '../src/engine/apply.ts';
import { legalActions } from '../src/engine/legal.ts';
import { describeIntent } from '../src/sim/view.ts';
import { badlyMadeUp } from '../src/engine/advance.ts';
import { createGame } from '../src/engine/setup.ts';
import type { CrewTray, GameConfig, GameState, GridCoord, RollingStock, TrackArc, TrackCard } from '../src/engine/state.ts';
import { carsOn, coordKey, turnOf } from '../src/engine/state.ts';
@@ -461,3 +464,161 @@ describe('a 45° leg is part of the west-to-east row, not outside it (Gitea#17)'
assert.deepEqual(standingAt(s, at(1, 0)), [], 'the cars should have come off the card');
});
});
// ---------------------------------------------------------------------------
/**
* The Small Yard's re-order menu, reported from Day 3 of the 2026-09-17 playtest.
*
* Jesse had train 10 on his Small Yard — nose first, `[loaded boxcar, loaded hopper, empty tank,
* caboose]` — wanted the boxcar on the tail, and could not tell which button did it: every option
* read `re-order consist [1,2,3,0]`, the engine's own array indices offered to a person. The move he
* wanted was the FIRST of the five. One of the other four re-ordered nothing at all and would still
* have spent one of his six Moves.
*/
describe('the Small Yard says what each re-order would build', () => {
const smallYard = (standing: RollingStock[] = []): TrackCard => ({
...straight(standing),
enhancements: ['smallYard'],
});
/** Train 10's consist as it actually stood, on a card carrying a Small Yard. */
const onTheYard = (): { s: GameState; trayId: string } => {
const s = game();
row(s, 3);
addCard(s, at(1, 1), smallYard());
const trayId = placeTray(s, at(1, 1), [car('boxcar', true), car('hopper', true), car('tank'), car('caboose', true)], 'e');
switching(s);
return { s, trayId };
};
it('never offers a sort that changes nothing', () => {
/**
* THE PAIR IS WHAT COUNTS, since the engine position became part of a sort (2026-09-17). The
* identity car order is now a perfectly good option when it moves the ENGINE — that is the whole
* of the separate engine control — so what must never be offered is the pair that reproduces the
* train already standing there, and no pair may appear twice.
*/
const { s, trayId } = onTheYard();
const tray = s.trays.get(trayId)!;
const offered = legalActions(s, 0)
.filter((i) => i.type === 'switch.sortConsist')
.map((i) => {
const sort = i as { order: number[]; engineAt?: number };
return `${sort.order.join(',')}|${sort.engineAt ?? 0}`;
});
assert.ok(offered.length > 0, 'no sort was offered at all, so this proved nothing');
const unchanged = `${[...tray.consist.keys()].join(',')}|${tray.engineAt}`;
assert.ok(
!offered.includes(unchanged),
'the menu offered the train as it already stands — a Move spent to change nothing',
);
assert.equal(new Set(offered).size, offered.length, 'the menu offered the same sort twice');
});
it('offers the engine every position, including ahead of its own cars', () => {
// Jesse's ruling, 2026-09-17, following `implications.md` against the v0.4.5 card text: a train
// in a Small Yard "may sort itself into any order, INCLUDING cars ahead of the engine".
const { s, trayId } = onTheYard();
const n = s.trays.get(trayId)!.consist.length;
const positions = legalActions(s, 0)
.filter((i) => i.type === 'switch.sortConsist')
.map((i) => (i as { engineAt?: number }).engineAt ?? 0);
for (let k = 1; k <= n; k++) {
assert.ok(positions.includes(k), `the engine was never offered position ${k} of ${n}`);
}
});
it('always offers a made-up order to a train that is not in one', () => {
/**
* Jesse, 2026-09-17: "trains with a caboose have to offer the caboose at the back… sorting all
* the cars back in, ready to leave the station."
*
* A train with its caboose mid-consist is one §8.2 will not let out of the Office, so at least
* one offer has to put it right. It comes out of the ordinary curated set — "bring car k to the
* tail" is enumerated for every car, and the caboose is one of them.
*/
const s = game();
row(s, 3);
addCard(s, at(1, 1), smallYard());
const trayId = placeTray(s, at(1, 1), [car('boxcar', true), car('caboose', true), car('hopper', true)], 'e');
const tray = s.trays.get(trayId)!;
tray.trainNumber = 10;
switching(s);
const fit = legalActions(s, 0)
.filter((i) => i.type === 'switch.sortConsist')
.filter((i) => {
const sort = i as { order: number[]; engineAt?: number };
const after = sort.order.map((n) => tray.consist[n]!);
return badlyMadeUp({ ...tray, consist: after, engineAt: sort.engineAt ?? 0 }) === null;
});
assert.ok(
fit.length > 0,
'a train that cannot leave the Office was offered no sort that would make it up',
);
// And the one that does it says so on the button, rather than leaving it to be discovered.
assert.ok(
fit.some((i) => describeIntent(s, i).includes('MADE UP, ready to leave')),
'the sort that makes the train up does not say so',
);
});
it('lays the train out west to east, with the engine where it will be', () => {
/**
* "You specify above that the order is front to back, but on the screen, if it's eastbound or
* westbound, it may look different" — Jesse, 2026-09-17.
*
* `board-svg.ts` draws the crew strip west on the left, reversing a consist for an east-facing
* train so its nose lands at the east end. The button has to read the same way or it describes a
* different train from the one on the board.
*/
const s = game();
row(s, 3);
addCard(s, at(1, 1), smallYard());
// Engine points WEST: the consist is stored nose first, so west to east reads engine first.
const west = placeTray(s, at(1, 1), [car('boxcar', true), car('hopper', true)], 'w');
switching(s);
const westLabel = legalActions(s, 0)
.filter((i) => i.type === 'switch.sortConsist')
.map((i) => describeIntent(s, i))
.find((l) => l.startsWith('re-order'));
assert.ok(westLabel, 'no re-order was offered for the west-facing train');
assert.match(westLabel, /west to east: ◀ ENGINE · /, `a west-facing engine was not drawn leading: ${westLabel}`);
// The same train pointing EAST puts the engine at the far end of the same sentence.
s.trays.get(west)!.railFacing = 'e';
s.trays.get(west)!.facing = 'e';
const eastLabel = legalActions(s, 0)
.filter((i) => i.type === 'switch.sortConsist')
.map((i) => describeIntent(s, i))
.find((l) => l.startsWith('re-order'));
assert.ok(eastLabel, 'no re-order was offered for the east-facing train');
assert.match(eastLabel, / · ENGINE ▶($| ·)/, `an east-facing engine was not drawn at the east end: ${eastLabel}`);
});
it('labels each option with the train it would make, not with array indices', () => {
const { s } = onTheYard();
const labels = legalActions(s, 0)
.filter((i) => i.type === 'switch.sortConsist')
.map((i) => describeIntent(s, i));
assert.ok(
labels.every((l) => !/\[\d(,\d)*\]/.test(l)),
`a re-order option still reads as a permutation: ${labels.find((l) => /\[\d(,\d)*\]/.test(l))}`,
);
/**
* The one Jesse wanted, written the way the board draws it: this crew faces EAST, so the strip
* runs west to east and the engine sits at the east end with the boxcar now furthest west.
*/
assert.ok(
labels.includes('re-order — west to east: loaded boxcar · caboose · empty tank · loaded hopper · ENGINE ▶'),
`the move that puts the boxcar on the tail was not offered in words — got: ${labels.join(' | ')}`,
);
// And the engine's own positions read as what they do, not as an index.
assert.ok(
labels.some((l) => l.startsWith('put the whole consist ahead of the engine —')),
`the shoving sort was not offered in words — got: ${labels.join(' | ')}`,
);
});
});