Adjudication — the Kruijswijk Fixed-Point Resolver¶
Companion to
diplomacy_rules.md(rulebook prose). This document covers the algorithm: howsrc/engine/adjudicator/turns a(map, state, orders)triple into a(Resolution, next_state)pair. It is mined from the source docstrings inmovement.py,retreats.py,adjustments.py— those files are the ground truth; this doc explains why they're shaped the way they are and ties the pieces together.Conformance: all 160 DATC cases green (
tests/datc/), under every submission order tried (§11). Everything below is implemented, not aspirational.
1. Why fixed-point, not a single pass¶
Diplomacy orders are simultaneous and interdependent: whether move A succeeds can depend on whether support B holds, which depends on whether move C cuts it, which depends on whether A succeeds. A single linear pass over orders cannot get this right, and gives answers that depend on the order in which the orders are processed.
The fix is Kruijswijk's algorithm ("The Math of Adjudication"): treat the outcome of every move, support, and convoy order as a boolean predicate and resolve them by mutual recursion with memoization, exactly as you'd resolve a system of mutually recursive functions. Three predicates:
move_succeeds(m)— does movemadvance its unit?support_given(s)— is supportseffective (valid and not cut)?convoy_survives(c)— does convoying fleetcavoid dislodgement?
src/engine/adjudicator/movement.py's _Resolver class implements all three as methods
(_move_succeeds, _support_given, _convoy_survives) dispatched through one entry
point, _resolve(province), keyed by the province of the ordering unit.
2. The resolve loop: UNRESOLVED / GUESSING / RESOLVED¶
Each order's resolvable item (_Item) carries a three-valued state:
- UNRESOLVED — not yet computed.
- GUESSING — computation is in progress; the current
valueis a provisional guess. - RESOLVED — final;
valueis authoritative and memoized.
_resolve(prov):
- If already
RESOLVED, return the memoized value. - If already
GUESSING, we've re-entered an order that's still being computed — that's a dependency cycle. Appendprovtoself._deps(the current recursion's dependency trail) and return the current guess. Every such read is appended, even whenprovis already on the trail: the caller's result now rests on that guess, and step 4 judges "guess-free" by whether the trail grew, so a read that left it unchanged would let a result computed on a guess be frozen asRESOLVED. - Otherwise: mark
GUESSINGwith a provisional guess ofFalse, stamp the item with a sequence number (seq, when its resolution began), then compute via_adjudicate(prov)(dispatches to_move_succeeds/_support_given/_convoy_survives). Every predicate reads another order's result only through_resolve— a convoying fleet's survival included (§6) — so every dependency is seen. - If no cycle was hit (
self._depsdidn't grow), the computed value is definitive: markRESOLVEDand return it. This is the common case — most orders have no cyclic dependency and resolve in one pass. - If a guess was read that began before
prov's own (a lowerseq: an order further up the call stack), the cycle reaches pastprov.provis not its head: it lists itself, keeps its value as a guess, and lets the head handle it. A guess read is alwaysprov's own, an order further up, or one begun insideprov's computation and still waiting on one of those two; so the lowestseqread decides. - Otherwise
provis the cycle's head: this is where the interesting cases live (§3).
3. Breaking cycles: circular movement vs. the Szykman rule¶
When the head of a cycle is reached, the resolver tries both truth values for that
order and re-evaluates the whole cycle each time (Kruijswijk's Resolve):
- Reset every member of the cycle to
UNRESOLVED, guess the head isTrue, and re-run_adjudicate. Compare against the first pass (head guessedFalse). If this pass read a guess from further up the stack, the head hands its value up as in step 5. - If both guesses produce the same outcome (guess-independent), that shared value is
correct: the head is
RESOLVEDwith it, and the other members go back toUNRESOLVEDto be resolved again on demand, now against a fixed head. This resolves most cycles. - If the two guesses disagree, the cycle has two outcomes or none, and the backup
rule (
_backup_rule) fixes part of it. Then the whole cycle, head included, is reset and the head is resolved again from scratch (return self._resolve(prov)): no member keeps a value computed on a guess. - A cycle holding a convoying fleet and a support is a convoy paradox (DATC
6.F.14–6.F.24, 6.G.11). The Szykman rule applies: the convoys of the cycle's
fleets are disrupted (
_disrupted)._convoy_path_worksskips a disrupted fleet without reading it, so an army that needs it fails (NO_CONVOY) and cuts nothing, as if that convoy had never been ordered; the fleet itself still holds, can be dislodged, and is reportedOKif it is not (6.F.16–6.F.18). A route through other, undisrupted fleets still carries the army (6.F.19/20). The cycle need not hold the army's move: a support reads the route directly, so in 6.F.14, starting atF LON S F WAL - ENGfinds {ENG's convoy, WAL's move, LON's support}. Disrupting by fleet makes every starting point give the same result. - Any other cycle is circular movement — DATC 6.C's multi-unit rotations and
army swaps via convoy. Every move in the cycle succeeds (
RESOLVED), and the rest is resolved again around them.
The distinction is deliberate: a cycle of pure moves (even one routed through a convoy, as in a same-power army swap) is not a paradox — nothing about it is self-referential once you fix "everyone moves." A paradox only arises when a support's cut-or-not status and a convoy's survival-or-not status depend on each other in a loop that has no consistent resolution without a tiebreaker.
Second-order paradoxes (6.F.22–6.F.24) need nothing more. Resolving again after a Szykman step may meet another paradox, whose backup disrupts its own fleets in turn; that repeats until no paradox is left. It ends because each step disrupts at least one more fleet, and a disrupted fleet is never read again, so it can join no further cycle.
4. Strength model¶
Every strength number folds in "supports that count," with several exemptions that are the actual substance of DATC §6.D:
- Hold strength of a province (
_hold_strength):0if empty;0if its occupant is ordered to move and that move actually happens (it vacated); otherwise1 + valid uncut hold-supports. A unit ordered to move that fails still holds at strength 1 with no hold support (a unit can't get both — DATC 6.D.7/8/25: a legally moving unit cannot receive hold support even if the move later bounces). - Attack strength of a move (
_attack_strength):0if its convoy path is required and broken;0if it would dislodge a unit of its own power (a unit never dislodges its own side, even head-to-head); otherwise1 + supports, where a support from the defender's own power does not count toward dislodging that defender. - Defend strength (
_defend_strength, used in head-to-head battles) and prevent strength (_prevent_strength, used for standoffs against a third unit's move into the same empty province): both1 + supports, with no own-power exemption (DATC defines only attack strength that way). A move that itself loses a head-to-head battle prevents nothing against third parties (_prevent_strength's head-to-head short-circuit). Only a head-to-head zeroes it (DATC issue 4.A.7, choice (b), the DATC's preference over the literal rulebook IX.7): a convoyed move dislodged by the unit leaving its destination is not in a head-to-head, so it still stands a third unit off there (DATC 6.G.10, 6.G.14, 6.G.15). This is a deliberate choice, made by the maintainer on 2026-11-17 (issue #404): the DATC is the authority where it and the rulebook text part.
A move succeeds (_move_succeeds) when: its convoy path (if any) works; its attack
strength beats every competing move's prevent strength into the same destination
(standoff check); and, if the destination is occupied, either the occupant vacates, or
(in a head-to-head) the attacker's strength beats the occupant's defend strength, or (a
stationary occupant) the attacker's strength beats the occupant's hold strength — and
never against a unit of the attacker's own power.
5. Support cuts¶
A support is void (illegal, reported VOID, contributes nothing) — computed once,
geometrically, before the cut question is even asked — when (_support_is_void):
- it's not a legally reachable support for the supporting unit (
_support_valid), or - it names no real order to support (
_support_has_target) — e.g. a hold-support for an empty province, or a move-support whose named mover isn't actually moving there, or a move-support naming a coast the mover does not take (F POR S F MAO - SPA/NCforF MAO - SPA/SC; DATC 6.B.9 — the mover's coast is the one it actually reaches, soF GAS - SPAgoes to SPA/NC (6.B.2) and a support namingSPA/SCis void too (_move_dest_coast); a support naming no coast matches either, 6.B.7/6.B.8, solegal_ordersoffers supports into BUL, SPA and STP only without a coast), or - (
SupportMove, reported only) it would help dislodge a holding unit of the supporter's own power at the destination — unless that unit is itself ordered to move away and the support was decisive elsewhere (_support_decisive_elsewhere): it was given, and the supported move's prevent strength equals the attack strength of another move into the same destination, so without it that move would have won (DATC 6.E.12: the support "serves other means" rather than self-dislodgement). Another attacker that bounces with or without the support does not count (6.E.8, 6.E.10), and a unit that vacates via circular movement (6.C.2) was never being dislodged at all. The test reads resolved results, which is one more reason it can only be a reporting rule. This rule decides theVOIDresult code and nothing else: for strength such a support is given like any other (_support_givencalls_support_is_void(..., count_own_unit_rule=False)) and is kept out of the one place DATC excludes it, the attack strength against that own-power unit. (Letting the rule zero the support would make the support depend on whether its own unit vacates, which depends on the support: a loop the resolver would settle differently depending on submission order. The determinism property intests/datc/test_properties.pyand a pinned case intests/datc/test_adjudicator_mechanics.pyguard this.) Or - (
SupportMove) it supports a convoyed move that no possible route (§6) could carry without the supporting fleet: a fleet cannot convoy and support at once, so when every route runs through it the support is impossible (DATC 6.D.31'sF BLA S A RUM - ARM). The check reads only the board (_possible_route(..., without=...)), so it holds for strength as well as for the reported code. Or - (
SupportHold) it targets a unit that is itself legally ordered to move (DATC 6.D.7/8/25 again — an illegal/ignored move leaves the unit holding, so support for it is fine, 6.D.28/29).
Given a non-void support, _support_given checks every other order for a move that (a)
targets the supporting unit's own province, (b) isn't the very unit being supported
(a supported unit never cuts its own support), (c) isn't from the same power as the
supporter (DATC 6.D.20 — you cannot cut your own country's support), and (d) isn't a
convoyed move whose convoy path is itself broken (a disrupted convoy attack cuts
nothing). One exception inside that: an attack from the province the support is
targeting against a move only cuts by actually dislodging the supporter — this is
the "attack from the supported-against province" exemption in the rulebook (a unit can
attack a move it's the target of without automatically cutting the support of that
move, unless it wins).
6. Convoys¶
A convoyed move is only recognized as convoyed — as opposed to illegal or a plain land
move — under specific conditions (_uses_convoy):
- Non-adjacent army moves are always convoyed (there's no other way to make the trip),
so
A NWY - YORandA NWY - YOR VIAare the same order; validation accepts either between two coastal provinces (data_spec.md§5). - For an adjacent move: an explicit
VIAforces convoy semantics whenever some fleet (any power) has actually been ordered to carry it (DATC 6.G.10/6.G.14) — with no matching Convoy order,VIAis ignored and the army walks (6.G.8). WithoutVIA, convoy intent is inferred from the army's own power's convoy order, swap or not (DATC 4.A.3 choice d) — a foreign fleet cannot "kidnap" a friendly army onto a convoy it never asked for (DATC 6.G.2/6.G.4). A convoy order on no possible route isVOIDand lends no intent (6.G.7); one that also creates a cycle is the 6.G.11 paradox. Intent needs only that own-power convoy order on a possible route (below), not a complete chain of convoy orders: withA NAP - ROM,F ION C A NAP - ROMandF TYS H, the army is convoyed, the chain is missingF TYS, and the move failsNO_CONVOYrather than walking (choice d as written; maintainer's ruling, 2026-11-17, issue #405). So that a player can ask for a (foreign) convoy into a neighbour,legal_ordersoffers an armyA X - Y VIAfor every province Y on the shore of a chain of fleet-held seas it stands on, adjacent or not, alongside the plainA X - Y.
A non-adjacent army move is legal only when the board allows a convoy: both ends
are coastal and a possible route (below) links them, whatever the fleets were ordered
(DATC 4.E.1 decides legality before the orders are revealed). With no possible route
the move is illegal -- VOID, and the army holds and may receive hold support (6.D.32,
6.F.1's A GRE). With one, it is a real move even if no fleet convoys it: it fails as
NO_CONVOY, and the army cannot receive hold support (6.D.8, 6.D.31's A RUM).
A Convoy order is illegal -- reported VOID, kept out of the resolver's items, and
showing no convoy intent -- when its fleet cannot be on any possible route
(_possible_route): a chain of fleets in sea provinces (any power, whatever they were
ordered), visiting no fleet twice, that starts at a fleet touching the army's province,
passes through this fleet, and ends at a fleet touching the destination (DATC 4.E.1: an order that can never be
valid is ignored). So a fleet on a coast never convoys (6.F.1's F CON), nor does a fleet
whose sea chain does not reach the far shore (6.G.7's F BOT C A SWE - NWY, which
therefore lends Russia's army no intent, and the swap bounces). The test is a
breadth-first search from each end over the sea fleets (_route_reach, memoized per
province and excluded fleet). With no fleet required, a chain from each end meeting is
enough; for a given fleet, reaching it from both ends is not (the halves may share a fleet,
a dead-end sea walked there and back), so _simple_route_through searches for halves that
share none. It reads only the board. server/legal_orders.py offers a convoy through a fleet
by asking the same rule (convoy_route_possible), and tests/test_legal_orders.py checks
the menu and the adjudicator agree. It asks the rule with without= too: a fleet is not
offered support for a convoyed move that no route avoiding that fleet could carry, since
such a support is void (6.D.31).
The convoy path itself (_convoy_path_works) is a breadth-first search over
currently-surviving convoying fleets (Convoy orders whose origin/dest match the move,
filtered to fleets not dislodged this phase and not disrupted by a paradox, §3), starting from fleets adjacent to the
army's source coast and searching for one adjacent to the destination. Whether a fleet
survives is read as _resolve of its Convoy order (_convoy_survives), not by asking
_is_dislodged directly, so the convoying fleet is a dependency of the army it carries
and a convoy can be part of a dependency cycle (§3). This directly
supports multi-route convoys: if any surviving subset of the ordered fleets forms an
unbroken chain, the move works — losing one fleet in a multi-fleet, multi-route convoy
order does not fail the whole move.
Three convoy-order result codes reflect fine distinctions DATC cares about:
VOID (no matching army move exists to convoy — 6.D.27 — or the fleet is on no possible
route, above), DISLODGED (the fleet itself
was dislodged this phase), and NO_CONVOY (the fleet survived but the chain is broken
elsewhere, e.g. a sibling fleet died) vs. plain OK (chain intact, even if the convoyed
army merely bounced at the far end — the convoy did its job; or the fleet's convoy was
disrupted by a paradox, §3, and the fleet was not dislodged).
Critically, a convoyed army's attack strength is never boosted by the number of
convoying fleets — it's still 1 + supports, same as any other move.
7. Assembling the phase result¶
After every order resolves (run()), the resolver derives, in order:
- Surviving units: for each pre-phase unit, if its move succeeded it lands at the
destination (coast-resolved via
_move_dest_location— an explicit coast is kept, otherwise inferred when the reachable set is unambiguous); otherwise it's dislodged (_is_dislodged) or stays put. - Standoff provinces (
contested): a province targeted by ≥2 moves, none of which succeeded, that no surviving unit occupies. Only a move with a nonzero prevent strength counts as targeting it: a convoyed army whose convoy failed (NO_CONVOY) never reached the province, so it stands nothing off there. That includes a province whose own unit moved out this turn: the rulebook closes any space "left vacant due to a standoff" to retreats. A standoff in a province whose unit stayed is instead reflected in the occupant's hold/dislodge outcome. - Dislodged unit records: for each dislodged unit, its
attacker_origin(the province the successful attacker moved from —Noneif that attack was convoyed, since a convoyed attacker crosses no shared border and so imposes no "can't retreat the way you came" block) and its precomputed legalretreats, viaretreats.compute_retreat_options(§8 below) — computed once, here, against post-resolution occupancy, so the retreat phase never has to recompute legality from stale pre-move board state. - Per-order
OrderResults with the appropriateResultCode(OK/BOUNCE/CUT/VOID/NO_CONVOY/DISLODGED), each carrying itsretreat_optionswhen applicable.
The returned GameState has units, dislodged, and contested populated; game.py
(the phase machine, §9) then decides whether the next phase is a retreat phase, the next
movement phase, or an adjustment phase.
8. Retreats¶
src/engine/adjudicator/retreats.py is deliberately split into a pure legality function,
compute_retreat_options, and the phase adjudicator, adjudicate_retreats, because the
legality function is needed twice: once by the movement resolver (to populate
DislodgedUnit.retreats and each order's retreat_options, both surfaced to players
before they choose), and once by the retreat phase itself to validate submitted orders.
Computing it once and reusing it (rather than recomputing from possibly-stale state) is
the whole point — see the module docstring's framing as "the single source of truth."
A destination is legal iff: the unit could reach it by ordinary adjacency (land for
armies, sea/coast for fleets — coasts are first-class, so a fleet retreating into a
split-coast province gets one candidate per reachable coast); it is not
attacker_origin (you can't retreat the way the attack came, unless that attack was
convoyed); no surviving unit already occupies it; and it isn't in contested (a
province that stood off this same movement phase admits no retreats either — too much
traffic).
retreat_refusal applies the same rules to one destination and returns the reason it is
refused (out of reach, the attacker's origin, occupied, standoff), which validation hands to
the player. A fleet retreat naming no coast takes the sole legal coast of that province, as
a move does (_legal_dest); with two legal coasts it is ambiguous and the unit disbands.
The retreat phase itself (adjudicate_retreats) resolves each dislodged unit's
attempted destination (a legal Retreat order, or None for an explicit Disband or no
order at all), then applies one more collision rule that only bites here: if two or
more units attempt to retreat into the same province, all of them fail and disband —
not "first submitted wins", and not decided by strength
(retreats don't have supports). An unordered or illegally-ordered dislodged unit disbands
outright.
The results say why each unit left the board, so a player can tell a disband they chose from one that happened to them:
- a retreat that collided is reported as its
Retreatorder withBOUNCE(the unit is disbanded all the same; nobody lands in the province); - a unit with at least one legal retreat but no order is a synthetic
Disbandreported asDISBANDwithcivil_disorder=Trueand theretreat_optionsit had — the retreat options are what tell it from an adjustment's civil-disorder disband, which has none; - an explicit
Disband, an illegal retreat (reported as itsRetreatorder) and a trapped unit that was given no order (it had nowhere to go) are a plainDISBAND.
9. Adjustments (builds, disbands, civil disorder)¶
src/engine/adjudicator/adjustments.py reconciles each power's unit count against
its supply-center count independently, power by power:
centers > units(_resolve_builds): entitlement iscenters - units, further capped in practice by how many valid builds exist (a power can be entitled to 3 builds but have only 1 vacant home center). EachBuildorder is validated (orders/validation.py— must be a currently-owned home supply center, must be vacant, a fleet build at a split-coast province must name a coast) up to the entitlement; excess or invalidBuilds areVOID. ExplicitWaiveorders consume a build slot without producing a unit; any entitlement left over after processing all submitted orders — whether from explicit waives or simply unordered — is implicitly waived (silently, no unit appears, reported as a syntheticWAIVEresult). ADisbandsubmitted while a power is owed builds is meaningless andVOID(you can't shrink when you're entitled to grow).centers < units(_resolve_disbands): the power must removeunits - centers. Valid submittedDisbandorders are honoured first, up to the required count; any shortfall is made up by civil disorder — automatic removal, unordered, following the rulebook's distance rule (_civil_disorder_order): farthest from the power's nearest home supply center first (by shortest route — for armies this traverses land and sea steps, since a convoy could in principle carry them home, so_distance_to_home's BFS for armies is not restricted to land adjacency; fleets are restricted to fleet adjacency), fleets removed before armies on a distance tie, and then alphabetically by the province's name (MapData.display_names, frommaps/standard.map), not its abbreviation: the rulebook (p. 18, Civil Disorder) says "If units are equally distant, then remove Fleets before Armies and then in alphabetical order by the provinces in which they are located", so a fleet in Norway goes before one in the Norwegian Sea although NWG sorts before NWY. Each such removal is a syntheticDisbandreported asDISBANDwithcivil_disorder=True, so it can be told apart from an ordered one (the server announces it to the power). ABuildorWaivesubmitted while a power owes disbands isVOID(you can't grow while shrinking).centers == units: no adjustment is owed; anyBuild/Disband/Waivesubmitted isVOID.
Submission refuses wrong-direction orders and more orders than the count (data_spec.md
§5), so these VOIDs are reached only by orders that bypass GameService (tests, the
engine called directly).
10. The phase machine¶
src/engine/game.py's Game.adjudicate() dispatches to whichever of the three
adjudicators matches state.phase_type, then computes the next phase
(_transition):
S{y}M → [S{y}R if dislodgements] → F{y}M → [F{y}R if dislodgements]
→ [W{y}A if any power's units ≠ centers] → S{y+1}M → …
Supply-center ownership is recomputed once, after the Fall turn fully settles
(movement plus any retreats) — whoever occupies a center at that instant claims it;
unoccupied centers keep their previous owner. Victory (VICTORY_CENTERS = 18) is
checked at that same point, before deciding whether an adjustment phase is needed. Game
itself is a frozen dataclass (map, current state, history of past snapshots) — every
call to adjudicate() returns a new Game, never mutates the old one.
11. Documented deviations / known gaps¶
No DATC case is xfail. Order independence is tested, not assumed:
tests/datc/test_order_independence.py runs every DATC movement case under its own
order, reversed and in seeded shuffles (every permutation up to five orders);
tests/datc/test_properties.py shuffles random convoy-rich boards
(tests/datc/convoy_boards.py) as well as army-only ones; and
tests/datc/test_szykman_boards.py pins twenty fuzz-found convoy paradoxes with their
Szykman results.
Convoy paradoxes follow the Szykman rule, not the rulebook's. The rulebook settles a
paradox with a narrower rule (diplomacy_rules.md, "A convoyed attack does not cut
certain supports"): a convoyed army attacking a fleet that supports an action in a body of
water holding a convoying fleet does not cut that support. Szykman (§3) instead disrupts
the cycle's convoys. On the rulebook's own example both give the same result, but they
differ where the rulebook's rule does not reach the support that causes the paradox. In
DATC 6.F.20 and 6.F.21 the engine cuts a support the literal rulebook text would leave
standing, so in 6.F.21 F NAO is dislodged. This follows DATC's preferred option, and
the DATC tests pin it.
12. Where to look¶
src/engine/adjudicator/movement.py— the resolver (§2–7).src/engine/adjudicator/retreats.py— retreat legality + phase (§8).src/engine/adjudicator/adjustments.py— builds/disbands/civil disorder (§9).src/engine/game.py— phase machine (§10).tests/datc/— one test per DATC case, tagged with thedatcpytest marker, organized by section (6.A–6.J);tests/datc/harness.pyhas theplace_units/give_orders/adjudicate/assert_result/assert_dislodgedhelpers used throughout.tests/datc/test_properties.py— Hypothesis properties: order-shuffling never changes the outcome (determinism), ≤1 unit per province post-resolution, unit conservation, every dislodged unit has a computed legal retreat set.