v0.7.4 — Red Flags hold a train out of your Limits (Gitea#19)

"If played, asked FLAG EAST or FLAG WEST. That stops all trains from entering your
limits from that direction (i.e. Flag East holds westbound trains). You can do this
if you see a problem or wish to complete switching."

REPLACES the old rule outright, per Jesse's call. Red Flags used to be played on a
stopped train out on the Mainline and protected it from a rear-ender: offered 4,212
times and played 4 across 600 games, a mechanic nobody used, and ABS Signals already
does that job better. The flag is now planted on one side of your own district and
holds the next train arriving from that side.

SPENT ON THE TRAIN IT STOPS. One card, one train, so there is no lifting action to
build, nothing to forget, and a flag cannot quietly strangle the Division. The held
train loses one Mainline Phase and comes in on the next — it buys a Stage to clear
the lead, which is what "wish to complete switching" asks for.

PLAYABLE OUT OF PHASE, which is the other half of the issue: when an arrival would
certainly collide and the district's owner holds the card, the phase breaks in and
asks. Offered ONLY to somebody holding one — a prompt with a single button is not a
choice, and it would leak that a collision is coming. The danger is read from §8.3's
own two triggers rather than restated, so the prompt cannot offer a flag against a
collision that will not happen.

Built on the decision union Gitea#5 introduced: this adds a `redFlag` case and
nothing else structural.

THE BOT STILL NEVER PLAYS IT, AND I MEASURED RATHER THAN ASSUMED. It now takes the
out-of-phase prompt unconditionally — the engine has already established the danger,
so there is nothing left to judge — and over 200 solitaire games `redFlagsSet` fires
ZERO times. The prompt needs an arrival that would collide (0.14 per game, about one
game in seven) to coincide with holding the card from a three-card hand out of 121.
So the anomaly exemption in sim.test.ts stays, but its comment no longer claims the
bot is unwilling: it is measuring deck luck. What is left to fix is the half of the
card a human would use, planting a flag on purpose to buy switching time, and TODO.md
now says that instead of the old finding.

A BUG WORTH RECORDING, because the next interruption will meet it too: the flag was
originally taken down in a `reduce` case, which never fires for an event advance.ts
emits — the phase driver mutates state and then describes it. The flag stayed up and
held every train that came. test/events.test.ts's unreduced-event registry is what
makes that class of mistake visible, and `redFlagSpent` is on it deliberately now,
with the reasoning.

858 tests pass.

Closes #19

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EAgJSmeV8zrMh55Mj85ESb
This commit is contained in:
Jesse.Markowitz
2026-08-29 07:12:36 -04:00
co-authored by Claude Opus 5
parent 228027637b
commit 19a6a47ab6
16 changed files with 550 additions and 124 deletions
+20 -12
View File
@@ -363,21 +363,29 @@ describe('end-of-game statistics', () => {
* and so removing this line is what proves the bot has been fixed.
*/
/**
* RED FLAGS JOINS IT (Gitea#3), and for the same reason — the rule is reachable and the bot will
* not take it.
* RED FLAGS JOINS IT, and the reason CHANGED with Gitea#19 — the exemption stays, but it no
* longer means what it used to.
*
* MEASURED over 600 games: `maneuver.redFlags` is OFFERED 4,212 times, first in game 5 — so the
* rule is live and constantly available. The bot PLAYS it 4 times, first in game 252. At 200
* games this canary sees nothing and calls it unreachable, which is the opposite of the truth.
* IT USED TO MEAN "the bot will not take it": measured over 600 games under the old rule,
* `maneuver.redFlags` was OFFERED 4,212 times and PLAYED 4. The card protected a stopped train
* out on the Mainline, it was always available, and the bot simply declined it.
*
* It got rarer for two compounding reasons, neither of them a broken rule: Gitea#14 took Red
* Flags from 5 copies to the sheet's 3, and Gitea#3 shortened most crossings to a single Stage,
* so the window in which a train is STANDING on a Mainline card — the only place the card may be
* played — is now usually one Stage wide.
* SINCE Gitea#19 the bot would take it every time — `worthFlagging` accepts the out-of-phase
* prompt unconditionally, because the engine only raises that prompt when an arrival is
* certainly about to collide, so there is nothing left for the bot to judge. It still never
* plays one. MEASURED after the redesign, 200 solitaire games: `redFlagsSet` fires ZERO times.
*
* The bot's unwillingness is the thing worth fixing, and it is in TODO.md under Bot Performance.
* Exempted BY NAME so the other forty-odd checks stay live, and so deleting this line is what
* proves the bot has learned to use it.
* The reason is now arithmetic rather than judgement, and it is worth writing down because it
* says what would actually change it. The prompt needs two things to coincide — an arrival that
* would collide (0.14 collisions per game, so roughly one game in seven) AND the district's
* owner holding a Red Flags card at that moment, out of a three-card hand drawn from 121. The
* bot also never plants a flag speculatively, which is the other half of the card and the half
* a human would use to buy time for switching.
*
* So this canary is measuring deck luck, not reachability. `test/mainline-cards.test.ts`
* exercises both halves of the rule end to end on a hand-built board, which is where the
* behaviour is actually pinned. Removing this line still proves something worth proving — that
* the bot has learned to plant a flag on purpose rather than only when handed one.
*/
const KNOWN_UNREACHABLE_BY_THE_BOT = ['event flyingSwitch', 'event redFlagsSet'];
const found = anomalies(report.perGame);