@chrischall/warapp-mcp 0.21.0 → 0.22.1

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.
package/dist/bundle.js CHANGED
@@ -101781,6 +101781,7 @@ function newPlanState() {
101781
101781
  staged: /* @__PURE__ */ new Map(),
101782
101782
  anchor: void 0,
101783
101783
  assumeGone: () => false,
101784
+ breakTarget: void 0,
101784
101785
  refusal: void 0,
101785
101786
  evenTradesOnly: false,
101786
101787
  plainRepulsed: false,
@@ -104860,13 +104861,14 @@ function floorTier(pc, ps, book, threats, hb, prev) {
104860
104861
  }
104861
104862
  };
104862
104863
  const settleContested = (mode = false) => {
104863
- const wholeOnly = mode !== false;
104864
+ const wholeOnly = mode === true || mode === "untrusted";
104865
+ const flooredOnly = mode === "floored";
104864
104866
  const facesUntrusted = (u) => u.members.some((m) => {
104865
104867
  const b = borders.get(m.id);
104866
104868
  return !heldBorders.has(m.id) && b !== void 0 && pc.untrustedAt(b.player, m.id) > 0;
104867
104869
  });
104868
104870
  const open5 = units.filter(
104869
- (u) => u.contested && !u.conceded && (mode === "untrusted" ? facesUntrusted(u) : !wholeOnly || u.loss !== "payback")
104871
+ (u) => u.contested && !u.conceded && (flooredOnly ? u.floored : mode === "untrusted" ? facesUntrusted(u) : !wholeOnly || u.loss !== "payback")
104870
104872
  );
104871
104873
  if (!open5.length) {
104872
104874
  if (mode === "untrusted") fillUntrustedGates([]);
@@ -104919,7 +104921,7 @@ function floorTier(pc, ps, book, threats, hb, prev) {
104919
104921
  if (more <= ps.budget && fundUnit(
104920
104922
  u,
104921
104923
  void 0,
104922
- `Hold bonus ${bonusName(u.bonusId)} (+${u.value}) whole: ${floored ? "past its floor " : ""}its ${unitBorders(u)} need${u.members.length === 1 ? "s" : ""} ${more}${floored ? " more" : ""}${why ? ` (${why})` : ""}, ${mode === "untrusted" ? `before any capture: player ${[...new Set(u.members.flatMap((m) => {
104924
+ `Hold bonus ${bonusName(u.bonusId)} (+${u.value}) whole: ${floored ? "past its floor " : ""}its ${unitBorders(u)} need${u.members.length === 1 ? "s" : ""} ${more}${floored ? " more" : ""}${why ? ` (${why})` : ""}, ${flooredOnly ? "before any expansion that completes no bonus (1v1 in contact: a home bonus under attack comes before a far advance)." : mode === "untrusted" ? `before any capture: player ${[...new Set(u.members.flatMap((m) => {
104923
104925
  const b = borders.get(m.id);
104924
104926
  return b && pc.untrustedAt(b.player, m.id) > 0 ? [b.player] : [];
104925
104927
  }))].sort((a, b) => a - b).join(", ")}'s estimate is untrusted (#275), so the border is held ahead of expansion.` : wholeOnly ? "before any expansion that completes no bonus (1v1 in contact: an advance ranks below every hold)." : "and nothing else this turn uses those armies."}`
@@ -104936,7 +104938,7 @@ function floorTier(pc, ps, book, threats, hb, prev) {
104936
104938
  }
104937
104939
  if (mode === "untrusted") fillUntrustedGates(open5.filter((u) => u.contested));
104938
104940
  if (wholeOnly) return;
104939
- const short = units.filter((u) => u.contested && !u.conceded).flatMap((u) => u.members.filter((m) => !heldBorders.has(m.id)).map((m) => ({ m, u })));
104941
+ const short = units.filter((u) => u.contested && !u.conceded && (!flooredOnly || u.floored)).flatMap((u) => u.members.filter((m) => !heldBorders.has(m.id)).map((m) => ({ m, u })));
104940
104942
  const value = (m) => Math.max(...short.filter((x) => x.m === m).map((x) => x.u.value));
104941
104943
  const members2 = [...new Set(short.map((x) => x.m))];
104942
104944
  const given2 = /* @__PURE__ */ new Map();
@@ -104956,6 +104958,14 @@ function floorTier(pc, ps, book, threats, hb, prev) {
104956
104958
  m.holdCost <= 0 ? `Deploy ${n} more to ${label3(m.id)} so it holds (${m.have} armies, ${toTake(m.have + m.units)} to take, above the ~${m.threat} threat).` : `Deploy ${n} more to ${label3(m.id)} against the one shared deploy: ${m.have} armies, so player ${borders.get(m.id)?.player}'s deploy needs ${breakCost(m)} of its ~${deployShare(m)} there to take it.`
104957
104959
  );
104958
104960
  for (const m of members2) if (m.holdCost <= 0) heldBorders.add(m.id);
104961
+ if (flooredOnly && given2.size)
104962
+ rationale.push(
104963
+ `1v1 in contact: what is left goes to the borders of ${[...new Set(short.map((x) => x.u))].map((u) => `${bonusName(u.bonusId)} (+${u.value})`).join(", ")} before any advance that completes nothing this turn \u2014 a home bonus the opponent's one stack can break is worth more than a far step toward another.`
104964
+ );
104965
+ if (flooredOnly) {
104966
+ for (const u of open5) if (u.members.every((m) => heldBorders.has(m.id))) u.contested = false;
104967
+ return;
104968
+ }
104959
104969
  const stillShort = [];
104960
104970
  for (const u of units) {
104961
104971
  if (!u.contested || u.conceded) continue;
@@ -107136,7 +107146,8 @@ function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
107136
107146
  });
107137
107147
  const leadConceded = (x, t) => leadSteps.has(t) && conceded.has(x) && !myCommanders.has(x);
107138
107148
  const fundedOnConceded = /* @__PURE__ */ new Set();
107139
- const concededSource = (x, t, cost) => concededSourceBase(x, t, cost) || leadConceded(x, t);
107149
+ const breakConceded = (x, t) => ps.breakTarget === t && conceded.has(x) && !myCommanders.has(x);
107150
+ const concededSource = (x, t, cost) => concededSourceBase(x, t, cost) || leadConceded(x, t) || breakConceded(x, t);
107140
107151
  const holdSource = (x, t) => leadSteps.has(t) && locked.has(x) && !conceded.has(x) && !myCommanders.has(x);
107141
107152
  const holdKeep = (x, t) => {
107142
107153
  const b = borderAt(x, (n) => captured.has(n) || n === t);
@@ -107266,6 +107277,7 @@ function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
107266
107277
  const farKeep = far ? twoStepKeep(src, (n) => n === t) : 0;
107267
107278
  const farBinds = far !== null && farKeep > 0 && farKeep >= keepOf(src, t);
107268
107279
  const viaLead = !fromHold && !force && need2 > 0 && src !== fromConceded && leadConceded(src, t) && !concededSourceBase(src, t, tg.cost);
107280
+ const viaBreak = !viaLead && !fromHold && !force && need2 > 0 && src !== fromConceded && breakConceded(src, t) && !concededSourceBase(src, t, tg.cost);
107269
107281
  deploy(src, need2);
107270
107282
  const sent = noSplit ? Math.max(tg.cost, avail.get(src)) : tg.cost;
107271
107283
  avail.set(src, avail.get(src) - sent);
@@ -107302,6 +107314,10 @@ function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
107302
107314
  rationale.push(
107303
107315
  `${label3(src)} is conceded, but the deploy there leaves with the attack on ${label3(t)}: a lead step into a bonus (rule 4f's order) may be funded on a conceded source, the deploy sized for the attack alone (#214).`
107304
107316
  );
107317
+ } else if (viaBreak) {
107318
+ rationale.push(
107319
+ `${label3(src)} is conceded, but the deploy there leaves with the attack on ${label3(t)}: a break may be funded on a conceded source, the deploy sized for the attack alone (#593).`
107320
+ );
107305
107321
  } else if (farBinds) rationale.push(twoStepCite(src, far, (c) => `The attack on ${label3(t)} leaves ${label3(src)} ${c}.`));
107306
107322
  else if (forHold > 0) {
107307
107323
  const th = borderAt(src, (n) => captured.has(n));
@@ -107913,6 +107929,12 @@ function guardOffExposure(args) {
107913
107929
  const left = /* @__PURE__ */ new Map();
107914
107930
  for (const t of board.territories) if (isMine3(t.territoryId)) left.set(t.territoryId, t.armies ?? 0);
107915
107931
  for (const d of args.deploys) if (left.has(d.territoryId)) left.set(d.territoryId, left.get(d.territoryId) + d.armies);
107932
+ for (const a of args.airlifts ?? []) {
107933
+ if (!left.has(a.from) || !left.has(a.to)) continue;
107934
+ const sent = Math.min(a.armies, left.get(a.from));
107935
+ left.set(a.from, left.get(a.from) - sent);
107936
+ left.set(a.to, left.get(a.to) + sent);
107937
+ }
107916
107938
  for (const m of args.moves) {
107917
107939
  if (left.has(m.from)) left.set(m.from, Math.max(0, left.get(m.from) - m.armies));
107918
107940
  if (left.has(m.to)) left.set(m.to, left.get(m.to) + m.armies);
@@ -111839,7 +111861,8 @@ function reportOffence(pc, ps, book, threats, hd, tgt, holdLocked, leadSpareFor)
111839
111861
  leadLever,
111840
111862
  ffaLeader,
111841
111863
  leadText,
111842
- myCommanders
111864
+ myCommanders,
111865
+ guard
111843
111866
  } = pc;
111844
111867
  const { warnings, rationale, deployed, avail, spared, unabsorbed, captured, moves } = ps;
111845
111868
  const { gainWith, orderOf, pools, coverOf } = book;
@@ -111952,6 +111975,17 @@ function reportOffence(pc, ps, book, threats, hd, tgt, holdLocked, leadSpareFor)
111952
111975
  const st = state.get(n);
111953
111976
  return !mineSet.has(n) && !attacked.has(n) && st?.owner.kind === "player" && foe(st.owner.playerId) && st.armies !== null;
111954
111977
  });
111978
+ const baitNote = (n) => {
111979
+ const owner = state.get(n).owner;
111980
+ const stacks = neighborsOf(g, n).flatMap((x) => {
111981
+ const st = state.get(x);
111982
+ return st && st.armies !== null && st.owner.kind === "player" && owner.kind === "player" && st.owner.playerId === owner.playerId && st.armies > guard ? [{ x, moves: st.armies - guard }] : [];
111983
+ }).sort((a, b) => b.moves - a.moves || a.x - b.x);
111984
+ if (!stacks.length) return "";
111985
+ const k = stacks.reduce((t, s) => t + s.moves, 0);
111986
+ const then = costAt(n, defenceAt(n) + k);
111987
+ return `; its stacks beside it can move ${k} in before an attack lands (${stacks.map((s) => `${label3(s.x)} ${s.moves}`).join(", ")}): ${then === null ? "no attack takes it then" : `${then} to take it then`} (#593)`;
111988
+ };
111955
111989
  const reasonFor = (n) => {
111956
111990
  const st = state.get(n);
111957
111991
  const p = st.owner.playerId;
@@ -111986,8 +112020,8 @@ function reportOffence(pc, ps, book, threats, hd, tgt, holdLocked, leadSpareFor)
111986
112020
  return `a lead strike (my army lead is ${leadText()}, over ${SECOND_FRONT_LEAD}\xD7) needs ${sure} \u2014 sized for its ${defenceAt(n)} defenders plus player ${p}'s ~${extra} deploy \u2014 and the most a neighbour of mine can spare for it is ${lead.spare}${lead.spare > 0 ? ` (${label3(lead.x)})` : ""}${deployText}`;
111987
112021
  }
111988
112022
  if (tgt.foggedMember.has(n))
111989
- return `${label3(best.x)} could spare ${best.spare} for it, and it probably breaks a bonus behind the fog (#593), but that break, sized for a partial deploy, did not fit or ranked below what the turn funded`;
111990
- return `${label3(best.x)} could spare ${best.spare} for it, but it breaks no bonus and is no counter-attack, finishing blow or strike \u2014 the only reasons the plan attacks a player's territory (rule 2), besides rule 4e's fallback when nothing else is captured${!ffaLead ? "" : !leadLever ? ` (a lead strike takes one only with an army lead over ${SECOND_FRONT_LEAD}\xD7; mine is ${leadText()})` : noSplit ? ` (no lead strike under No-Split: an order carries the whole stack)` : ""}`;
112023
+ return `${label3(best.x)} could spare ${best.spare} for it, and it probably breaks a bonus behind the fog (#593), but that break, sized for a partial deploy, did not fit or ranked below what the turn funded${baitNote(n)}`;
112024
+ return `${label3(best.x)} could spare ${best.spare} for it, but it breaks no bonus and is no counter-attack, finishing blow or strike \u2014 the only reasons the plan attacks a player's territory (rule 2), besides rule 4e's fallback when nothing else is captured${!ffaLead ? "" : !leadLever ? ` (a lead strike takes one only with an army lead over ${SECOND_FRONT_LEAD}\xD7; mine is ${leadText()})` : noSplit ? ` (no lead strike under No-Split: an order carries the whole stack)` : ""}${baitNote(n)}`;
111991
112025
  };
111992
112026
  const capNote = (n) => {
111993
112027
  const why = ps.capRefused.get(n);
@@ -112716,6 +112750,14 @@ function planPass(input2, pass) {
112716
112750
  });
112717
112751
  return true;
112718
112752
  };
112753
+ const asBreak = (t, f) => {
112754
+ ps.breakTarget = t;
112755
+ try {
112756
+ return f();
112757
+ } finally {
112758
+ ps.breakTarget = void 0;
112759
+ }
112760
+ };
112719
112761
  const breakOptionOf = (b) => bonusTerritories(g, b.bonusId).filter((t) => targets.has(t)).map((t) => breakOption(t)).sort((a, b2) => a.cost - b2.cost || a.scoreCost - b2.scoreCost || a.t - b2.t)[0];
112720
112762
  const pileBreak = (() => {
112721
112763
  if (!pc.pile) return void 0;
@@ -112774,13 +112816,13 @@ function planPass(input2, pass) {
112774
112816
  const was = worstCase.get(o.t);
112775
112817
  targets.set(o.t, { ...tg, cost: o.cost });
112776
112818
  worstCase.set(o.t, defenceAt(o.t) + reinforcementAt(o.t));
112777
- if (!tryCapture(o.t, reasonOf2(`${breakReason(b)}, sized to land against player ${b.player}'s ~${reinforcementAt(o.t)} deploy (#201: I lead this free-for-all)`))) {
112819
+ if (!asBreak(o.t, () => tryCapture(o.t, reasonOf2(`${breakReason(b)}, sized to land against player ${b.player}'s ~${reinforcementAt(o.t)} deploy (#201: I lead this free-for-all)`)))) {
112778
112820
  targets.set(o.t, tg);
112779
112821
  if (was === void 0) worstCase.delete(o.t);
112780
112822
  else worstCase.set(o.t, was);
112781
112823
  return;
112782
112824
  }
112783
- } else if (!tryCapture(o.t, reasonOf2(breakReason(b)))) return;
112825
+ } else if (!asBreak(o.t, () => tryCapture(o.t, reasonOf2(breakReason(b))))) return;
112784
112826
  ps.anchor ??= moves[moves.length - 1].from;
112785
112827
  warnRetake(b, o);
112786
112828
  })
@@ -112824,7 +112866,7 @@ function planPass(input2, pass) {
112824
112866
  const was = worstCase.get(o.t);
112825
112867
  if (raised) targets.set(o.t, { ...tg, cost: o.cost });
112826
112868
  worstCase.set(o.t, Math.max(was ?? 0, defenceAt(o.t) + partial2));
112827
- const ok = tryCapture(o.t, reason);
112869
+ const ok = asBreak(o.t, () => tryCapture(o.t, reason));
112828
112870
  if (raised) targets.set(o.t, tg);
112829
112871
  if (!ok) {
112830
112872
  if (was === void 0) worstCase.delete(o.t);
@@ -113058,7 +113100,7 @@ function planPass(input2, pass) {
113058
113100
  const left = expansionLeft;
113059
113101
  c.run();
113060
113102
  const after2 = new Set(fundable(pending, ps.budget));
113061
- const starved = before.filter((u) => !after2.has(u));
113103
+ const starved = before.filter((u) => !after2.has(u) && !(u.hubOnly && u.floored));
113062
113104
  const lost = starved.reduce((n, u) => n + u.value, 0);
113063
113105
  const kept2 = starved.map((u) => keptShort(u, local ? Math.min(ps.budget, leftFor(u)) : ps.budget));
113064
113106
  const conceding = starved.filter((_, i2) => !kept2[i2]).reduce((n, u) => n + u.value, 0);
@@ -113076,6 +113118,7 @@ function planPass(input2, pass) {
113076
113118
  for (const c of postponed.splice(0)) c.run();
113077
113119
  };
113078
113120
  let contestedDue = false;
113121
+ let flooredDue = false;
113079
113122
  let untrustedDue = false;
113080
113123
  candidates2.forEach((c, i2) => {
113081
113124
  if (done.has(c)) return;
@@ -113087,6 +113130,10 @@ function planPass(input2, pass) {
113087
113130
  contestedDue = true;
113088
113131
  settleContested(true);
113089
113132
  }
113133
+ if (oneVsOne && (c.kind === "advance" || c.kind === "stage") && !c.focus && !flooredDue) {
113134
+ flooredDue = true;
113135
+ settleContested("floored");
113136
+ }
113090
113137
  if (completesNothing(c) && !c.focus && !unitsDue) {
113091
113138
  unitsDue = true;
113092
113139
  for (const u of waiting.splice(0)) fundOrConcede(u);
@@ -116117,7 +116164,7 @@ function serverBuild() {
116117
116164
  }
116118
116165
 
116119
116166
  // src/version.ts
116120
- var VERSION2 = "0.21.0";
116167
+ var VERSION2 = "0.22.1";
116121
116168
 
116122
116169
  // src/decision-log.ts
116123
116170
  var DECISION_LOG_VERSION = 1;
@@ -144881,7 +144928,7 @@ function lessonsSummary(file2) {
144881
144928
  }
144882
144929
  return { games, byFormat, calibration: calibrationSummary(all2), ...excludedCounts(file2.excluded) };
144883
144930
  }
144884
- function outlookCalibration(file2, format, min) {
144931
+ function outlookCalibration(file2, format, min, opts = {}) {
144885
144932
  let all2 = {};
144886
144933
  for (const f of PROFILE_FORMATS) {
144887
144934
  const t = file2.byFormat[f];
@@ -144890,7 +144937,7 @@ function outlookCalibration(file2, format, min) {
144890
144937
  const own2 = file2.byFormat[format]?.calibration ?? {};
144891
144938
  const out = {};
144892
144939
  for (const k of COVERAGE_BUCKETS) {
144893
- const x = (own2[k]?.n ?? 0) >= min ? own2[k] : all2[k];
144940
+ const x = (own2[k]?.n ?? 0) >= min ? own2[k] : opts.ownOnly ? void 0 : all2[k];
144894
144941
  if (!x || x.n < min) continue;
144895
144942
  out[k] = { geoMean: r2(Math.exp(x.logSum / x.n)), n: x.n };
144896
144943
  }
@@ -146626,6 +146673,17 @@ async function outlookCalibrationFor(dataDir2, env, format) {
146626
146673
  return void 0;
146627
146674
  }
146628
146675
  }
146676
+ async function trackCalibrationFor(dataDir2, env, format) {
146677
+ if (format === "1v1" || !dataDir2 || !profileEnabled(env ?? process.env)) return void 0;
146678
+ try {
146679
+ const file2 = await readLessons(dataDir2);
146680
+ if (file2 === "unreadable") return void 0;
146681
+ const c = outlookCalibration(file2, format, MIN_CALIBRATION_SAMPLES, { ownOnly: true });
146682
+ return Object.keys(c).length ? c : void 0;
146683
+ } catch {
146684
+ return void 0;
146685
+ }
146686
+ }
146629
146687
 
146630
146688
  // src/analysis/whereabouts.ts
146631
146689
  var REACH_HORIZON = 12;
@@ -148732,6 +148790,12 @@ function stressPlan(input2) {
148732
148790
  for (const s of stacks) {
148733
148791
  const dep = deployOn(opp, s);
148734
148792
  if (myTargets.has(s) && dep > 0) candidates2.push({ player: opp.id, kind: "reinforce", deployTo: s, deploy: dep, orders: [] });
148793
+ if (myTargets.has(s) && input2.firstMover !== "me") {
148794
+ const beside = neighborsOf(graph, s).filter((n) => start.get(n)?.owner === opp.id && (start.get(n)?.armies ?? 0) > guard).sort((a, b) => (start.get(b)?.armies ?? 0) - (start.get(a)?.armies ?? 0) || a - b);
148795
+ if (beside.length) {
148796
+ candidates2.push({ player: opp.id, kind: "gather", deployTo: s, deploy: dep, orders: beside.map((n) => ({ from: n, to: s, armies: allOf(n, 0) })) });
148797
+ }
148798
+ }
148735
148799
  }
148736
148800
  if (reach.size >= 2) {
148737
148801
  const bySize = [...reach.keys()].sort((a, b) => (start.get(b)?.armies ?? 0) - (start.get(a)?.armies ?? 0) || a - b);
@@ -148861,6 +148925,9 @@ function stressPlan(input2) {
148861
148925
  deployTo: c.deployTo,
148862
148926
  deploy: c.deploy,
148863
148927
  ...single ? { from: c.orders[0].from, to: c.orders[0].to, armies: sent ?? 0 } : {},
148928
+ ...c.kind === "gather" ? {
148929
+ movedIn: c.orders.map((o, i2) => ({ from: o.from, armies: r.log.find((e) => e.player === c.player && e.index === i2)?.sent ?? 0 }))
148930
+ } : {},
148864
148931
  ...c.kind === "all-attack" || c.kind === "joint" ? { attacks: sides.flatMap((x) => x.orders.map((o) => ({ from: o.from, to: o.to }))) } : {},
148865
148932
  ...c.partner ? { partner: c.partner.player, partnerDeployTo: c.partner.deployTo, partnerDeploy: c.partner.deploy } : {},
148866
148933
  ...run2.firstOpponent !== void 0 ? { firstOpponent: run2.firstOpponent } : {},
@@ -148881,7 +148948,7 @@ function stressPlan(input2) {
148881
148948
  };
148882
148949
  const signature = (x) => JSON.stringify({ ...x, firstMover: void 0, firstOpponent: void 0 });
148883
148950
  const runsFor = (c) => {
148884
- const firsts = c.kind === "dodge" ? ["opponent"] : input2.firstMover !== void 0 ? [input2.firstMover] : ["me", "opponent"];
148951
+ const firsts = c.kind === "dodge" || c.kind === "gather" ? ["opponent"] : input2.firstMover !== void 0 ? [input2.firstMover] : ["me", "opponent"];
148885
148952
  if (!c.partner) return firsts.map((f) => ({ firstMover: f, moveOrder: f === "me" ? [me, c.player] : [c.player, me] }));
148886
148953
  const pair2 = [c.player, c.partner.player];
148887
148954
  return firsts.flatMap(
@@ -149481,6 +149548,43 @@ var OWN_PLAN_STEPS = [
149481
149548
  "Submit with warapp_submit_turn; when your orders differ from the plan, pass override_reason so the decision log keeps why."
149482
149549
  ];
149483
149550
 
149551
+ // src/tools/bait.ts
149552
+ function baitAttackWarning(input2) {
149553
+ const { graph, board, me, settings, label: label3, name } = input2;
149554
+ const teammates = input2.teammates ?? /* @__PURE__ */ new Set();
149555
+ const standing = new Map(board.map((t) => [t.territoryId, t]));
149556
+ const guard = settings.oneArmyStandsGuard === false ? 0 : 1;
149557
+ const rates = {
149558
+ ...settings.offensiveKillRate !== void 0 ? { offensiveKillRate: settings.offensiveKillRate } : {},
149559
+ ...settings.defensiveKillRate !== void 0 ? { defensiveKillRate: settings.defensiveKillRate } : {}
149560
+ };
149561
+ const byTarget = /* @__PURE__ */ new Map();
149562
+ for (const m of input2.moves) {
149563
+ const t = standing.get(m.to.id);
149564
+ if (m.mode === "transfer-only" || !t || t.fogged || t.owner === me || t.owner <= OWNER_NEUTRAL) continue;
149565
+ if (teammates.has(t.owner) && m.attackTeammates !== true) continue;
149566
+ const power = m.armies + (m.commander ? COMMANDER_STRENGTH : 0);
149567
+ const g = byTarget.get(m.to.id);
149568
+ if (g) g.armies += power;
149569
+ else byTarget.set(m.to.id, { from: m.from, to: m.to, armies: power });
149570
+ }
149571
+ const parts = [];
149572
+ for (const [id, a] of byTarget) {
149573
+ const target = standing.get(id);
149574
+ const owner = target.owner;
149575
+ const stacks = neighborsOf(graph, id).map((n) => standing.get(n)).filter((s) => s !== void 0 && !s.fogged && s.owner === owner && (s.armies ?? 0) > guard).map((s) => ({ id: s.territoryId, moves: (s.armies ?? 0) - guard })).sort((x, y) => y.moves - x.moves || x.id - y.id);
149576
+ if (!stacks.length) continue;
149577
+ const defenders2 = (target.armies ?? 0) + specialUnitStrength(target.specialUnits) + stacks.reduce((n, s) => n + s.moves, 0);
149578
+ const needs = armiesToTake(defenders2, rates);
149579
+ if (needs !== null && a.armies >= needs) continue;
149580
+ parts.push(
149581
+ `${label3(a.from)} \u2192 ${label3(a.to)} with ${a.armies}: player ${owner}'s stacks beside it can move in first (${stacks.map((s) => `${label3(name(s.id))} ${s.moves}`).join(", ")}), ${defenders2} defenders before any deploy, which ${needs === null ? "no attack can take" : `needs ${needs}`}`
149582
+ );
149583
+ }
149584
+ if (!parts.length) return void 0;
149585
+ return `Possible bait (#593): ${parts.join("; ")}. That happens when it moves first, or when its moves run before the attack in the zigzag. warapp_check_plan tries it with its deploy too (the \`gather\` reply).`;
149586
+ }
149587
+
149484
149588
  // src/analysis/chat-advice.ts
149485
149589
  var CLOSE_RATIO = 0.85;
149486
149590
  var CLEAR_LEAD_RATIO = 1.2;
@@ -153521,7 +153625,8 @@ function headroomTable(input2) {
153521
153625
  moveOrder: attack ? first === "me" ? [me, attack.player] : [attack.player, me] : [me],
153522
153626
  ...input2.settings ? { settings: input2.settings } : {},
153523
153627
  ...teams ? { teams } : {},
153524
- ...input2.orderPriority ? { orderPriority: [me] } : {}
153628
+ ...input2.orderPriority ? { orderPriority: [me] } : {},
153629
+ ...input2.airlifts?.length ? { airlifts: input2.airlifts.map((a) => ({ player: me, ...a })) } : {}
153525
153630
  });
153526
153631
  const fillerCounts = (b, s, first) => {
153527
153632
  const n = myOrders.length;
@@ -154325,9 +154430,9 @@ function cityPurchaseOf(game, asked, map2, board, myInGameId2, gold) {
154325
154430
  const note = `Commerce: ${count4} cit${count4 === 1 ? "y" : "ies"} for ${cost} gold (each pays ${rules.cityIncome} gold a turn), ` + (gold.source === "standing" ? `leaving ${left} gold for the deploys. ` : `against the income model's ${gold.gold} gold (your gold could not be read from the board, and saved gold is not in it${left < 0 ? ", so war.app may refuse the purchase: error 597" : ""}). `) + "The purchase order's encoding is read from the client and UNVERIFIED live: check the cities on the board once the turn resolves.";
154326
154431
  return { cities, cost, note };
154327
154432
  }
154328
- function guardOffWarnings(graph, map2, board, me, friends, settings, deploys, moves) {
154433
+ function guardOffWarnings(graph, map2, board, me, friends, settings, deploys, moves, airlifts = []) {
154329
154434
  if (settings?.oneArmyStandsGuard !== false) return [];
154330
- const r = guardOffExposure({ graph, board, me, friends, deploys, moves });
154435
+ const r = guardOffExposure({ graph, board, me, friends, deploys, moves, airlifts });
154331
154436
  const name = namer(map2);
154332
154437
  const out = [];
154333
154438
  if (r.emptied.length) {
@@ -155036,6 +155141,7 @@ async function livePlanSetup(ctx, a) {
155036
155141
  const bonusAttempts = turn !== null && ctx.dataDir ? await readBonusAttempts(ctx.dataDir, game.id, me.id) : void 0;
155037
155142
  const cardArmies = cardArmyCeiling(game.settings);
155038
155143
  const calibration = await outlookCalibrationFor(ctx.dataDir, a.env, profileFormatOf(game.players));
155144
+ const trackCalibration = await trackCalibrationFor(ctx.dataDir, a.env, profileFormatOf(game.players));
155039
155145
  const outlookInput = {
155040
155146
  graph,
155041
155147
  me: me.id,
@@ -155087,8 +155193,9 @@ async function livePlanSetup(ctx, a) {
155087
155193
  // #166: the opponent's opening simulated from the starts the award proved, as the prior.
155088
155194
  ...opening ? { opening } : {},
155089
155195
  ...mapPace ? { mapPace } : {},
155090
- // #568: the same calibration raises each tracked figure by its coverage band's damped factor.
155091
- ...calibration ? { trackCalibration: calibration } : {},
155196
+ // #568: this format's own calibration raises each tracked figure by its coverage band's damped factor
155197
+ // (none in a 1v1, where the fog prior already lifts the tracker: trackCalibrationFor).
155198
+ ...trackCalibration ? { trackCalibration } : {},
155092
155199
  // #164: an opponent's Reinforcement card, from the turn the card clock says one can be in hand.
155093
155200
  ...opponentReinforcement(game.settings, hand) ? { reinforcement: opponentReinforcement(game.settings, hand) } : {},
155094
155201
  // #427: the Reinforcement plays seen in the turns' orders (card plays not fogged): a play restarts the clock.
@@ -155532,7 +155639,7 @@ async function commanderCheck(ctx, a) {
155532
155639
  ]);
155533
155640
  const opening = openingThreat(award, a.game, graph, a.seen, a.turn);
155534
155641
  const mapPace = await fogPaceFor(ctx.dataDir, void 0, a.game.settings?.mapId ?? a.map.id, mapMatchOf(profileFormatOf(a.game.players), a.game.settings), a.turn === null ? null : a.turn - 1);
155535
- const trackCalibration = await outlookCalibrationFor(ctx.dataDir, void 0, profileFormatOf(a.game.players));
155642
+ const trackCalibration = await trackCalibrationFor(ctx.dataDir, void 0, profileFormatOf(a.game.players));
155536
155643
  const so = stressOpponents({
155537
155644
  graph,
155538
155645
  map: a.map,
@@ -156767,6 +156874,9 @@ function registerTurnTools(server, ctx, opts = {}) {
156767
156874
  const { claimed } = teamHandLeft(hand, teamCardClaims(board.teammateOrders, new Set(teammatesOf(game.players, me).map((p) => p.id))));
156768
156875
  const pickFrom = unclaimedFirst(hand, claimed);
156769
156876
  const plays = resolveCardPlays(map2, pickFrom, rules, cardInputs);
156877
+ const submitAirlifts = plays.flatMap(
156878
+ (p) => p.kind === "Airlift" && p.targets?.from && p.targets.to ? [{ from: p.targets.from.id, to: p.targets.to.id, armies: p.targets.armies ?? 0, ...p.targets.commander ? { commander: true } : {} }] : []
156879
+ );
156770
156880
  for (const p of plays) {
156771
156881
  if (p.before !== void 0 && p.before > moves.length + 1) {
156772
156882
  throw new McpToolError(
@@ -157004,7 +157114,8 @@ function registerTurnTools(server, ctx, opts = {}) {
157004
157114
  friendsOf(game.players, me),
157005
157115
  game.settings,
157006
157116
  deploys.map((d) => ({ territoryId: d.territory.id, armies: d.armies })),
157007
- moves.map((m, i2) => ({ from: m.from.id, to: m.to.id, armies: m.percent ? options.estimates.get(i2) ?? 0 : m.armies }))
157117
+ moves.map((m, i2) => ({ from: m.from.id, to: m.to.id, armies: m.percent ? options.estimates.get(i2) ?? 0 : m.armies })),
157118
+ submitAirlifts
157008
157119
  )
157009
157120
  );
157010
157121
  if (handUnknown) warnings.push(UNREADABLE_HAND);
@@ -157079,6 +157190,17 @@ function registerTurnTools(server, ctx, opts = {}) {
157079
157190
  );
157080
157191
  const hopeless = hopelessAttackWarning(attacks, label2);
157081
157192
  if (hopeless) warnings.push(hopeless);
157193
+ const bait = baitAttackWarning({
157194
+ graph: graphOf(map2),
157195
+ board: territories,
157196
+ me: playerId,
157197
+ moves: moves.map((m, i2) => ({ ...m, armies: m.percent ? options.estimates.get(i2) ?? 0 : m.armies })),
157198
+ settings: plannerSettings(game.settings),
157199
+ label: label2,
157200
+ name: (id) => ({ id, name: map2.territories.find((t) => t.id === id)?.name ?? String(id) }),
157201
+ teammates
157202
+ });
157203
+ if (bait) warnings.push(bait);
157082
157204
  const subTeams = teamsOf(game.players);
157083
157205
  const givenDeploys = deploys.map((d) => ({ territoryId: d.territory.id, armies: d.armies }));
157084
157206
  const givenMoves = moves.map((m, i2) => ({
@@ -157099,7 +157221,9 @@ function registerTurnTools(server, ctx, opts = {}) {
157099
157221
  moves: givenMoves,
157100
157222
  settings: plannerSettings(game.settings),
157101
157223
  ...subTeams ? { teams: subTeams } : {},
157102
- ...plays.some((p) => p.kind === "OrderPriority") ? { orderPriority: true } : {}
157224
+ ...plays.some((p) => p.kind === "OrderPriority") ? { orderPriority: true } : {},
157225
+ // #618: the Airlifts land before the moves, as the stress test carries them out.
157226
+ ...submitAirlifts.length ? { airlifts: submitAirlifts } : {}
157103
157227
  });
157104
157228
  warnings.push(...headroomWarnings(headroomRows, modelled, !teamsKnown));
157105
157229
  const belowRows = await bordersBelowPlan(ctx, {
@@ -160720,7 +160844,7 @@ function registerCheckPlanTool(server, ctx) {
160720
160844
  {
160721
160845
  title: "Stress-test a planned turn in a war.app game",
160722
160846
  description: untrustedDescription(
160723
- `Stress-test a list of orders for your turn in an in-progress war.app (Warzone) game before you submit it (in a game of more than 16 opponents, \`unseenOpponents\` lists only those near your land \u2014 \`unseenOpponentsMore\` counts the rest \u2014 and \`scale\` sums the opponents not in view or within 2 steps of your land): the orders (the \`orders\` array warapp_plan_turn returns, or your own edit of it) are carried out on the live board, turn rules included (deploys first, then attacks and transfers interleaved in the zigzag move order; each order an attack or a transfer by who holds its target when it runs; kill rates, the guard army, each army moving once, commanders), against the replies each opponent could make with ONE deploy: its whole estimated deploy on one stack and an attack on a territory you hold or are about to take, its whole deploy on a territory you attack, or every stack attacking at once; a stack you attack moving out first (a dodge: into its own territory, or a neutral or one of yours it can take \u2014 \`dodges\` lists each with the armies that got away and what your strike then hit); two opponents striking one of your territories together (teammates always; any two in a free-for-all when you lead \u2014 \`jointFalls\` gives the armies each such territory needs to hold); and, under Multi-Attack, each stack's most damaging chain of captures. Under Local Deployment each deploy is bounded by where its bonus armies may land. Each reply is tried with you moving first and with the opponent moving first unless \`first_mover\` says which. A reply that keeps alive a player your orders finish off is \`eliminationsFailed\`. Returns \`safe\` (true, false, or null when no reply could be tried), a one-line \`summary\`, the \`worst\` reply and \`otherReplies\` that cost you something (territories \`lost\`, captures that fail or are \`retaken\`, bonuses and income lost, your commander), everything \`atRisk\` to some single reply (only one of them happens: one deploy, one place), what your orders do unanswered (\`plan\`: captures, attacks that fail, orders that send fewer armies than ordered or none), \`blindBorders\`: your territories next to the fog, where nothing could be tested, and \`exposedNextTurn\`: territories no enemy stack touches today that one could take next turn by first taking the territory in between (yours or neutral), each with the armies it would need to hold, if you add nothing next turn. Decide on the fields (\`safe\`, \`worst\`, \`exposedNextTurn\`), not on the wording of \`summary\`, which may change. With your commander on the board, \`commander\` says where it stands after the orders, the armies there and \`needs\`: the armies its territory needs to survive every reply tried, by the check warapp_submit_turn refuses on (each reply at the larger of the estimate and your income, enemy_deploy only raising it, both move orders, your Airlifts counted); when a reply kills it, the summary starts with it. \`commander.fogged\` tests it against \`fogged_attackers\` (default as warapp_plan_turn: 2 in a Commanders free-for-all of eight or more players under fog, else off) unknown opponents the fog may hide within two moves of where it ends, striking together (each a start of the game's starting armies, else your largest stack, plus a deploy of your income; luck-free): \`safe\`, \`needs\`, where they may come from; the summary names it when it can fall, and it never changes \`safe\`. Exact with no luck and straight rounding; otherwise battles are resolved at their expectation and \`exact\` is false. It does not try: ${CHECK_PLAN_NOT_COVERED.join("; ")}. When this server kept your pick list, \`award\` says what the award of picks showed (as in warapp_plan_turn): the opponent's proven starts stand on the board the orders are tried on even while fogged, and \`award.firstMover\` is who moves first this turn under a \`Cycle\` move order (not NoLuckCycle, where play speed sets it) \u2014 pass it as \`first_mover\` to judge by it; both orders are still tried by default. \`headroom\` lists, weakest first, each border of yours with the smallest single deploy by a neighbouring opponent that takes it after these orders, and what falls with it (the bonuses it breaks, the territories behind it and their bonus income). An opponent whose estimate one observation broke (see warapp_plan_turn) is tried at the larger of what it implied and your own income (\`enemyDeploy\` source \`untrusted\`), said in the first warning. Each \`enemyDeploy\` entry shows the Reinforcement card the clock says it may hold apart as \`cardBonus\` (in \`deploy\` unless \`assume_enemy_cards\` is "none"; a progressive card's source in \`cardBonusBasis\`, as warapp_plan_turn has it) and, under Sanctions, \`sanctionApplied\` (its income before and after the cut). A Sanctions card in the orders is projected onto next turn in \`sanctionsPlayed\` (\`nextIncome\`: yours from this turn's income when the game's percentage is negative and you play it on yourself, an opponent's estimate when positive), and a card on the wrong side for its sign is a warning (warapp_submit_turn refuses it). \`belowPlan\` compares these orders with the default plan made now on the same board (warapp_plan_turn with no options, the award of picks read as it reads it), or with its border guess when the deploys given are the guess's (\`belowPlanAgainst\`: plan or guess): each border they leave below what that plan leaves standing there, with \`planLeaves\`, \`left\` and \`short\`, the largest shortfall first (empty: none). \`planLeaves\` carries the plan's surplus, so a border named may still hold (see \`headroom\`); orders warapp_plan_turn made with options differ from the default plan by design. In a free-for-all with a truce in force (the agreement ledger), its partner is still tried \u2014 \`safe\` is safe against a break too \u2014 each reply that attacks a territory a truce covers is marked \`breaksTruce\`, and \`safeIfTruceHolds\` is the verdict over the other replies (null when every reply is a break); a partner-approved truce exception on this turn opens its territories (no break) and is listed under \`relations\`. In a game running the Diplomacy 2 mod, an ally is such a truce too, and a warning names any order that attacks a territory an ally holds (the game skips it; its armies sit idle). Refuses outside a turn phase. ${BRIDGE_NOTE} Read-only on war.app; it never submits orders.`
160847
+ `Stress-test a list of orders for your turn in an in-progress war.app (Warzone) game before you submit it (in a game of more than 16 opponents, \`unseenOpponents\` lists only those near your land \u2014 \`unseenOpponentsMore\` counts the rest \u2014 and \`scale\` sums the opponents not in view or within 2 steps of your land): the orders (the \`orders\` array warapp_plan_turn returns, or your own edit of it) are carried out on the live board, turn rules included (deploys first, then attacks and transfers interleaved in the zigzag move order; each order an attack or a transfer by who holds its target when it runs; kill rates, the guard army, each army moving once, commanders), against the replies each opponent could make with ONE deploy: its whole estimated deploy on one stack and an attack on a territory you hold or are about to take, its whole deploy on a territory you attack, or that plus its stacks beside it moving in first (\`gather\`, the bait: \`movedIn\` names each), or every stack attacking at once; a stack you attack moving out first (a dodge: into its own territory, or a neutral or one of yours it can take \u2014 \`dodges\` lists each with the armies that got away and what your strike then hit); two opponents striking one of your territories together (teammates always; any two in a free-for-all when you lead \u2014 \`jointFalls\` gives the armies each such territory needs to hold); and, under Multi-Attack, each stack's most damaging chain of captures. Under Local Deployment each deploy is bounded by where its bonus armies may land. Each reply is tried with you moving first and with the opponent moving first unless \`first_mover\` says which. A reply that keeps alive a player your orders finish off is \`eliminationsFailed\`. Returns \`safe\` (true, false, or null when no reply could be tried), a one-line \`summary\`, the \`worst\` reply and \`otherReplies\` that cost you something (territories \`lost\`, captures that fail or are \`retaken\`, bonuses and income lost, your commander), everything \`atRisk\` to some single reply (only one of them happens: one deploy, one place), what your orders do unanswered (\`plan\`: captures, attacks that fail, orders that send fewer armies than ordered or none), \`blindBorders\`: your territories next to the fog, where nothing could be tested, and \`exposedNextTurn\`: territories no enemy stack touches today that one could take next turn by first taking the territory in between (yours or neutral), each with the armies it would need to hold, if you add nothing next turn. Decide on the fields (\`safe\`, \`worst\`, \`exposedNextTurn\`), not on the wording of \`summary\`, which may change. With your commander on the board, \`commander\` says where it stands after the orders, the armies there and \`needs\`: the armies its territory needs to survive every reply tried, by the check warapp_submit_turn refuses on (each reply at the larger of the estimate and your income, enemy_deploy only raising it, both move orders, your Airlifts counted); when a reply kills it, the summary starts with it. \`commander.fogged\` tests it against \`fogged_attackers\` (default as warapp_plan_turn: 2 in a Commanders free-for-all of eight or more players under fog, else off) unknown opponents the fog may hide within two moves of where it ends, striking together (each a start of the game's starting armies, else your largest stack, plus a deploy of your income; luck-free): \`safe\`, \`needs\`, where they may come from; the summary names it when it can fall, and it never changes \`safe\`. Exact with no luck and straight rounding; otherwise battles are resolved at their expectation and \`exact\` is false. It does not try: ${CHECK_PLAN_NOT_COVERED.join("; ")}. When this server kept your pick list, \`award\` says what the award of picks showed (as in warapp_plan_turn): the opponent's proven starts stand on the board the orders are tried on even while fogged, and \`award.firstMover\` is who moves first this turn under a \`Cycle\` move order (not NoLuckCycle, where play speed sets it) \u2014 pass it as \`first_mover\` to judge by it; both orders are still tried by default. \`headroom\` lists, weakest first, each border of yours with the smallest single deploy by a neighbouring opponent that takes it after these orders, and what falls with it (the bonuses it breaks, the territories behind it and their bonus income). An opponent whose estimate one observation broke (see warapp_plan_turn) is tried at the larger of what it implied and your own income (\`enemyDeploy\` source \`untrusted\`), said in the first warning. Each \`enemyDeploy\` entry shows the Reinforcement card the clock says it may hold apart as \`cardBonus\` (in \`deploy\` unless \`assume_enemy_cards\` is "none"; a progressive card's source in \`cardBonusBasis\`, as warapp_plan_turn has it) and, under Sanctions, \`sanctionApplied\` (its income before and after the cut). A Sanctions card in the orders is projected onto next turn in \`sanctionsPlayed\` (\`nextIncome\`: yours from this turn's income when the game's percentage is negative and you play it on yourself, an opponent's estimate when positive), and a card on the wrong side for its sign is a warning (warapp_submit_turn refuses it). \`belowPlan\` compares these orders with the default plan made now on the same board (warapp_plan_turn with no options, the award of picks read as it reads it), or with its border guess when the deploys given are the guess's (\`belowPlanAgainst\`: plan or guess): each border they leave below what that plan leaves standing there, with \`planLeaves\`, \`left\` and \`short\`, the largest shortfall first (empty: none). \`planLeaves\` carries the plan's surplus, so a border named may still hold (see \`headroom\`); orders warapp_plan_turn made with options differ from the default plan by design. In a free-for-all with a truce in force (the agreement ledger), its partner is still tried \u2014 \`safe\` is safe against a break too \u2014 each reply that attacks a territory a truce covers is marked \`breaksTruce\`, and \`safeIfTruceHolds\` is the verdict over the other replies (null when every reply is a break); a partner-approved truce exception on this turn opens its territories (no break) and is listed under \`relations\`. In a game running the Diplomacy 2 mod, an ally is such a truce too, and a warning names any order that attacks a territory an ally holds (the game skips it; its armies sit idle). Refuses outside a turn phase. ${BRIDGE_NOTE} Read-only on war.app; it never submits orders.`
160724
160848
  ),
160725
160849
  _meta: lookupMeta(["check my plan", "stress test my orders", "what can my opponent do to this turn", "is this plan safe"]),
160726
160850
  annotations: readAnnotations("Stress-test a war.app turn"),
@@ -160773,7 +160897,7 @@ function registerCheckPlanTool(server, ctx) {
160773
160897
  const opening = openingThreat(award, game, graph, seen2, turn);
160774
160898
  const settings = plannerSettings(game.settings);
160775
160899
  const mapPace = await fogPaceFor(ctx.dataDir, void 0, game.settings?.mapId ?? map2.id, mapMatchOf(profileFormatOf(game.players), game.settings), turn === null ? null : turn - 1);
160776
- const trackCalibration = await outlookCalibrationFor(ctx.dataDir, void 0, profileFormatOf(game.players));
160900
+ const trackCalibration = await trackCalibrationFor(ctx.dataDir, void 0, profileFormatOf(game.players));
160777
160901
  const deploys = [];
160778
160902
  const moves = [];
160779
160903
  const refused = /* @__PURE__ */ new Set();
@@ -160998,7 +161122,7 @@ function registerCheckPlanTool(server, ctx) {
160998
161122
  const some = (ids2) => `${ids2.slice(0, LIST_MAX2).join(", ")}${ids2.length > LIST_MAX2 ? ` and ${ids2.length - LIST_MAX2} more` : ""}`;
160999
161123
  const capped2 = (ids2) => ids2.slice(0, LIST_MAX2).map(name);
161000
161124
  const sentence = (r) => {
161001
- const act = r.kind === "reinforce" ? `deploys ${r.deploy} on territory ${r.deployTo} and holds` : r.kind === "attack" ? `deploys ${r.deploy} on territory ${r.deployTo} and attacks territory ${r.to} with ${r.armies}` : r.kind === "dodge" ? `deploys ${r.deploy} on territory ${r.deployTo} and moves it out first, ${r.armies} into territory ${r.to}` : r.kind === "chain" ? `deploys ${r.deploy} on territory ${r.deployTo} and attacks on through territories ${r.path.slice(1).join(" \u2192 ")}` : r.kind === "joint" ? `and player ${r.partner} strike territory ${r.to} together from territories ${r.from} and ${r.partnerDeployTo} (deploying ${r.deploy} and ${r.partnerDeploy})` : `attacks with every stack at once (${r.attacks.length} attacks), its ${r.deploy} on territory ${r.deployTo}`;
161125
+ const act = r.kind === "reinforce" ? `deploys ${r.deploy} on territory ${r.deployTo} and holds` : r.kind === "gather" ? `${r.deploy > 0 ? `deploys ${r.deploy} on territory ${r.deployTo} and ` : ""}moves ${(r.movedIn ?? []).map((m) => `${m.armies} in from territory ${m.from}`).join(" and ")} onto territory ${r.deployTo}` : r.kind === "attack" ? `deploys ${r.deploy} on territory ${r.deployTo} and attacks territory ${r.to} with ${r.armies}` : r.kind === "dodge" ? `deploys ${r.deploy} on territory ${r.deployTo} and moves it out first, ${r.armies} into territory ${r.to}` : r.kind === "chain" ? `deploys ${r.deploy} on territory ${r.deployTo} and attacks on through territories ${r.path.slice(1).join(" \u2192 ")}` : r.kind === "joint" ? `and player ${r.partner} strike territory ${r.to} together from territories ${r.from} and ${r.partnerDeployTo} (deploying ${r.deploy} and ${r.partnerDeploy})` : `attacks with every stack at once (${r.attacks.length} attacks), its ${r.deploy} on territory ${r.deployTo}`;
161002
161126
  const when = (needs(r) === "you" ? ", and you move first" : needs(r) === "opponent" ? `, and ${r.kind === "joint" ? "they move" : "it moves"} first` : "") + (r.firstOpponent !== void 0 ? `, player ${r.firstOpponent} before the other` : "");
161003
161127
  const cost = r.commanderLost ? ["you lose your commander and the game"] : [
161004
161128
  ...r.lost.length ? [`you lose territor${r.lost.length === 1 ? "y" : "ies"} ${some(r.lost)}`] : [],
@@ -161016,6 +161140,8 @@ function registerCheckPlanTool(server, ctx) {
161016
161140
  deploy: r.deploy,
161017
161141
  deployTo: name(r.deployTo),
161018
161142
  ...r.kind === "attack" || r.kind === "dodge" || r.kind === "chain" ? { attack: { from: name(r.from), to: name(r.to), armies: r.armies } } : {},
161143
+ // #593 5c: the stacks a gather moved into the target, and what arrived from each.
161144
+ ...r.movedIn ? { movedIn: r.movedIn.map((m) => ({ from: name(m.from), armies: m.armies })) } : {},
161019
161145
  // #180: a chain's every territory, and a joint strike's second opponent.
161020
161146
  ...r.path ? { path: r.path.map(name) } : {},
161021
161147
  ...r.partner !== void 0 ? {
@@ -161132,7 +161258,9 @@ function registerCheckPlanTool(server, ctx) {
161132
161258
  settings,
161133
161259
  ...teams.size ? { teams } : {},
161134
161260
  ...first_mover !== void 0 ? { firstMover: first_mover } : {},
161135
- orderPriority
161261
+ orderPriority,
161262
+ // #618: the Airlifts land before the moves, as the stress test above carries them out.
161263
+ ...airlifts.length ? { airlifts } : {}
161136
161264
  });
161137
161265
  const belowPlan = await bordersBelowPlan(ctx, { game, map: map2, me, turn, territories, info, history, teamsKnown, given: { deploys, moves } });
161138
161266
  const avoidT = new Set((intel.avoidTerritories ?? []).map((t) => resolveTerritory(map2, t).id));
@@ -161188,7 +161316,8 @@ function registerCheckPlanTool(server, ctx) {
161188
161316
  from: m.from,
161189
161317
  to: m.to,
161190
161318
  armies: m.byPercent ? report2.baseline.log.find((e) => e.index === i2)?.sent ?? 0 : m.armies
161191
- }))
161319
+ })),
161320
+ airlifts
161192
161321
  ),
161193
161322
  ...refused.size ? [`These orders use ${[...refused].join(", ")}: war.app would refuse them in this game, and warapp_submit_turn does; the test ran them anyway.`] : [],
161194
161323
  ...sanction.warnings,
@@ -638,7 +638,7 @@ export function lessonsSummary(file) {
638
638
  * (geometric mean and samples): this format's band when it has `min` samples or more, else every format's
639
639
  * band together; a band with fewer than `min` either way is left out. Pure.
640
640
  */
641
- export function outlookCalibration(file, format, min) {
641
+ export function outlookCalibration(file, format, min, opts = {}) {
642
642
  let all = {};
643
643
  for (const f of PROFILE_FORMATS) {
644
644
  const t = file.byFormat[f];
@@ -648,7 +648,7 @@ export function outlookCalibration(file, format, min) {
648
648
  const own = file.byFormat[format]?.calibration ?? {};
649
649
  const out = {};
650
650
  for (const k of COVERAGE_BUCKETS) {
651
- const x = (own[k]?.n ?? 0) >= min ? own[k] : all[k];
651
+ const x = (own[k]?.n ?? 0) >= min ? own[k] : opts.ownOnly ? undefined : all[k];
652
652
  if (!x || x.n < min)
653
653
  continue;
654
654
  out[k] = { geoMean: r2(Math.exp(x.logSum / x.n)), n: x.n };
@@ -0,0 +1,62 @@
1
+ // #593 5c: the bait warning. A lightly held territory of a player's beside its big stack reads as
2
+ // a cheap capture, but that stack can move in before my attack lands (it moves first in the
3
+ // zigzag, or my attack is not my first order), and the attack then meets everything at once. The
4
+ // owner's rematch lost four 2–3 army attacks this way; the Tibet one met 24 moved in and 12
5
+ // deployed. The submit preview has no deploy estimate (warapp_check_plan's `gather` reply adds it):
6
+ // this counts only the armies there and what its stacks beside it can move in, so whatever it
7
+ // names is short before a single army is deployed.
8
+ import { armiesToTake, COMMANDER_STRENGTH, specialUnitStrength } from '../analysis/combat.js';
9
+ import { neighborsOf } from '../analysis/graph.js';
10
+ import { OWNER_NEUTRAL } from '../live.js';
11
+ /** The preview's warning, or `undefined` when no attack can be met that way. */
12
+ export function baitAttackWarning(input) {
13
+ const { graph, board, me, settings, label, name } = input;
14
+ const teammates = input.teammates ?? new Set();
15
+ const standing = new Map(board.map((t) => [t.territoryId, t]));
16
+ const guard = settings.oneArmyStandsGuard === false ? 0 : 1;
17
+ const rates = {
18
+ ...(settings.offensiveKillRate !== undefined ? { offensiveKillRate: settings.offensiveKillRate } : {}),
19
+ ...(settings.defensiveKillRate !== undefined ? { defensiveKillRate: settings.defensiveKillRate } : {}),
20
+ };
21
+ /**
22
+ * My attacks by target, in the order first listed: a player's visible territory, not a teammate's unless asked.
23
+ * Never a neutral's (#617: the live board's owner 0, whose stacks never move) or a hidden or pickable one (below 0).
24
+ */
25
+ const byTarget = new Map();
26
+ for (const m of input.moves) {
27
+ const t = standing.get(m.to.id);
28
+ if (m.mode === 'transfer-only' || !t || t.fogged || t.owner === me || t.owner <= OWNER_NEUTRAL)
29
+ continue;
30
+ if (teammates.has(t.owner) && m.attackTeammates !== true)
31
+ continue;
32
+ const power = m.armies + (m.commander ? COMMANDER_STRENGTH : 0);
33
+ const g = byTarget.get(m.to.id);
34
+ if (g)
35
+ g.armies += power;
36
+ else
37
+ byTarget.set(m.to.id, { from: m.from, to: m.to, armies: power });
38
+ }
39
+ const parts = [];
40
+ for (const [id, a] of byTarget) {
41
+ const target = standing.get(id);
42
+ const owner = target.owner;
43
+ const stacks = neighborsOf(graph, id)
44
+ .map((n) => standing.get(n))
45
+ .filter((s) => s !== undefined && !s.fogged && s.owner === owner && (s.armies ?? 0) > guard)
46
+ .map((s) => ({ id: s.territoryId, moves: (s.armies ?? 0) - guard }))
47
+ .sort((x, y) => y.moves - x.moves || x.id - y.id);
48
+ if (!stacks.length)
49
+ continue;
50
+ const defenders = (target.armies ?? 0) + specialUnitStrength(target.specialUnits) + stacks.reduce((n, s) => n + s.moves, 0);
51
+ const needs = armiesToTake(defenders, rates);
52
+ if (needs !== null && a.armies >= needs)
53
+ continue;
54
+ parts.push(`${label(a.from)} → ${label(a.to)} with ${a.armies}: player ${owner}'s stacks beside it can move in first (${stacks
55
+ .map((s) => `${label(name(s.id))} ${s.moves}`)
56
+ .join(', ')}), ${defenders} defenders before any deploy, which ${needs === null ? 'no attack can take' : `needs ${needs}`}`);
57
+ }
58
+ if (!parts.length)
59
+ return undefined;
60
+ return (`Possible bait (#593): ${parts.join('; ')}. That happens when it moves first, or when its moves run before the attack in the zigzag. ` +
61
+ 'warapp_check_plan tries it with its deploy too (the `gather` reply).');
62
+ }