make turnout description more clear. fix curves from breaking running track.

This commit is contained in:
Jesse
2026-08-05 10:03:50 -04:00
parent 9c76b1a5e2
commit 1c321d4cea
9 changed files with 226 additions and 28 deletions
+6
View File
@@ -50,6 +50,7 @@ import type { Occupancy, Port } from './track.ts';
import {
canDropCarsAt,
canPlaceAt,
carriesThroughTrack,
facilityVariants,
opposite,
reachableDestinations,
@@ -590,6 +591,11 @@ function checkPlay(
{
const proto = protoCard(card.kind, variant);
if (!proto) return 'NO_PLACEMENT';
// Said separately from NOT_CONNECTED because it is a different mistake: the card would join
// perfectly well, and would still leave the Running Track stopping dead at it.
if (placement.row === area.runningRow && !carriesThroughTrack(proto)) {
return 'BREAKS_RUNNING_TRACK';
}
return canPlaceAt(area, placement, proto) ? null : 'NOT_CONNECTED';
}
+2
View File
@@ -115,6 +115,8 @@ export type RejectionCode =
| 'FACILITY_LOCKED'
/** An Industry goes on a straight stub, never on the Running Track (sheet: "Placed" column). */
| 'ON_RUNNING_TRACK'
/** A card with no east-west road would dead-end the Running Track it was laid in. */
| 'BREAKS_RUNNING_TRACK'
| 'NOT_IMPLEMENTED'
| 'WRONG_INTENT'
| 'NOT_A_GRADE'
+18
View File
@@ -406,6 +406,20 @@ export function allReachable(
// Placement
// ---------------------------------------------------------------------------
/**
* Does this card carry the through route — an east-west road straight across it?
*
* The Running Track is the road trains run on, Limits to Limits, and every card standing in it has
* to pass traffic along the row. A curve does not: it has one road, from an east or west edge round
* to a 45° leg, and dropping one into the running row DEAD-ENDS the main there. Straights, turnouts,
* Limits signs, the Office and industries all carry it.
*/
export function carriesThroughTrack(card: TrackCard): boolean {
return connectionsFor(card).some(
([a, b]) => (a === 'e' && b === 'w') || (a === 'w' && b === 'e'),
);
}
/**
* Gap 4a — a placed card must connect to existing track, and "connect" means `joins`: ports meeting
* AND, on a north or south edge, 45° legs on the same diagonal.
@@ -433,6 +447,10 @@ export function canPlaceAt(area: OfficeArea, coord: GridCoord, card: TrackCard):
// with a Limits card stranded mid-track. The district below the Running Track is unbounded.
if (coord.row === area.runningRow) {
if (coord.col < area.limitsWest.col || coord.col > area.limitsEast.col) return false;
// And it must not BREAK the Running Track. A curve laid here has no east-west road, so the main
// stops dead at it — the bot did exactly this, turning the west end of its own Running Track
// into a stub and cutting the Office off from the Limits.
if (!carriesThroughTrack(card)) return false;
}
const ports: Port[] = ['n', 's', 'e', 'w'];