Three of the six DATC deviations were bugs

The illegal/invalid line (6.A.5, 6.D.8). The document separates an order
that is impossible in this position from one this position allows that
merely did not come off. The first is ignored and its unit is holding like
any other; the second means the unit tried to leave and cannot be propped up
where it stands. An army sent across water with a fleet on the route and no
convoy ordered is the second; the identical order with nobody in the sea at
all is the first. Guessing at this once cost four passing cases to buy one.
Reading the document cost nothing -- it says so outright, in the note under
6.D.8 and again under 6.D.32.

A support that only looked like a hold (6.A.5). "Supports A Yorkshire" and
"Supports A Yorkshire - Yorkshire" are the same shape once parsed, and the
case turns on the difference: the first holds a unit down, the second
supports a move nobody can legally make. The extractor was throwing that
away; it now keeps it, and the fixture is regenerated.

The head of a cycle (6.F.22). Kruijswijk's resolver guesses that an order
fails, sees what follows, then guesses the other way. Only the outermost
order in a cycle may do that, because its answer is the one everything else
was computed against. This engine let any order that reached the dependency
list first declare the cycle its own -- and an inner one takes both guesses
with its callers' provisional answers held fixed, gets the same result twice
for that reason, and writes it down as settled. The cycle then becomes
invisible: the backup rule never runs and Szykman's rule never fires, and
the position resolves to whichever of its two consistent readings the search
happened to walk into first. It had been doing this on every paradox and
getting away with it, because on a first-order paradox both readings agree.

Also carried across from the reference algorithm: an order that resolved
itself while a nested call was away must not have the guess written over it.

Three remain. 6.F.28 and 6.F.29 are sixth-order paradoxes -- the same
twenty-six orders with one support between them, and the point of the pair
is that the answer swings on it, where this resolver gives both the same
answer. 6.G.19 the document itself gives three answers to, calls a little
bit pedantic, and advises adjudicators not to offer at all.
This commit is contained in:
2026-09-09 09:41:41 -07:00
parent ce276836cc
commit 8c31ecb35c
6 changed files with 415 additions and 64 deletions
+36 -5
View File
@@ -107,7 +107,7 @@ published cases is parsed and run.
| Section | | Passing |
| --- | --- | --- |
| 6.A - 6.G | movement | 133 / 139 |
| 6.A - 6.G | movement | 136 / 139 |
| 6.H | retreating | 18 / 18 |
| 6.I | building | 7 / 7 |
| 6.J | civil disorder | 13 / 13 |
@@ -121,14 +121,45 @@ Three cases are excluded rather than failed. 6.A.6, 6.B.10 and 6.B.11 state
their setup in prose -- "Germany has a fleet in London" -- and the fixture is
built from order lines, so it cannot carry a unit nobody ordered.
Six are known deviations, written down so they are not rediscovered as
Three are known deviations, written down so they are not rediscovered as
surprises:
| Case | What it is |
| --- | --- |
| 6.A.5, 6.D.8 | The document distinguishes an `invalid` order from an `illegal` one, and the two cases disagree about whether a unit whose move was refused keeps its hold support. Guessing at the distinction cost four passing cases to buy one, so it is left until it can be read properly. |
| 6.F.22, 6.F.28, 6.F.29 | Second and sixth order paradoxes. The resolver settles them by Szykman's rule and reaches a different answer than the document's. These are positions nobody assembles by accident. |
| 6.G.19 | Whether an unnecessary fleet in a convoy chain signals intent. The document notes this one depends on which edition of the rules is used. |
| 6.F.28, 6.F.29 | Sixth order paradoxes: the same twenty-six orders with one extra support between them, which the document uses to show that the answer swings on it. The resolver gets five of the six sub-paradoxes right in both and the sixth wrong, and gives the same answer to both positions when the point is that they differ. These are positions nobody assembles by accident. |
| 6.G.19 | Whether an unnecessary fleet in a convoy chain signals intent. The document gives three different answers by edition, calls the question "a little bit pedantic", and advises that web adjudicators should not offer the order at all -- which is the line this one takes. |
### What the failing cases were worth
They found three real faults, which is the whole argument for running
somebody else's tests rather than only your own.
**The illegal/invalid line (6.A.5, 6.D.8).** The document separates an order
that is impossible *in this position* from one this position allows that
merely did not come off. The first is ignored and the unit is holding like
any other; the second means the unit tried to leave and cannot be propped up
where it stands. An army sent across water with a fleet on the route and no
convoy ordered is the second (6.D.8); the identical order with nobody in the
sea at all is the first (6.D.32). Guessing at this once cost four passing
cases to buy one. Reading it properly cost nothing.
**A support that only looked like a hold (6.A.5).** "Supports A Yorkshire"
and "Supports A Yorkshire - Yorkshire" are the same shape once parsed, and
the case turns on the difference: the first holds a unit down, the second
supports a move nobody can legally make. The extractor now keeps the
distinction; it was losing it.
**The head of a cycle (6.F.22).** Kruijswijk's resolver guesses that an order
fails, sees what follows, and guesses the other way. Only the *outermost*
order in a cycle may do that, because its answer is the one everything else
was computed against. This engine let any order that reached the dependency
list first declare the cycle its own -- and an inner one takes both guesses
with its callers' provisional answers held fixed, gets the same result twice
for that reason, and records it as settled. The cycle then becomes
invisible: the backup rule never runs, and the position resolves to
whichever of its two consistent readings the search walked into first. It
had been doing that on every paradox and getting away with it, because on a
first-order paradox both readings agree.
Sections H, I and J -- retreating and the winter -- have engine code but no
harness yet; their cases are shaped differently and need one.
+51 -11
View File
@@ -83,7 +83,7 @@ function resolveAll(
forced: ReadonlySet<string>,
): Outcome {
// A unit with no order holds, and so does a unit whose order was refused.
const { orders, illegal } = validate(board, orderList)
const { orders, illegal, orderedAway } = validate(board, orderList)
const state = new Map<string, State>()
const result = new Map<string, boolean>()
@@ -236,14 +236,13 @@ function resolveAll(
if (o?.type === 'move') return resolve(dest) ? 0 : 1
/*
* A unit told to move cannot be supported where it stands, and the first
* branch above covers that. What is *not* settled here is the unit whose
* move order was refused outright: 6.D.8 says it loses its hold support
* too, while 6.D.28 to 6.D.32 say a unit in much the same position keeps
* it. The difference is the document's distinction between an order that
* is `invalid` and one that is `illegal`, which I have not pinned down,
* and guessing at it cost four passing cases to buy one. Left alone
* until it can be read properly rather than inferred.
* branch above covers the ones whose orders survived. This covers the
* rest: an order this position allowed and that merely did not come off
* still means the unit tried to leave. An order the position never
* allowed is ignored, and that unit is holding like any other and may be
* held down. See `orderedAway` for which is which.
*/
if (orderedAway.has(dest)) return 1
return 1 + supportsToHold(dest)
}
@@ -316,6 +315,8 @@ function resolveAll(
* agreeing answers are the answer, and disagreeing ones mean a genuine
* cycle, which the backup rule below settles.
*/
const stack: string[] = []
function resolve(p: string): boolean {
const s = state.get(p)
if (s === 'resolved') return result.get(p)!
@@ -325,18 +326,55 @@ function resolveAll(
}
const mark = dep.length
/*
* Who is already guessing further down the stack.
*
* This is the difference between settling a cycle and appearing to. Only
* the *outermost* order in a cycle may take the two guesses, because its
* answer is the one everything else was computed against. An inner order
* that finds itself first in the dependency list will otherwise declare
* the cycle its own, take both guesses with its callers' provisional
* answers held fixed, get the same result twice for that reason, and
* record it as settled. The cycle is then invisible: the backup rule
* never runs, and the position quietly resolves to whichever of its two
* consistent readings the search happened to walk into first.
*
* 6.F.22 is the case that found this. The English Channel put itself
* forward as the head while Edinburgh and London -- both in the same
* paradox -- were still on the stack below it.
*/
const below = new Set(stack)
stack.push(p)
state.set(p, 'guessing')
result.set(p, false)
const first = adjudicateOne(p)
if (dep.length === mark) {
/*
* Nothing depended on the guess, so the answer stands -- unless the
* order resolved itself while we were away. A nested call can reach
* the backup rule, settle this very province, and return; writing the
* guess over that answer loses it, and the cycle it was settling
* quietly re-forms as a fixed point nobody detects.
*/
stack.pop()
if (state.get(p) !== 'resolved') {
state.set(p, 'resolved')
result.set(p, first)
return first
}
return result.get(p)!
}
if (dep[mark] !== p) {
// Somebody above us is the one really guessing; report and let them ask.
/*
* Am I the outermost order of this cycle?
*
* Only if the cycle came back round to me at all, and only if none of
* its other members is still waiting further down the stack. Anything
* else reports what it has and lets the one below ask.
*/
const cycle = dep.slice(mark)
if (!cycle.includes(p) || cycle.some((q) => below.has(q))) {
stack.pop()
dep.push(p)
result.set(p, first)
return first
@@ -350,11 +388,13 @@ function resolveAll(
if (first === second) {
while (dep.length > mark) state.set(dep.pop()!, 'unresolved')
stack.pop()
state.set(p, 'resolved')
result.set(p, first)
return first
}
stack.pop()
backup(mark)
return resolve(p)
}
+231
View File
File diff suppressed because it is too large Load Diff
+83 -4
View File
@@ -28,8 +28,14 @@ export interface Unit {
export type Order =
| { type: 'hold'; at: string; power?: Power }
| { type: 'move'; at: string; to: string; viaConvoy?: boolean; power?: Power }
/** `from === to` is a support to hold. */
| { type: 'support'; at: string; from: string; to: string; power?: Power }
/**
* `from === to` is a support to hold, unless `ofMove` says a destination
* was actually written out. The difference is invisible in the shape of
* the order and decides 6.A.5: "Supports A Yorkshire" holds a unit down,
* while "Supports A Yorkshire - Yorkshire" supports a move nobody can
* legally make, and is therefore no order at all.
*/
| { type: 'support'; at: string; from: string; to: string; ofMove?: boolean; power?: Power }
| { type: 'convoy'; at: string; from: string; to: string; power?: Power }
/** Units by province. One unit to a province, whatever its coast. */
@@ -133,6 +139,22 @@ export interface Validated {
illegal: Set<string>
/** Provinces whose unit was told to move, legally or not. */
orderedToMove: Set<string>
/**
* Provinces whose unit was told to leave and could have.
*
* The document draws a line here that decides two cases (issue 4.E.1). An
* order that is impossible *in this position* but would be possible in
* another is **illegal**: it is ignored, the unit is simply holding, and
* it may be held down by hold support. An order that this position allows
* and that merely did not come off is **invalid**: the unit tried to
* leave, and a unit trying to leave cannot be propped up where it stands.
*
* The two cases are the same order with one piece moved. An army sent
* across water with a fleet standing on the route and no convoy ordered
* was given a legal order that failed (6.D.8). The identical order with
* nobody in the sea at all was never an order (6.D.32).
*/
orderedAway: Set<string>
}
export function validate(board: Board, given: readonly Order[]): Validated {
@@ -197,16 +219,30 @@ export function validate(board: Board, given: readonly Order[]): Validated {
}
const supported = orders.get(base(order.from))
const wasRefused = refused.has(base(order.from))
if (base(order.from) !== base(order.to) && wasRefused && supported?.type !== 'move') {
// A destination written out makes this a support of a move, even when
// the destination is where the unit already is -- and there is no legal
// move to your own province, so there is nothing there to support.
const ofMove = order.ofMove === true || base(order.from) !== base(order.to)
if (ofMove && wasRefused && supported?.type !== 'move') {
refused.add(at)
continue
}
orders.set(at, ok)
}
const orderedAway = new Set<string>()
for (const order of given) {
if (order.type !== 'move') continue
const at = base(order.at)
const unit = board.get(at)
if (!unit || (order.power && order.power !== unit.power)) continue
if (orders.get(at)?.type === 'move') orderedAway.add(at)
else if (unit.type === 'army' && crewedRoute(board, unit.at, order.to)) orderedAway.add(at)
}
for (const at of refused) if (!orders.has(at)) illegal.add(at)
for (const [p] of board) if (!orders.has(p)) orders.set(p, { type: 'hold', at: p })
return { orders, illegal, orderedToMove }
return { orders, illegal, orderedToMove, orderedAway }
}
/** The order as it will be obeyed, with the coast filled in, or null. */
@@ -330,6 +366,49 @@ export function seaRouteExists(
return false
}
/**
* The coasts a chain of fleets standing on the board can reach from these
* seas.
*
* Whoever owns them and whatever they were ordered to do. This is a question
* about what the position makes possible, not about what anybody asked for,
* and it is the difference between an order that is illegal and one that is
* merely invalid.
*/
export function coastsThroughFleets(board: Board, from: readonly string[]): Set<string> {
const crewed = (id: string) => board.get(base(id))?.type === 'fleet'
const out = new Set<string>()
const seen = new Set<string>()
const queue = [...from]
while (queue.length > 0) {
const sea = queue.shift()!
if (seen.has(sea)) continue
seen.add(sea)
for (const next of FLEET[sea] ?? []) {
const p = base(next)
if (PROVINCES[p]!.terrain === 'sea') {
if (crewed(p)) queue.push(p)
} else if (PROVINCES[p]!.terrain === 'coast') {
out.add(p)
}
}
}
return out
}
/** Could the fleets now on the board carry an army from here to there? */
export function crewedRoute(board: Board, from: string, to: string): boolean {
const start = base(from)
const end = base(to)
if (start === end) return false
if (PROVINCES[start]?.terrain !== 'coast' || PROVINCES[end]?.terrain !== 'coast') return false
const seas = coastalSeas(start)
.map(base)
.filter((sea) => board.get(sea)?.type === 'fleet')
return coastsThroughFleets(board, seas).has(end)
}
/** The seas a coastal province touches, whichever coast they are on. */
export function coastalSeas(id: string): string[] {
const coasts = PROVINCES[id]?.coasts
+5 -41
View File
@@ -1,6 +1,6 @@
import { reachableFrom } from './layout'
import { FLEET, PROVINCES, base } from './map'
import { coastalSeas, type Board, type Unit } from './orders'
import { PROVINCES, base } from './map'
import { coastalSeas, coastsThroughFleets, type Board, type Unit } from './orders'
/**
* What each half of an order may be clicked on.
@@ -51,42 +51,6 @@ export function supportTargets(board: Board, unit: Unit, from: string): Set<stri
return out
}
/**
* The coasts a chain of crewed seas touches, starting from these.
*
* The model the whole convoy offering is built on: a sea counts if there is
* a fleet standing in it, whoever owns it, and the chain runs as far as the
* fleets do. A fleet that has not been ordered to convoy still counts -- it
* is a thing that could be arranged, which is what the negotiation is for,
* and the adjudicator will bounce the crossing if it is not.
*
* This is deliberately not the question the rules ask when they *judge* a
* convoy order, which is whether water could ever get there. That one says
* yes to most of Europe: it would offer thirty provinces because a chain of
* fleets is conceivable, which is worse than offering none.
*/
function coastsReached(board: Board, from: readonly string[]): Set<string> {
const crewed = (id: string) => board.get(base(id))?.type === 'fleet'
const out = new Set<string>()
const seen = new Set<string>()
const queue = [...from]
while (queue.length > 0) {
const sea = queue.shift()!
if (seen.has(sea)) continue
seen.add(sea)
for (const next of FLEET[sea] ?? []) {
const p = base(next)
if (PROVINCES[p]!.terrain === 'sea') {
if (crewed(p)) queue.push(p)
} else if (PROVINCES[p]!.terrain === 'coast') {
out.add(p)
}
}
}
return out
}
/** The seas off this coast that have a fleet in them. */
const putToSea = (board: Board, coast: string): string[] =>
coastalSeas(coast)
@@ -97,7 +61,7 @@ const putToSea = (board: Board, coast: string): string[] =>
export function convoyDestinations(board: Board, unit: Unit): Set<string> {
const here = base(unit.at)
if (unit.type !== 'army' || PROVINCES[here]?.terrain !== 'coast') return new Set()
const out = coastsReached(board, putToSea(board, here))
const out = coastsThroughFleets(board, putToSea(board, here))
out.delete(here)
return out
}
@@ -112,7 +76,7 @@ export function convoyDestinations(board: Board, unit: Unit): Set<string> {
export function convoyable(board: Board, unit: Unit): Set<string> {
const sea = base(unit.at)
if (unit.type !== 'fleet' || PROVINCES[sea]?.terrain !== 'sea') return new Set()
const ashore = coastsReached(board, [sea])
const ashore = coastsThroughFleets(board, [sea])
const out = new Set<string>()
for (const coast of ashore) {
if (board.get(coast)?.type === 'army') out.add(coast)
@@ -124,7 +88,7 @@ export function convoyable(board: Board, unit: Unit): Set<string> {
export function convoyTargets(board: Board, unit: Unit, from: string): Set<string> {
const sea = base(unit.at)
if (unit.type !== 'fleet' || PROVINCES[sea]?.terrain !== 'sea') return new Set()
const out = coastsReached(board, [sea])
const out = coastsThroughFleets(board, [sea])
out.delete(base(from))
return out
}
+7 -1
View File
@@ -153,8 +153,14 @@ def main() -> int:
order = {'type': 'convoy', 'at': at,
'from': place(m2.group(2)), 'to': place(m2.group(3))}
elif m2 := re.match(r'^(.*?)\s+Supports\s+[AF]\s+(.*?)\s+-\s+(.*)$', rest, re.I):
# A destination was written out. Worth keeping even when it
# is the mover's own province: "Supports A Yorkshire" and
# "Supports A Yorkshire - Yorkshire" come out identically
# otherwise, and 6.A.5 turns on the difference between
# them -- the first holds a unit down, the second supports
# a move nobody can legally make.
at = place(m2.group(1))
order = {'type': 'support', 'at': at,
order = {'type': 'support', 'at': at, 'ofMove': True,
'from': place(m2.group(2)), 'to': place(m2.group(3))}
elif m2 := re.match(r'^(.*?)\s+Supports\s+[AF]\s+(.*)$', rest, re.I):
at = place(m2.group(1))