@chrischall/warapp-mcp 0.19.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.
@@ -296,8 +296,7 @@ export function reconsiderAndGarrison(pc, ps, book, threats, hb, prev) {
296
296
  continue;
297
297
  const cost = todo.reduce((n, x) => n + x.d, 0);
298
298
  const worth = b.value + have / paybackTurns;
299
- // #421: the strike share holds back captures only, never this garrison.
300
- 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)
301
300
  continue;
302
301
  // The pools are checked for the members together: each may fit the free pool on its own
303
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): …").
@@ -1099,13 +1096,10 @@
1099
1096
  // territory my commander walks from — all that stands there is its transit hold (rule 1w,
1100
1097
  // `commanderTransit` sizes it on the whole stack); a commander that stays keeps its worst-case
1101
1098
  // hold through `keepOf`, as from any capture.
1102
- // #297, a 1v1 only: every border of mine facing the opponent is a gate, each sized for its stack plus the
1103
- // opponent's whole deploy, since that one deploy floats to whichever it picks. A capture that adds a gate is
1104
- // stopped when the frontier would then need more next turn than the next income and more than without it
1105
- // (`gateStop`, src/analysis/plan/captures.ts) — rule 4d's start-of-turn escape does not apply in a 1v1, and
1106
- // rule 4e's contact fallback, where 4d is only a cost (#114), runs it too. The plan reports `gates` (each gate's
1107
- // need and armies, conceded ones marked, the summed need, what stands on them, the per-gate deficit, the next
1108
- // 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.
1109
1103
  // #426 (draft): a no-loss neutral (its defenders kill none of my attackers, `noLossNeutral`) is taken
1110
1104
  // by pass 3 even in an uneconomic bonus, and rule 4d lets one through when only the fog faces its new
1111
1105
  // border and the hold it adds is at most 1× the next income (`outgrows`, not in a 1v1); a stack idle two
@@ -1704,7 +1698,6 @@ import { neutralizeSeats, seatTerritories, staticSeats } from './static-seats.js
1704
1698
  import { deployBook } from './plan/orders.js';
1705
1699
  import { holdsPhase, priorOnlyHold } from './plan/holds.js';
1706
1700
  import { threatsPhase } from './plan/threats.js';
1707
- import { applyShortGates } from './plan/horizon.js';
1708
1701
  import { targetsPhase } from './plan/targets.js';
1709
1702
  import { capturesPhase } from './plan/captures.js';
1710
1703
  import { spreadBind } from './plan/spread-bind.js';
@@ -1912,11 +1905,11 @@ function planAttempts(input) {
1912
1905
  const turn = input.turn;
1913
1906
  const none = new Set();
1914
1907
  if (!input.bonusAttempts || turn === undefined)
1915
- return planShare(input.stockpileAllIn?.size ? withPush(input, none, none) : input);
1908
+ return planSettled(input.stockpileAllIn?.size ? withPush(input, none, none) : input);
1916
1909
  const judged = judgeAttempts(input.bonusAttempts, turn, input.graph, input.board, input.me);
1917
1910
  const verdicts = bonusVerdicts(judged, turn).filter((v) => input.graph.bonusById.has(v.bonusId));
1918
1911
  if (!verdicts.length)
1919
- return planShare(input.stockpileAllIn?.size ? withPush(input, none, none) : input);
1912
+ return planSettled(input.stockpileAllIn?.size ? withPush(input, none, none) : input);
1920
1913
  const entries = new Map();
1921
1914
  for (const v of verdicts)
1922
1915
  if (v.kind === 'dropped')
@@ -1941,7 +1934,7 @@ function planAttempts(input) {
1941
1934
  let plan;
1942
1935
  for (;;) {
1943
1936
  const ids = new Set(allIn.map((v) => v.bonusId));
1944
- plan = planShare(withPush(input, ids, new Set([...entries.keys()])));
1937
+ plan = planSettled(withPush(input, ids, new Set([...entries.keys()])));
1945
1938
  const tries = allInOutcome.get(plan);
1946
1939
  const taken = new Set(plan.expected.captures);
1947
1940
  const failing = allIn.flatMap((v) => {
@@ -1991,29 +1984,11 @@ function planAttempts(input) {
1991
1984
  plan.bonusPush = push;
1992
1985
  return plan;
1993
1986
  }
1994
- /** #421: per plan, the strike share its pass held out of captures (absent when none). */
1995
- const shareOutcome = new WeakMap();
1996
1987
  const closenessOutcome = new WeakMap();
1997
1988
  /** #505: rule 4f's nearest bonus and turns to finish for a plan `planTurn` made; `undefined` for any other object. */
1998
1989
  export function planCloseness(plan) {
1999
1990
  return closenessOutcome.get(plan);
2000
1991
  }
2001
- /**
2002
- * #421 (owner decision, 2026-11-20): the strike share is held out of captures, ahead of comfort margins,
2003
- * but never at the cost of next income — when the plan without it earns more next turn (a completion the
2004
- * share starves), that plan stands and says why.
2005
- */
2006
- function planShare(input) {
2007
- const plan = planSettled(input);
2008
- const share = shareOutcome.get(plan);
2009
- if (!share)
2010
- return plan;
2011
- const without = planSettled({ ...input, options: { ...input.options, strikeShare: false } });
2012
- if (without.expected.nextIncome <= plan.expected.nextIncome)
2013
- return plan;
2014
- 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).`);
2015
- return without;
2016
- }
2017
1992
  function planSettled(input) {
2018
1993
  const plan = planRun(input, false);
2019
1994
  const bare = runOutcome.get(plan);
@@ -2092,9 +2067,6 @@ function planPass(input, pass) {
2092
2067
  const local = pools !== null && pools.bonuses.length > 0;
2093
2068
  // ---- 1t. threat trend, 1. defence (plan/threats.ts) ----
2094
2069
  const threats = threatsPhase(pc, ps, input, book.valueOf);
2095
- // #432: a 1v1 whose gates are short at the start judges its captures on a shorter payback horizon from here on
2096
- // (every capture test after this reads `pc.capturePaybackTurns`; holds keep `paybackTurns`).
2097
- applyShortGates(pc, ps, threats);
2098
2070
  const { growthOf, reinforcementAt, borders, facing, borderAt } = threats;
2099
2071
  // ---- 1. holds, #172, 1h, 1b, 1c, #122 garrisons (plan/holds.ts) ----
2100
2072
  const hd = holdsPhase(pc, ps, book, threats, pass);
@@ -3619,8 +3591,6 @@ function planPass(input, pass) {
3619
3591
  }
3620
3592
  if (tgt.allInTries.size)
3621
3593
  allInOutcome.set(plan, tgt.allInTries);
3622
- if (pc.strikeShare > 0)
3623
- shareOutcome.set(plan, pc.strikeShare);
3624
3594
  {
3625
3595
  const nearest = tgt.committing ? (tgt.byCloseness.find((p) => !p.focus) ?? tgt.byCloseness[0]) : undefined;
3626
3596
  const near = tgt.spreadNearest ?? nearest;