v0.7.2 — a leg that is part of the row, the deck the sheet prints, regions not miles per hour, and a Division you read left to right
Gitea#17 — a 45° leg is an end of the west-to-east row, so backing into a cut through a curve's south leg no longer couples it back to front. The same assumption left a crew's own cut standing when it pulled out through a leg, which is the "cars left behind" report we had failed to reproduce. Gitea#14 — every count is docs/Deck cards5.xlsx. Track halved, and the Q12 office doubling and Gap 12 industry tripling both come out with it: they were measured against a deck with twice the track, and keeping them at the sheet's track count wipes out the reefer chain entirely. 84 rows now match card for card; the ten Safety, Event and Inspection cards it adds are not built and are held out. Cards the sheet no longer lists are dealt zero copies rather than deleted, so their rules stay implemented. Gitea#15 — RAR reversed it: a rail may stop dead against its neighbour and the placement is legal. What must hold is that no train crosses the gap, which was already true and is now pinned against the reported board. Gitea#3 — the printed speeds are scenery. A card costs one Stage per printed region and where a train STARTS is what varies; Fast/Slow is read on Hilly alone. Entering a one-region card behind another is a collision now, which is what ABS exists to prevent, and ABS no longer holds trains silently. Gitea#18 — the Division draws as one row, west to east, with no office-area detail. East is finally always to the right. Closes #3 Closes #14 Closes #15 Closes #17 Closes #18
This commit is contained in:
+63
-6
@@ -188,6 +188,40 @@ export function joins(a: TrackCard, p: Port, b: TrackCard): boolean {
|
||||
return slopeAt(a, p) === slopeAt(b, opposite(p));
|
||||
}
|
||||
|
||||
/**
|
||||
* WHICH END OF THE WEST-TO-EAST ROW A PORT SITS AT.
|
||||
*
|
||||
* `TrackCard.standing` is ordered west to east (§A.3), so whether a train meets the row front to
|
||||
* back or back to front depends on which end it enters by — and a port is not always at one of
|
||||
* those two extremes. Every 45° leg leaves through the MIDDLE of its north or south edge, so its
|
||||
* end of the run is whichever end the arc does NOT reach: a `sw` curve's south leg is the EAST end
|
||||
* of the row, and an `se` curve's south leg is the WEST end. Same port, opposite answers, which is
|
||||
* why this has to ask the card rather than read the port.
|
||||
*
|
||||
* Gitea#17 is what both callers looked like without it. `exploreMoves` reversed the row for an 'e'
|
||||
* entry and for nothing else, so backing into a cut through a `sw` curve's south leg coupled it up
|
||||
* back to front — the caboose came out next to the engine, which §8.2 then calls badly made up.
|
||||
* `cutTowards` answered "you meet nothing" for a north or south exit, so a crew standing on a curve
|
||||
* pulled out through the leg and left the cars beside it standing, which §A.4 forbids.
|
||||
*
|
||||
* There is no north-south straight anywhere on the printed sheet (see the module comment), so a run
|
||||
* touching a 45° leg always has an east or west port at its other end and the answer is never
|
||||
* undefined. A TURNOUT is the one card whose row has three ends rather than two — and it is also
|
||||
* the one card no cut can ever stand on, since a train may not stop there (§A.1) and so never sets
|
||||
* anything out there. Its stem answers for it.
|
||||
*/
|
||||
export function rowEndAt(card: TrackCard, p: Port): 'e' | 'w' {
|
||||
if (p === 'e' || p === 'w') return p;
|
||||
for (const [a, b] of connectionsFor(card)) {
|
||||
const other = a === p ? b : b === p ? a : null;
|
||||
if (other === 'e') return 'w';
|
||||
if (other === 'w') return 'e';
|
||||
}
|
||||
// Not a card the printed sheet can produce. Reading the leg as the west end leaves the row in the
|
||||
// order it is stored rather than inventing a reversal on a card nothing knows the shape of.
|
||||
return 'w';
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Orientation (Gap 11)
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -450,7 +484,7 @@ export function exploreMoves(
|
||||
*
|
||||
* Ordered nearest-first like every other card's, so it simply seeds the accumulator.
|
||||
*/
|
||||
const ownCut = cutTowards(startCard, carsOn(startCard), initialExit);
|
||||
const ownCut = cutTowards(startCard, carsOn(startCard), rowEndAt(startCard, initialExit));
|
||||
const startKey = coordKey(start);
|
||||
const queue: Frontier[] = [
|
||||
{
|
||||
@@ -502,12 +536,15 @@ export function exploreMoves(
|
||||
* overfill the tray is illegal, not a move that picks up fewer cars.
|
||||
*
|
||||
* NEAREST FIRST ALONG THE DIRECTION OF TRAVEL. `carsOn` runs west to east, so a train entering
|
||||
* through the card's EAST port meets them back to front and the row has to be reversed. Without
|
||||
* this the same parked cut produced an identical consist whichever way it was approached, when
|
||||
* the two must mirror — which is the difference between a run-around being worth a Move and
|
||||
* being pointless.
|
||||
* at the row's EAST end meets them back to front and the row has to be reversed. Without this
|
||||
* the same parked cut produced an identical consist whichever way it was approached, when the
|
||||
* two must mirror — which is the difference between a run-around being worth a Move and being
|
||||
* pointless.
|
||||
*
|
||||
* `rowEndAt` rather than `node.entry === 'e'`: a 45° leg is an end of the row too, and which
|
||||
* end it is depends on the card's arc (Gitea#17).
|
||||
*/
|
||||
const met = node.entry === 'e' ? [...carsOn(card)].reverse() : carsOn(card);
|
||||
const met = rowEndAt(card, node.entry) === 'e' ? [...carsOn(card)].reverse() : carsOn(card);
|
||||
const couples = [...node.couples, ...met];
|
||||
const nodeKey = coordKey(node.coord);
|
||||
const origins = [...node.origins, ...met.map(() => nodeKey)];
|
||||
@@ -658,6 +695,26 @@ export function canPlaceAt(area: OfficeArea, coord: GridCoord, card: TrackCard):
|
||||
// into a stub and cutting the Office off from the Limits.
|
||||
if (coord.row === area.runningRow && !carriesThroughTrack(card)) return false;
|
||||
|
||||
/**
|
||||
* ONE NEIGHBOUR MUST JOIN. THE OTHERS NEED NOT — AND THIS RULE HAS BEEN BOTH WAYS (Gitea#15).
|
||||
*
|
||||
* A card may be laid with an exit facing a card that has nothing to meet it. The rail stops dead
|
||||
* at that edge, and that is legal.
|
||||
*
|
||||
* The issue was filed the other way round — "if a card is placed in that space, it MUST connect" —
|
||||
* against a right-hand curve laid with its north leg against an Ice House and the turnout below it
|
||||
* pointing at its portless south edge. **RAR reversed it on review (2026-08-26): placing it is
|
||||
* fine, and a stub like that is useful — a siding to park cars on.**
|
||||
*
|
||||
* WHAT MATTERS INSTEAD IS THAT NOTHING CAN DRIVE ACROSS THE GAP, so the real requirement is on
|
||||
* MOVEMENT rather than on placement: two cards touching are not connected, and `exploreMoves` must
|
||||
* refuse the hop. It does — every step is gated on `joins`, never on a bare pair of `hasPort`
|
||||
* calls — and `track.test.ts` pins the reported geometry against exactly that.
|
||||
*
|
||||
* SO DO NOT ADD A PER-EDGE CHECK HERE. One was written and taken out again when the ruling
|
||||
* arrived. What survives is the weaker rule that was always here: the piece must touch the network
|
||||
* SOMEWHERE, which is what stops orphaned track being laid in an empty corner of the board.
|
||||
*/
|
||||
const ports: Port[] = ['n', 's', 'e', 'w'];
|
||||
for (const p of ports) {
|
||||
const neighbourCard = cardAt(area, neighbour(coord, p));
|
||||
|
||||
Reference in New Issue
Block a user