Fix parking trains, freight deadlock, and Whistle Post lock-in

This commit is contained in:
Jesse
2026-07-31 15:09:16 -04:00
parent b085d5a0bb
commit d261ad7af8
15 changed files with 577 additions and 121 deletions
+31
View File
@@ -287,3 +287,34 @@ describe('switching accomplishes something (regression)', () => {
assert.ok(moves < 60, `${moves.toFixed(0)} Moves per game suggests aimless shuttling`);
});
});
describe('measurement discipline', () => {
it('the observer sees exactly the events the log records', () => {
// REGRESSION, against a measurement bug rather than a game bug. Events reach the log from TWO
// sources — the phase driver (`pump`) and player intents (`applyIntent`). An ad-hoc probe that
// watched only the first reported "60 of 60 games never upgraded past Whistle Post" while the
// Office tier histogram from the same run plainly showed Depots, Stations and Terminals.
//
// A wrong measurement is worse than a missing one: it gets believed and acted on. This asserts
// the observer hook cannot drift from the log, so probes have one trustworthy way in and no
// reason to hand-roll the drive loop again.
const seen: string[] = [];
const s = createGame({ id: 'obs', seed: 4242, config: { ...config, length: 'standard' }, playerNames: ['b'] });
const out = playGame(s, developerBot, pump, 50_000, (e) => seen.push(e.type));
assert.ok(out.events.length > 0, 'a finished game must produce events');
assert.deepEqual(seen, out.events.map((e) => e.type));
});
it('records office upgrades where a probe can actually find them', () => {
// The upgrade arrives via applyIntent, not pump — the exact branch the broken probe missed.
// Asserted across several seeds because a single game may never draw a Depot card.
let upgrades = 0;
for (let seed = 0; seed < 25; seed++) {
const s = createGame({ id: `u${seed}`, seed, config: { ...config, length: 'standard' }, playerNames: ['b'] });
const out = playGame(s, developerBot, pump);
upgrades += out.events.filter((e) => e.type === 'officeUpgraded').length;
}
assert.ok(upgrades > 0, 'no office upgrade was visible in the event log across 25 games');
});
});