@chrischall/warapp-mcp 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -531,7 +531,8 @@ export function threatForces(pc, ps, src, valueOf) {
531
531
  * #420 (owner decision of 2026-11-20, "One opponent's deploy"): an opponent deploys its income in one
532
532
  * place, so its full deploy sizes only its single most valuable border of mine (by protected value —
533
533
  * `valueOf` —, then its movable armies beside it, then id); each other border of mine its stacks face is
534
- * sized at those stacks plus its largest top-up seen (`topUpOf`), never above the full deploy. `capAt`:
534
+ * sized at those stacks alone (#603: the self-play arena; before it, those stacks plus its largest top-up seen,
535
+ * which kept every border sized for nearly the whole deploy once the opponent had once dumped it on one). `capAt`:
535
536
  * by my territory, the players capped there and the figure; `primary`: each such player's full border.
536
537
  * Not on my commander's territory (rule 1k's worst case), nor for an untrusted estimate (#275) at that
537
538
  * border, a player with no top-up seen, or one facing a single border of mine. A quiet neighbour
@@ -564,7 +565,10 @@ export function threatForces(pc, ps, src, valueOf) {
564
565
  if (pc.myCommanders.has(t) || untrustedAt(player, t) > 0)
565
566
  continue;
566
567
  const m = oneBorderMemo.capAt.get(t) ?? new Map();
567
- m.set(player, src.topUpOf.get(player));
568
+ // #603: the deploy floats once — a border other than the most valuable one holds against the stacks beside
569
+ // it alone (a quiet neighbour, #420's P1 amendment, keeps its largest top-up seen on every border).
570
+ const legacy = pc.opts.experiments?.includes('legacy-topup') === true;
571
+ m.set(player, quiet || legacy ? src.topUpOf.get(player) : 0);
568
572
  oneBorderMemo.capAt.set(t, m);
569
573
  }
570
574
  }
@@ -601,9 +605,10 @@ export function threatForces(pc, ps, src, valueOf) {
601
605
  const full = truced === player
602
606
  ? 0
603
607
  : deployReaching(player, [...p.stacks.map((x) => x.id), ...(p.behind ?? [])], Math.max(pc.deployOf(player), untrustedAt(player, t)));
604
- // #420: off its most valuable border, the stack plus its largest top-up seen.
608
+ // #420/#603: off its most valuable border, the stack alone (a quiet neighbour: plus its largest top-up seen).
605
609
  const cap = oneBorder().capAt.get(t)?.get(player);
606
- const deploy = cap !== undefined ? Math.min(full, cap) : full;
610
+ const capped = cap !== undefined ? Math.min(full, cap) : full;
611
+ const deploy = o.deployCap !== undefined ? Math.min(capped, o.deployCap) : capped;
607
612
  const growth = truced === player ? 0 : p.growth;
608
613
  const movable = p.stacks.reduce((n, x) => n + x.movable, 0);
609
614
  const add = Math.max(deploy, growth);
@@ -684,10 +689,17 @@ export function threatForces(pc, ps, src, valueOf) {
684
689
  * {@link threatAt} for next turn (G2): the same force, with the players a Diplomacy card shields me
685
690
  * from only this turn counted again ({@link foeNext}). The same as threatAt when there is none.
686
691
  */
687
- const nextTurnAt = (t, gone) => {
688
- if (!returning.size && !behindNext)
692
+ const nextTurnAt = (t, gone, deployCap) => {
693
+ if (!returning.size && !behindNext && deployCap === undefined)
689
694
  return threatAt(t, gone);
690
- const f = forceAt(t, gone, { trend: true, allPlayers: true, solo: ps.soloHeld.has(t), nextTurn: true, behind: behindNext });
695
+ const f = forceAt(t, gone, {
696
+ trend: true,
697
+ allPlayers: true,
698
+ solo: ps.soloHeld.has(t),
699
+ nextTurn: true,
700
+ behind: behindNext,
701
+ ...(deployCap !== undefined ? { deployCap } : {}),
702
+ });
691
703
  return f ? { player: f.player, threat: f.threat } : null;
692
704
  };
693
705
  /**
@@ -930,7 +942,7 @@ export function borderThreats(pc, ps, input, src, forces) {
930
942
  if (!rest.length)
931
943
  continue;
932
944
  const one = rest.length === 1;
933
- rationale.push(`Player ${player} deploys its ~${full} in one place (#420): its full deploy is sized only on its most valuable border, ${label(top)}; ${rest.map(label).join(', ')} ${one ? 'is' : 'are'} sized at its stack beside ${one ? 'it' : 'them'} plus its largest top-up seen, +${capAt.get(rest[0]).get(player)} (the most one of its stacks beside my land grew in a turn).`);
945
+ rationale.push(`Player ${player} deploys its ~${full} in one place (#420): its full deploy is sized only on its most valuable border, ${label(top)}; ${rest.map(label).join(', ')} ${one ? 'is' : 'are'} sized at its ${capAt.get(rest[0]).get(player) ? `stack beside ${one ? 'it' : 'them'} plus its largest top-up seen, +${capAt.get(rest[0]).get(player)} (the most one of its stacks beside my land grew in a turn)` : `stacks beside ${one ? 'it' : 'them'} alone: one deploy cannot land on two borders (#603)`}.`);
934
946
  }
935
947
  }
936
948
  // #199: say where a Multi-Attack chain sets a border's threat.
@@ -1060,7 +1072,12 @@ export function borderThreats(pc, ps, input, src, forces) {
1060
1072
  if (e.tracked !== null) {
1061
1073
  const track = input.tracks.find((t) => t.playerId === p);
1062
1074
  const used = track.turns.filter((x) => e.trackedTurns.includes(x.from));
1063
- rationale.push(`Tracked income for player ${p}: ~${e.tracked}/turn (${incomeBasis(track)}): ${used.map((x) => `turn ${x.from} +${x.observed}`).join(', ')}, each observed deploy a lower bound under fog${e.coverage ? `, read from ${coverageText(e.coverage)}` : ''}; at least its visible base + bonuses ${track.visibleIncome}; used in place of the single-turn observed figure (warapp_track_opponents has the details).`);
1075
+ rationale.push(`Tracked income for player ${p}: ~${e.trackCalibration ? e.trackCalibration.raw : e.tracked}/turn (${incomeBasis(track)}): ${used.map((x) => `turn ${x.from} +${x.observed}`).join(', ')}, each observed deploy a lower bound under fog${e.coverage ? `, read from ${coverageText(e.coverage)}` : ''}; at least its visible base + bonuses ${track.visibleIncome}; used in place of the single-turn observed figure (warapp_track_opponents has the details).`);
1076
+ }
1077
+ // #568: the tracked figure raised by past games' calibration in its coverage band.
1078
+ if (e.trackCalibration) {
1079
+ const c = e.trackCalibration;
1080
+ warnings.push(`Player ${p}'s tracked income ~${c.raw} is raised to ~${c.figure} (#568, draft): past games' tracker read ${c.geoMean.toFixed(2)}× the true income at this frontier coverage (${c.band}, ${c.n} samples), divided by its square root (${c.factor.toFixed(2)}).`);
1064
1081
  }
1065
1082
  // #427: a card play the tracker read as income, taken out of its figure.
1066
1083
  if (e.cardInTrack) {
@@ -193,7 +193,7 @@ export function withdrawals(pc, ps, book, threats, hb, prev) {
193
193
  export function reconsiderAndGarrison(pc, ps, book, threats, hb, prev) {
194
194
  const { g, guarded, reserve, paybackTurns, label, bonusName, mine, mineSet, unitsAt, toTake, myCommanders } = pc;
195
195
  const { warnings, rationale, deployed, locked, captured, moves } = ps;
196
- const { orderOf, deploy, pools, valueCache, cutCache, breachCache, opensCache, valueOf } = book;
196
+ const { orderOf, deploy, pools, valueCache, cutCache, breachCache, opensCache, hubCache, valueOf } = book;
197
197
  const local = pools !== null && pools.bonuses.length > 0;
198
198
  const { borders } = threats;
199
199
  const { conceded, kept, garrisoned } = hb;
@@ -211,6 +211,7 @@ export function reconsiderAndGarrison(pc, ps, book, threats, hb, prev) {
211
211
  cutCache.clear();
212
212
  breachCache.clear();
213
213
  opensCache.clear();
214
+ hubCache.clear();
214
215
  if (!conceded.size)
215
216
  return;
216
217
  for (const t of [...conceded].sort(byNum)) {
@@ -295,8 +296,7 @@ export function reconsiderAndGarrison(pc, ps, book, threats, hb, prev) {
295
296
  continue;
296
297
  const cost = todo.reduce((n, x) => n + x.d, 0);
297
298
  const worth = b.value + have / paybackTurns;
298
- // #421: the strike share holds back captures only, never this garrison.
299
- if (cost > paybackTurns * b.value || cost > CONCEDE_FACTOR * worth || cost > ps.budget - (reserve - pc.strikeShare))
299
+ if (cost > paybackTurns * b.value || cost > CONCEDE_FACTOR * worth || cost > ps.budget - reserve)
300
300
  continue;
301
301
  // The pools are checked for the members together: each may fit the free pool on its own
302
302
  // while together they overdraw it.
@@ -209,9 +209,6 @@
209
209
  // builds the same stack facing the opponent beside me whose visible armies mine outnumber
210
210
  // STOCKPILE_LEAD× (fewest first, then id; never an income estimate), never on my commander's
211
211
  // territory, and spends it as above ("Stockpile (#421): …").
212
- // #421, the strike share: in contact on a flat income (a stack built as above), STRIKE_SHARE
213
- // of the income is held out of captures for the stack (holds keep their exact need first),
214
- // unless that lowers next income (`planShare`) ("Strike share (#421): …").
215
212
  // #421, the break spend: on the pile (`pc.pile`), rule 4a runs the break of the strongest
216
213
  // opponent's cheapest visible bonus before every other capture, never skipped as a second
217
214
  // front ("Stockpile spend (#421): …").
@@ -549,7 +546,16 @@
549
546
  // loss opens (none containing it, none its cut or breach counts), with a line ("… is the only way in
550
547
  // to …"); and a territory whose loss opens held bonuses guards against a stack two steps away
551
548
  // (#172) like a bonus member, so the gate behind a conceded border keeps a hold — save when a stack
552
- // steps into that conceded border and makes it hold (#257), which cuts the reach. Its hold cost is the fewest
549
+ // steps into that conceded border and makes it hold (#257), which cuts the reach. #593: a hub — a member of
550
+ // a positive bonus of HUB_MIN_MEMBERS (4)+ members I hold in full (a bonus completed this turn too, once rule
551
+ // 1c counts the captures) that borders HUB_DEGREE (0.75) or more of its other members — also protects
552
+ // HUB_WEIGHT (0.6) × that bonus's value (its fall takes the rest, which comes back only member by member),
553
+ // counted once per bonus in rule 1h's unit worth, with a line ("… borders N of bonus …'s M other members: its
554
+ // fall takes the rest … (#593)"); no cut, breach or opens counts its own bonus. A unit that pays only for its hub
555
+ // share is funded first like any other, even before a larger completion, and gets a contested unit's
556
+ // floor before the captures (#118), so it is floored, never conceded bare, when it cannot be held whole
557
+ // (owner, 2026-11-27).
558
+ // Its hold cost is the fewest
553
559
  // deploys making `armiesToTake(armies + d) > threat`. Every border facing one
554
560
  // opponent is sized for that opponent's whole deploy (#69): it picks where to land
555
561
  // after I commit, so that is each border's worst case, and a sure hold of several
@@ -830,6 +836,11 @@
830
836
  // absorbed by its own neighbours' growth) and is now cheaper to take than it
831
837
  // was; never under `expand`/`defend`). Fogged or unknown neighbours are never attacked — they
832
838
  // produce a warning.
839
+ // #593: in a 1v1 under `balanced`, a member in view of an opponent bonus behind the fog (no member
840
+ // shown with another owner, one fogged, that member its with armies and beside mine) is a probable
841
+ // break target, and on turns 2–4 so is one of a bonus it is one neutral short of (worth
842
+ // ONE_SHORT_WEIGHT × the bonus); rule 4a sizes either for its defenders plus `partialDeploy` (its
843
+ // deploy estimate split over its territories beside my land), the rest as a break (plan/fogged-break.ts).
833
844
  // #430 (owner decision of 2026-11-22): under `balanced`, the opponents' territories that retake
834
845
  // a bonus I held in full on `previousBoard` are bonus targets too, in every format, when the retake
835
846
  // completes it this turn (every missing member in view, beside mine), costs at most RETAKE_VALUE_TURNS
@@ -1085,13 +1096,10 @@
1085
1096
  // territory my commander walks from — all that stands there is its transit hold (rule 1w,
1086
1097
  // `commanderTransit` sizes it on the whole stack); a commander that stays keeps its worst-case
1087
1098
  // hold through `keepOf`, as from any capture.
1088
- // #297, a 1v1 only: every border of mine facing the opponent is a gate, each sized for its stack plus the
1089
- // opponent's whole deploy, since that one deploy floats to whichever it picks. A capture that adds a gate is
1090
- // stopped when the frontier would then need more next turn than the next income and more than without it
1091
- // (`gateStop`, src/analysis/plan/captures.ts) — rule 4d's start-of-turn escape does not apply in a 1v1, and
1092
- // rule 4e's contact fallback, where 4d is only a cost (#114), runs it too. The plan reports `gates` (each gate's
1093
- // need and armies, conceded ones marked, the summed need, what stands on them, the per-gate deficit, the next
1094
- // income and the shortfall) and warns when its own captures open a gate the income cannot hold.
1099
+ // #297, a 1v1 only: the plan reports `gates` (each border of mine facing the opponent, its need and armies,
1100
+ // conceded ones marked, the summed need, what stands on them, the per-gate deficit, the next income and the
1101
+ // shortfall). #603: a report only — the veto and #432's short-gates horizon are gone; rule 4d's total counts
1102
+ // the opponent's one floating deploy once.
1095
1103
  // #426 (draft): a no-loss neutral (its defenders kill none of my attackers, `noLossNeutral`) is taken
1096
1104
  // by pass 3 even in an uneconomic bonus, and rule 4d lets one through when only the fog faces its new
1097
1105
  // border and the hold it adds is at most 1× the next income (`outgrows`, not in a 1v1); a stack idle two
@@ -1238,6 +1246,15 @@
1238
1246
  // 2, the `balanced` advance slots, #439's stage), pass 3 and rule 5b; never the bonus's own members, a
1239
1247
  // focused bonus, completions, holds, breaks, counters, the 1v1 race, strikes, rule 4e, 4g or 4h. What is
1240
1248
  // bound may still attack with the armies on my other territories. A "#319 binds the deploys" line says so.
1249
+ // #593 (plan/dead-advance.ts): no expansion capture (`tryExpand`: pass 2, the `balanced` advance slots,
1250
+ // pass 3, #439's stage, rule 5b) advances only bonuses whose other member I hold this plan concedes,
1251
+ // unless it completes one, is focused, is no-loss (#426), is land a static seat left, is a step of a bonus
1252
+ // this turn's captures could complete, breaks the bonus for the foe attacking a conceded member (owner,
1253
+ // 2026-11-27: his own member, or the one he would still lack), or every attack on it leaves a conceded border with no deploy; its
1254
+ // armies stay for the next candidate, with a "(#593)" line. A concession made after the capture, or a
1255
+ // completable bonus the plan leaves incomplete, is caught on the finished plan: planTurn plans again with
1256
+ // those bonuses carried (`PlanInput.deadAdvance`, `planAlive`, at most DEAD_PASSES times). Rule 4e's
1257
+ // never-stand-still fallback is not bound.
1241
1258
  // 3b. One surplus per territory (#121). A border that holds at the start of the turn (its armies
1242
1259
  // beat its visible threat, rule 1) and is not conceded keeps what holds it, as my commander's
1243
1260
  // territory does (rule 1k): a capture from it spends only its armies above that, plus deploys
@@ -1672,15 +1689,15 @@ import { neighborsOf } from './graph.js';
1672
1689
  import { forecastBorder, mainFront } from './exchange.js';
1673
1690
  import { byNum, pct } from './plan/util.js';
1674
1691
  import { SIEGE_BREAK_WEIGHT } from './plan/siege.js';
1692
+ import { ONE_SHORT_WEIGHT, partialDeploy } from './plan/fogged-break.js';
1675
1693
  import { ALL_IN_VALUE_TURNS, bonusVerdicts, DROP_TURNS, judgeAttempts } from './plan/bonus-attempts.js';
1676
1694
  import { planJabs } from './plan/jabs.js';
1677
- import { BREAK_WEIGHT, MIN_EXPANSION_SHARE, PLAIN_EXPANSION_LOSS, SECOND_FRONT_LEAD, SECOND_FRONT_SIMILAR, captureCost, } from './plan/shared.js';
1695
+ import { BREAK_WEIGHT, MIN_EXPANSION_SHARE, PLAIN_EXPANSION_LOSS, SECOND_FRONT_LEAD, SECOND_FRONT_SIMILAR, captureCost, visibleState, } from './plan/shared.js';
1678
1696
  import { emptyPlan, noteEstimates, planContext } from './plan/estimates.js';
1679
1697
  import { neutralizeSeats, seatTerritories, staticSeats } from './static-seats.js';
1680
1698
  import { deployBook } from './plan/orders.js';
1681
1699
  import { holdsPhase, priorOnlyHold } from './plan/holds.js';
1682
1700
  import { threatsPhase } from './plan/threats.js';
1683
- import { applyShortGates } from './plan/horizon.js';
1684
1701
  import { targetsPhase } from './plan/targets.js';
1685
1702
  import { capturesPhase } from './plan/captures.js';
1686
1703
  import { spreadBind } from './plan/spread-bind.js';
@@ -1688,7 +1705,8 @@ import { completedMembers } from './plan/completed.js';
1688
1705
  import { chooseStrikeStack, leadStrikes, spendStrikeStack, strikesPhase } from './plan/strike.js';
1689
1706
  import { contestedBonuses } from './plan/stockpile.js';
1690
1707
  import { warnIdleBesideFree } from './plan/free-capture.js';
1691
- import { afterLeftoverCaptures, onlyNoLoss, plainEconomy, plainEligible } from './plan/after-leftover.js';
1708
+ import { afterLeftoverCaptures, noLossNeutral, onlyNoLoss, plainEconomy, plainEligible } from './plan/after-leftover.js';
1709
+ import { deadAdvanceOf } from './plan/dead-advance.js';
1692
1710
  import { fundFromSecondSizing } from './plan/second-sizing.js';
1693
1711
  import { leftoverDeploy } from './plan/leftover.js';
1694
1712
  import { fillSecondLine, guardOffRaids } from './plan/guard-off.js';
@@ -1749,7 +1767,7 @@ export function planTurn(input) {
1749
1767
  // territories are planned as neutrals (static armies), and it is no opponent anywhere below.
1750
1768
  const seats = staticSeats(input.game?.players, input.game?.endRules, input.me);
1751
1769
  const held = seatTerritories(input.board, seats);
1752
- const plan = planPushed(withoutStaticSeats(input, seats));
1770
+ const plan = planAlive(withoutStaticSeats(input, seats));
1753
1771
  for (const [p, n] of [...held].sort((a, b) => a[0] - b[0]))
1754
1772
  plan.rationale.push(`Player ${p} is out (${seats.get(p)}) and no AI plays its seat: it deploys and attacks nothing, so its ${n} territor${n === 1 ? 'y is' : 'ies are'} planned as neutrals — static armies to take, no hold needed beside them (#270).`);
1755
1773
  return plan;
@@ -1788,6 +1806,38 @@ function withoutStaticSeats(input, seats) {
1788
1806
  ...(input.game && opening ? { game: { ...input.game, opening: new Map([...opening].filter(([p]) => !seats.has(p))) } } : {}),
1789
1807
  };
1790
1808
  }
1809
+ /** #593: per plan, the bonuses an expansion capture it kept advances though it concedes another member of them. */
1810
+ const deadOutcome = new WeakMap();
1811
+ /** #593: at most this many plans again, each carrying the dead bonuses the ones before found. */
1812
+ const DEAD_PASSES = 3;
1813
+ /**
1814
+ * #593: never advance a bonus whose other member the same plan concedes. The capture passes refuse such an
1815
+ * advance as they go (plan/dead-advance.ts), but a concession can come after the capture (the greedy concedes
1816
+ * pending holds as it runs): when the finished plan still advances one, it is planned again with that bonus
1817
+ * carried, so its armies go to the next candidate from the start, until no plan does (at most DEAD_PASSES times).
1818
+ */
1819
+ function planAlive(input) {
1820
+ let plan = planPushed(input);
1821
+ const carried = new Map(input.deadAdvance ?? []);
1822
+ for (let i = 0; i < DEAD_PASSES; i++) {
1823
+ const found = deadOutcome.get(plan);
1824
+ if (!found?.size)
1825
+ return plan;
1826
+ let grew = false;
1827
+ for (const [id, ms] of found) {
1828
+ const was = carried.get(id) ?? [];
1829
+ const next = [...new Set([...was, ...ms])].sort(byNum);
1830
+ if (next.length > was.length) {
1831
+ carried.set(id, next);
1832
+ grew = true;
1833
+ }
1834
+ }
1835
+ if (!grew)
1836
+ return plan;
1837
+ plan = planPushed({ ...input, deadAdvance: new Map(carried) });
1838
+ }
1839
+ return plan;
1840
+ }
1791
1841
  /** #298: per plan, the all-in pushes its pass sized (plan/targets.ts), by bonus id. */
1792
1842
  const allInOutcome = new WeakMap();
1793
1843
  /**
@@ -1855,11 +1905,11 @@ function planAttempts(input) {
1855
1905
  const turn = input.turn;
1856
1906
  const none = new Set();
1857
1907
  if (!input.bonusAttempts || turn === undefined)
1858
- return planShare(input.stockpileAllIn?.size ? withPush(input, none, none) : input);
1908
+ return planSettled(input.stockpileAllIn?.size ? withPush(input, none, none) : input);
1859
1909
  const judged = judgeAttempts(input.bonusAttempts, turn, input.graph, input.board, input.me);
1860
1910
  const verdicts = bonusVerdicts(judged, turn).filter((v) => input.graph.bonusById.has(v.bonusId));
1861
1911
  if (!verdicts.length)
1862
- return planShare(input.stockpileAllIn?.size ? withPush(input, none, none) : input);
1912
+ return planSettled(input.stockpileAllIn?.size ? withPush(input, none, none) : input);
1863
1913
  const entries = new Map();
1864
1914
  for (const v of verdicts)
1865
1915
  if (v.kind === 'dropped')
@@ -1884,7 +1934,7 @@ function planAttempts(input) {
1884
1934
  let plan;
1885
1935
  for (;;) {
1886
1936
  const ids = new Set(allIn.map((v) => v.bonusId));
1887
- plan = planShare(withPush(input, ids, new Set([...entries.keys()])));
1937
+ plan = planSettled(withPush(input, ids, new Set([...entries.keys()])));
1888
1938
  const tries = allInOutcome.get(plan);
1889
1939
  const taken = new Set(plan.expected.captures);
1890
1940
  const failing = allIn.flatMap((v) => {
@@ -1934,29 +1984,11 @@ function planAttempts(input) {
1934
1984
  plan.bonusPush = push;
1935
1985
  return plan;
1936
1986
  }
1937
- /** #421: per plan, the strike share its pass held out of captures (absent when none). */
1938
- const shareOutcome = new WeakMap();
1939
1987
  const closenessOutcome = new WeakMap();
1940
1988
  /** #505: rule 4f's nearest bonus and turns to finish for a plan `planTurn` made; `undefined` for any other object. */
1941
1989
  export function planCloseness(plan) {
1942
1990
  return closenessOutcome.get(plan);
1943
1991
  }
1944
- /**
1945
- * #421 (owner decision, 2026-11-20): the strike share is held out of captures, ahead of comfort margins,
1946
- * but never at the cost of next income — when the plan without it earns more next turn (a completion the
1947
- * share starves), that plan stands and says why.
1948
- */
1949
- function planShare(input) {
1950
- const plan = planSettled(input);
1951
- const share = shareOutcome.get(plan);
1952
- if (!share)
1953
- return plan;
1954
- const without = planSettled({ ...input, options: { ...input.options, strikeShare: false } });
1955
- if (without.expected.nextIncome <= plan.expected.nextIncome)
1956
- return plan;
1957
- without.rationale.push(`Strike share (#421) not held this turn: holding ${share} of the income out of captures for the strike stack would lower next income from ${without.expected.nextIncome} to ${plan.expected.nextIncome} (a capture it starves completes a bonus).`);
1958
- return without;
1959
- }
1960
1992
  function planSettled(input) {
1961
1993
  const plan = planRun(input, false);
1962
1994
  const bare = runOutcome.get(plan);
@@ -2035,16 +2067,13 @@ function planPass(input, pass) {
2035
2067
  const local = pools !== null && pools.bonuses.length > 0;
2036
2068
  // ---- 1t. threat trend, 1. defence (plan/threats.ts) ----
2037
2069
  const threats = threatsPhase(pc, ps, input, book.valueOf);
2038
- // #432: a 1v1 whose gates are short at the start judges its captures on a shorter payback horizon from here on
2039
- // (every capture test after this reads `pc.capturePaybackTurns`; holds keep `paybackTurns`).
2040
- applyShortGates(pc, ps, threats);
2041
2070
  const { growthOf, reinforcementAt, borders, facing, borderAt } = threats;
2042
2071
  // ---- 1. holds, #172, 1h, 1b, 1c, #122 garrisons (plan/holds.ts) ----
2043
2072
  const hd = holdsPhase(pc, ps, book, threats, pass);
2044
2073
  const { acting, conceded, concedeUnaffordable, floorOrConcede, fundNearMiss, fundUnit, garrisonCompleted, heldBorders, heldStack, hold, holds, keepFor, kept, keptShort, leftFor, mayComplete, mayHold, noteRecent, pendingLocks, reconsider, settleContested, twoStepBound, twoStepKeep, uneconomic, units, withdraw, overCap, chargeCap, concedeCapped, } = hd;
2045
2074
  // ---- 2. targets, 4d. frontier cost, bonus scoring, #101 (plan/targets.ts) ----
2046
2075
  const tgt = targetsPhase(pc, ps, input, threats, hd);
2047
- const { breakable, counterAt, targets, leadSteps, landScoreCost, offence, skipOffence, plans, ratio, committing, byCloseness, retakeChecks, retakeWarning, } = tgt;
2076
+ const { breakable, counterAt, targets, leadSteps, landScoreCost, offence, skipOffence, plans, ratio, committing, byCloseness, retakeChecks, retakeWarning, foggedBreaks, } = tgt;
2048
2077
  // #215 review: rule 1a's triage (run with the strikes, below) leaves pending a border in a bonus
2049
2078
  // these plans may complete this turn.
2050
2079
  for (const p of plans)
@@ -2053,6 +2082,8 @@ function planPass(input, pass) {
2053
2082
  // ---- R3, No-Split, capture helper, 3a. combined, passes 1 and 2 (plan/captures.ts) ----
2054
2083
  const caps = capturesPhase(pc, ps, pass, book, threats, hd, tgt);
2055
2084
  const { strikes, worstCase, defendersAt, tryCapture, snapshot, complete, tryExpand, advance } = caps;
2085
+ /** #593: the fogged breaks taken this turn, by target, with the partial deploy each was sized for. */
2086
+ const partialSized = new Map();
2056
2087
  /** #439: single-territory bonuses two moves away, each with its neutral in between. */
2057
2088
  const stages = twoMoveStages(pc, tgt);
2058
2089
  /** #416 part 4: while #319 fires, other advances and pass 3 wait for the nearest bonus's steps (plan/spread-bind.ts). */
@@ -2227,14 +2258,17 @@ function planPass(input, pass) {
2227
2258
  });
2228
2259
  // Capturing a member of a breakable bonus: what survives it, and whether that holds next turn.
2229
2260
  // A break is sized to land (#72): its score leaves out what holding it would need.
2230
- const breakOption = (t) => {
2261
+ const breakOption = (t, partial) => {
2231
2262
  // #201: the FFA leader's break is sized to land for certain against its owner's one deploy.
2232
- const landing = ffaLeader ? defenceAt(t) + reinforcementAt(t) : undefined;
2263
+ // #593: a break behind the fog, against a partial deploy (its owner's estimate split over its fronts).
2264
+ const landing = ffaLeader ? defenceAt(t) + reinforcementAt(t) : partial !== undefined ? defenceAt(t) + partial : undefined;
2233
2265
  const cost = (landing !== undefined ? captureCost(landing, s) : null) ?? targets.get(t).cost;
2234
2266
  const survivors = cost - straightKills(defenceAt(t), rates.defensiveKillRate);
2235
2267
  const counter = counterThreat(t);
2236
2268
  const take = toTake(survivors);
2237
- return { t, cost, survivors, counter, take, survives: take === null || take > counter, scoreCost: landScoreCost(t) };
2269
+ // #593: a fogged break's score pays for the partial deploy it is sized for.
2270
+ const scoreCost = partial !== undefined ? Math.max(1, landScoreCost(t) + cost - targets.get(t).cost) : landScoreCost(t);
2271
+ return { t, cost, survivors, counter, take, survives: take === null || take > counter, scoreCost };
2238
2272
  };
2239
2273
  /**
2240
2274
  * What a strike is worth (#72), in income terms like a hold's worth: the income the opponent
@@ -2320,7 +2354,7 @@ function planPass(input, pass) {
2320
2354
  /** The member a break of `b` takes: its cheapest visible member (#72: a break only has to land), then the least frontier, then id. */
2321
2355
  const breakOptionOf = (b) => bonusTerritories(g, b.bonusId)
2322
2356
  .filter((t) => targets.has(t))
2323
- .map(breakOption)
2357
+ .map((t) => breakOption(t))
2324
2358
  .sort((a, b) => a.cost - b.cost || a.scoreCost - b.scoreCost || a.t - b.t)[0];
2325
2359
  // #421 (owner decision, 2026-11-20): on a stockpile (`pc.pile`) the turn spends by breaking the strongest
2326
2360
  // opponent's cheapest visible bonus (every member in view: never a probable one) — ahead of every other
@@ -2347,7 +2381,7 @@ function planPass(input, pass) {
2347
2381
  // Its cheapest visible member (#72: a break only has to land), then the least frontier, then id.
2348
2382
  const options = bonusTerritories(g, b.bonusId)
2349
2383
  .filter((t) => targets.has(t))
2350
- .map(breakOption)
2384
+ .map((t) => breakOption(t))
2351
2385
  .sort((a, b) => a.cost - b.cost || a.scoreCost - b.scoreCost || a.t - b.t);
2352
2386
  const o = options[0];
2353
2387
  if (!o)
@@ -2414,6 +2448,90 @@ function planPass(input, pass) {
2414
2448
  }),
2415
2449
  });
2416
2450
  }
2451
+ // #593 (items 2 and 5a): in a 1v1, a bonus behind the fog a member in view of which is the opponent's
2452
+ // (plan/fogged-break.ts), and on the opening turns one it is a neutral short of, scored as rule 4a scores
2453
+ // a break (a denial at ONE_SHORT_WEIGHT of the bonus) and sized for a partial deploy: the opponent's
2454
+ // estimate on the target split over its territories in view beside my land. #240's sure size still
2455
+ // applies (tryCapture); #298's dropped members are never tried.
2456
+ /** The opponent's territories in view beside my land (its fronts, #593). */
2457
+ const frontsOf = (p) => [...state].filter(([id, st]) => visibleState(st)?.owner.kind === 'player' && st.owner.playerId === p && neighborsOf(g, id).some((n) => mineSet.has(n))).length;
2458
+ for (const fb of foggedBreaks) {
2459
+ const fronts = frontsOf(fb.player);
2460
+ const sizing = (t) => {
2461
+ const estimate = reinforcementAt(t);
2462
+ return { estimate, partial: partialDeploy(estimate, fronts) };
2463
+ };
2464
+ const o = fb.members
2465
+ .filter((t) => targets.has(t) && !tgt.droppedMembers.has(t))
2466
+ .map((t) => breakOption(t, sizing(t).partial))
2467
+ .sort((a, b) => a.cost - b.cost || a.scoreCost - b.scoreCost || a.t - b.t)[0];
2468
+ if (!o)
2469
+ continue;
2470
+ const { estimate, partial } = sizing(o.t);
2471
+ const value = fb.shortOf !== undefined ? fb.value * ONE_SHORT_WEIGHT : fb.value;
2472
+ const worth = strikeWorth(value, o);
2473
+ const score = worth / Math.max(1, o.scoreCost);
2474
+ const split = fronts > 1 ? `split over the ${fronts} territories of its beside my land, #593` : `its only territory beside my land, so the whole of it, #593`;
2475
+ const sized = `sized to land if player ${fb.player} deploys up to ${partial} of its ~${estimate} there first (${split})`;
2476
+ const head = fb.shortOf !== undefined
2477
+ ? `denies player ${fb.player} bonus ${bonusName(fb.bonusId)} (+${fb.value}), one territory short of complete (${label(fb.shortOf)} still neutral; opening strike, #593)`
2478
+ : `breaks probable enemy bonus ${bonusName(fb.bonusId)} (+${fb.value} from player ${fb.player}; ${fb.probable})`;
2479
+ const reason = `${head}, ${sized}`;
2480
+ rationale.push(fb.shortOf !== undefined
2481
+ ? `Player ${fb.player} is one territory short of bonus ${bonusName(fb.bonusId)} (+${fb.value}): ${label(o.t)} in view is its, beside my land, and ${label(fb.shortOf)} is still neutral; on an opening turn a strike there denies it (worth ${ONE_SHORT_WEIGHT} × the bonus) (#593).`
2482
+ : `Player ${fb.player} probably holds bonus ${bonusName(fb.bonusId)} (+${fb.value}): ${label(o.t)} in view is its, beside my land, and its ${fb.fogged} fogged member${fb.fogged > 1 ? 's' : ''} could all be its (#593).`);
2483
+ offence.set(`break:${fb.bonusId}`, { bonusId: fb.bonusId, target: o.t, kind: 'break', cost: o.cost, value: round2(worth), taken: false, why: head });
2484
+ candidates.push({
2485
+ kind: 'break',
2486
+ score,
2487
+ cost: o.cost,
2488
+ id: fb.bonusId,
2489
+ value,
2490
+ focus: false,
2491
+ borders: analyzeBonus(g, fb.bonusId).borderTerritoryIds.length,
2492
+ target: o.t,
2493
+ owner: fb.player,
2494
+ run: spend(() => {
2495
+ if (captured.has(o.t) || bonusTerritories(g, fb.bonusId).some((x) => captured.has(x)))
2496
+ return;
2497
+ // Sized for its defenders plus the partial deploy, a combined capture included (its softeners
2498
+ // wear that many down); no worst case once taken: #120 may still size it for the whole deploy,
2499
+ // and its "assumes" warning gives the win chance against it.
2500
+ const tg = targets.get(o.t);
2501
+ const raised = o.cost > tg.cost;
2502
+ const was = worstCase.get(o.t);
2503
+ if (raised)
2504
+ targets.set(o.t, { ...tg, cost: o.cost });
2505
+ worstCase.set(o.t, Math.max(was ?? 0, defenceAt(o.t) + partial));
2506
+ const ok = tryCapture(o.t, reason);
2507
+ if (raised)
2508
+ targets.set(o.t, tg);
2509
+ if (!ok) {
2510
+ if (was === undefined)
2511
+ worstCase.delete(o.t);
2512
+ else
2513
+ worstCase.set(o.t, was);
2514
+ return;
2515
+ }
2516
+ // Sent enough for the whole deploy (one front, or #240's sure size): a worst case, no warning.
2517
+ const sent = moves.filter((m) => m.kind === 'attack' && m.to === o.t).reduce((n, m) => n + m.armies, 0);
2518
+ const whole = costAt(o.t, defenceAt(o.t) + estimate);
2519
+ if (whole !== null && sent >= whole && !combined.has(o.t))
2520
+ worstCase.set(o.t, Math.max(was ?? 0, defenceAt(o.t) + estimate));
2521
+ else {
2522
+ if (was === undefined)
2523
+ worstCase.delete(o.t);
2524
+ else
2525
+ worstCase.set(o.t, was);
2526
+ const assumes = `Attack on enemy ${label(o.t)} assumes its owner does not reinforce it first.`;
2527
+ if (was === undefined && !warnings.includes(assumes))
2528
+ warnings.push(assumes);
2529
+ }
2530
+ partialSized.set(o.t, partial);
2531
+ ps.anchor ??= moves[moves.length - 1].from;
2532
+ }),
2533
+ });
2534
+ }
2417
2535
  // Counter-attacks (#72): a stack that shrank fighting me, scored like a break that breaks no
2418
2536
  // bonus (the armies its owner must spend to retake it). It is already fighting me (it
2419
2537
  // attacked me, or held off my attack), so it is never a second front.
@@ -3359,7 +3477,10 @@ function planPass(input, pass) {
3359
3477
  const d = defenceAt(m.to);
3360
3478
  const full = costAt(m.to, d + extra);
3361
3479
  const aim = chanceAt(m.to);
3362
- warnings[w] = `Attack on enemy ${label(m.to)} assumes its owner does not reinforce it first: if player ${st.owner.playerId} deploys its ~${extra} there, ${m.armies} attack ${d + extra} (win chance ${pct(chanceOf(m.armies, d + extra))})${full !== null ? `; ${full} would ${aim >= 1 ? 'be sure' : `reach ${pct(aim)}`}` : ''}.`;
3480
+ // #593: a fogged break sized for a partial deploy says so.
3481
+ const part = partialSized.get(m.to);
3482
+ const sizedFor = part !== undefined && part > 0 && part < extra ? ` (sized for a partial deploy of ${part} (#593))` : '';
3483
+ warnings[w] = `Attack on enemy ${label(m.to)} assumes its owner does not reinforce it first${sizedFor}: if player ${st.owner.playerId} deploys its ~${extra} there, ${m.armies} attack ${d + extra} (win chance ${pct(chanceOf(m.armies, d + extra))})${full !== null ? `; ${full} would ${aim >= 1 ? 'be sure' : `reach ${pct(aim)}`}` : ''}.`;
3363
3484
  }
3364
3485
  // ---- #361: single-army jabs from the armies still idle beyond each hold (plan/jabs.ts) ----
3365
3486
  const jabsOn = pc.opts.jabs ?? pc.siege !== undefined;
@@ -3454,10 +3575,22 @@ function planPass(input, pass) {
3454
3575
  if (!heldBorders.has(m.id))
3455
3576
  unheld.add(m.id);
3456
3577
  runOutcome.set(plan, { bareSteps: [...caps.bareTaken].filter(gone).sort(byNum), held, unheld });
3578
+ // #593: an expansion capture the finished plan keeps though it concedes another member of every bonus it
3579
+ // advances (conceded after the capture was made): planTurn plans again with those bonuses carried.
3580
+ {
3581
+ const dead = new Map();
3582
+ const after = book.heldNow();
3583
+ for (const t of [...ps.expanded].filter(gone).sort(byNum)) {
3584
+ if (caps.givenUp(t) || noLossNeutral(pc, tgt, t))
3585
+ continue;
3586
+ for (const d of deadAdvanceOf(pc, t, after, conceded, new Map()) ?? [])
3587
+ dead.set(d.bonusId, [...new Set([...(dead.get(d.bonusId) ?? []), ...d.members])].sort(byNum));
3588
+ }
3589
+ if (dead.size)
3590
+ deadOutcome.set(plan, dead);
3591
+ }
3457
3592
  if (tgt.allInTries.size)
3458
3593
  allInOutcome.set(plan, tgt.allInTries);
3459
- if (pc.strikeShare > 0)
3460
- shareOutcome.set(plan, pc.strikeShare);
3461
3594
  {
3462
3595
  const nearest = tgt.committing ? (tgt.byCloseness.find((p) => !p.focus) ?? tgt.byCloseness[0]) : undefined;
3463
3596
  const near = tgt.spreadNearest ?? nearest;