@chrischall/warapp-mcp 0.20.0 → 0.22.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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +3 -3
- package/dist/analysis/options.js +157 -0
- package/dist/analysis/plan/captures.js +12 -1
- package/dist/analysis/plan/report.js +23 -3
- package/dist/analysis/plan/state.js +1 -0
- package/dist/analysis/planner.js +16 -4
- package/dist/analysis/situation.js +243 -0
- package/dist/analysis/stress.js +20 -1
- package/dist/bundle.js +578 -93
- package/dist/tools/bait.js +58 -0
- package/dist/tools/check-plan.js +17 -10
- package/dist/tools/turn.js +116 -1
- package/dist/version.js +1 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/bundle.js
CHANGED
|
@@ -98823,14 +98823,14 @@ var round2 = (v) => Math.round(v * 100) / 100;
|
|
|
98823
98823
|
function siegeOf(o) {
|
|
98824
98824
|
const { g, state, mineAtStart, foe } = o;
|
|
98825
98825
|
const guard = o.settings.oneArmyStandsGuard === false ? 0 : 1;
|
|
98826
|
-
const
|
|
98826
|
+
const ownerOf11 = (t) => {
|
|
98827
98827
|
const st = state.get(t);
|
|
98828
98828
|
return st?.owner.kind === "player" ? st.owner.playerId : void 0;
|
|
98829
98829
|
};
|
|
98830
98830
|
const inContact = /* @__PURE__ */ new Set();
|
|
98831
98831
|
for (const x of mineAtStart)
|
|
98832
98832
|
for (const n of neighborsOf(g, x)) {
|
|
98833
|
-
const p2 =
|
|
98833
|
+
const p2 = ownerOf11(n);
|
|
98834
98834
|
if (p2 !== void 0 && foe(p2)) inContact.add(p2);
|
|
98835
98835
|
}
|
|
98836
98836
|
let target = o.target;
|
|
@@ -98859,7 +98859,7 @@ function siegeOf(o) {
|
|
|
98859
98859
|
const cheapest = (bonusId) => {
|
|
98860
98860
|
const costs = bonusTerritories(g, bonusId).flatMap((t) => {
|
|
98861
98861
|
const a = armiesAt(t);
|
|
98862
|
-
if (a === null ||
|
|
98862
|
+
if (a === null || ownerOf11(t) !== p || !neighborsOf(g, t).some((n) => mineAtStart.has(n))) return [];
|
|
98863
98863
|
const c = captureCost(a, o.settings);
|
|
98864
98864
|
return c === null ? [] : [c];
|
|
98865
98865
|
});
|
|
@@ -101160,7 +101160,7 @@ function skirtedNeutrals(input2, o) {
|
|
|
101160
101160
|
const watched = [.../* @__PURE__ */ new Set([...avoid, ...partners])].sort(byNum2);
|
|
101161
101161
|
const { graph: g, board, me } = input2;
|
|
101162
101162
|
const state = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
101163
|
-
const
|
|
101163
|
+
const ownerOf11 = (t) => {
|
|
101164
101164
|
const st = state.get(t);
|
|
101165
101165
|
return st?.owner.kind === "player" ? st.owner.playerId : void 0;
|
|
101166
101166
|
};
|
|
@@ -101169,9 +101169,9 @@ function skirtedNeutrals(input2, o) {
|
|
|
101169
101169
|
const n = st.territoryId;
|
|
101170
101170
|
if (st.owner.kind !== "neutral" || !g.territoryById.has(n)) continue;
|
|
101171
101171
|
const bonuses = g.map.bonuses.filter((b) => bonusTerritories(g, b.id).includes(n));
|
|
101172
|
-
if (bonuses.some((b) => b.value > 0 && bonusTerritories(g, b.id).every((x) => x === n ||
|
|
101172
|
+
if (bonuses.some((b) => b.value > 0 && bonusTerritories(g, b.id).every((x) => x === n || ownerOf11(x) === me))) continue;
|
|
101173
101173
|
const foes = [...new Set(neighborsOf(g, n).flatMap((x) => {
|
|
101174
|
-
const p =
|
|
101174
|
+
const p = ownerOf11(x);
|
|
101175
101175
|
return p !== void 0 && (o.foe(p) || partners.has(p)) ? [p] : [];
|
|
101176
101176
|
}))];
|
|
101177
101177
|
const of = (player2, why) => ({ player: player2, why, ...partners.has(player2) ? { truce: true } : {} });
|
|
@@ -101180,7 +101180,7 @@ function skirtedNeutrals(input2, o) {
|
|
|
101180
101180
|
else
|
|
101181
101181
|
for (const b of [...bonuses].sort((x, y) => x.id - y.id)) {
|
|
101182
101182
|
const ts = bonusTerritories(g, b.id);
|
|
101183
|
-
const p = watched.find((a) => ts.filter((x) =>
|
|
101183
|
+
const p = watched.find((a) => ts.filter((x) => ownerOf11(x) === a).length * 2 > ts.length);
|
|
101184
101184
|
if (p !== void 0) {
|
|
101185
101185
|
skirt = of(p, "bonus");
|
|
101186
101186
|
break;
|
|
@@ -101197,7 +101197,7 @@ function skirtedNeutrals(input2, o) {
|
|
|
101197
101197
|
const threat2 = Math.max(
|
|
101198
101198
|
0,
|
|
101199
101199
|
...foes.map(
|
|
101200
|
-
(p) => neighborsOf(g, n).reduce((sum, x) => sum + (
|
|
101200
|
+
(p) => neighborsOf(g, n).reduce((sum, x) => sum + (ownerOf11(x) === p ? Math.max(0, (state.get(x).armies ?? 0) - 1) : 0), 0) + o.deployOf(p)
|
|
101201
101201
|
)
|
|
101202
101202
|
);
|
|
101203
101203
|
if (survivors > 0 && (armiesToTake(survivors, rates) ?? Number.POSITIVE_INFINITY) > threat2) continue;
|
|
@@ -101696,7 +101696,7 @@ function truceBreakLosses(pc, plan) {
|
|
|
101696
101696
|
function warnTruceNeutrals(pc, plan) {
|
|
101697
101697
|
const kept = pc.truce.keptWith;
|
|
101698
101698
|
if (!kept?.size) return;
|
|
101699
|
-
const
|
|
101699
|
+
const ownerOf11 = (t) => {
|
|
101700
101700
|
const o = pc.territories.get(t)?.owner;
|
|
101701
101701
|
return o?.kind === "player" ? o.playerId : void 0;
|
|
101702
101702
|
};
|
|
@@ -101704,7 +101704,7 @@ function warnTruceNeutrals(pc, plan) {
|
|
|
101704
101704
|
for (const t of taken) {
|
|
101705
101705
|
if (pc.territories.get(t)?.owner.kind !== "neutral") continue;
|
|
101706
101706
|
const beside = [...new Set(neighborsOf(pc.g, t).flatMap((x) => {
|
|
101707
|
-
const p =
|
|
101707
|
+
const p = ownerOf11(x);
|
|
101708
101708
|
return p !== void 0 && kept.has(p) ? [p] : [];
|
|
101709
101709
|
}))].sort(byNum2);
|
|
101710
101710
|
if (!beside.length) continue;
|
|
@@ -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,
|
|
@@ -103186,7 +103187,7 @@ function enemyDeployReaching(estimate, free, pools, on2, perTerritory) {
|
|
|
103186
103187
|
const anywhere = perTerritory ? Math.max(Math.min(estimate, free), estimate - pooled) : free;
|
|
103187
103188
|
return Math.min(estimate, anywhere + here);
|
|
103188
103189
|
}
|
|
103189
|
-
function couldHoldBonusPools(g, players,
|
|
103190
|
+
function couldHoldBonusPools(g, players, ownerOf11) {
|
|
103190
103191
|
const out = /* @__PURE__ */ new Map();
|
|
103191
103192
|
for (const p of players) out.set(p, []);
|
|
103192
103193
|
for (const b of [...g.map.bonuses].sort((x, y) => x.id - y.id)) {
|
|
@@ -103196,7 +103197,7 @@ function couldHoldBonusPools(g, players, ownerOf9) {
|
|
|
103196
103197
|
const members2 = new Set(ts);
|
|
103197
103198
|
for (const p of players)
|
|
103198
103199
|
if (ts.every((t) => {
|
|
103199
|
-
const o =
|
|
103200
|
+
const o = ownerOf11(t);
|
|
103200
103201
|
return o === void 0 || o === p;
|
|
103201
103202
|
}))
|
|
103202
103203
|
out.get(p).push({ bonusId: b.id, value: b.value, members: members2 });
|
|
@@ -106079,7 +106080,7 @@ function visibleOpponents(pc, input2) {
|
|
|
106079
106080
|
if (st.owner.kind !== "player" || !foe(st.owner.playerId) || st.armies === null) continue;
|
|
106080
106081
|
ownedBy3.set(st.owner.playerId, [...ownedBy3.get(st.owner.playerId) ?? [], id]);
|
|
106081
106082
|
}
|
|
106082
|
-
const
|
|
106083
|
+
const ownerOf11 = (id) => {
|
|
106083
106084
|
const o = state.get(id)?.owner;
|
|
106084
106085
|
return o?.kind === "player" ? o.playerId : void 0;
|
|
106085
106086
|
};
|
|
@@ -106104,7 +106105,7 @@ function visibleOpponents(pc, input2) {
|
|
|
106104
106105
|
const p = previousOwner.get(id);
|
|
106105
106106
|
return p !== void 0 && p !== me && weak.has(p) ? p : void 0;
|
|
106106
106107
|
};
|
|
106107
|
-
return { ownedBy: ownedBy3, ownerOf:
|
|
106108
|
+
return { ownedBy: ownedBy3, ownerOf: ownerOf11, hidden, fogAnywhere, fogEdge, inReach, weak, previousOwner, recentlyTakenFrom };
|
|
106108
106109
|
}
|
|
106109
106110
|
|
|
106110
106111
|
// src/analysis/plan/targets.ts
|
|
@@ -106923,23 +106924,23 @@ function deadAdvanceOf(pc, t, held, conceded, carried, completable2 = () => fals
|
|
|
106923
106924
|
return dead;
|
|
106924
106925
|
}
|
|
106925
106926
|
function breaksForAttacker(pc, t, ts, now) {
|
|
106926
|
-
const
|
|
106927
|
+
const ownerOf11 = (x) => {
|
|
106927
106928
|
const o = pc.territories.get(x)?.owner;
|
|
106928
106929
|
return o?.kind === "player" ? o.playerId : null;
|
|
106929
106930
|
};
|
|
106930
106931
|
const attackers = /* @__PURE__ */ new Set();
|
|
106931
106932
|
for (const m of now)
|
|
106932
106933
|
for (const n of pc.g.neighbors.get(m) ?? []) {
|
|
106933
|
-
const p =
|
|
106934
|
+
const p = ownerOf11(n);
|
|
106934
106935
|
const st = pc.territories.get(n);
|
|
106935
106936
|
if (p !== null && pc.foe(p) && (st?.armies ?? 0) > 0) attackers.add(p);
|
|
106936
106937
|
}
|
|
106937
106938
|
if (!attackers.size) return false;
|
|
106938
|
-
const owner =
|
|
106939
|
+
const owner = ownerOf11(t);
|
|
106939
106940
|
if (owner !== null) return attackers.has(owner);
|
|
106940
106941
|
if (pc.territories.get(t)?.owner.kind !== "neutral") return false;
|
|
106941
106942
|
const conceded = new Set(now);
|
|
106942
|
-
return [...attackers].some((a) => ts.every((x) => x === t || conceded.has(x) ||
|
|
106943
|
+
return [...attackers].some((a) => ts.every((x) => x === t || conceded.has(x) || ownerOf11(x) === a));
|
|
106943
106944
|
}
|
|
106944
106945
|
function deadAdvanceLine(pc, t, d) {
|
|
106945
106946
|
const members2 = d.members.map(pc.label).join(", ");
|
|
@@ -107136,7 +107137,8 @@ function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
|
|
|
107136
107137
|
});
|
|
107137
107138
|
const leadConceded = (x, t) => leadSteps.has(t) && conceded.has(x) && !myCommanders.has(x);
|
|
107138
107139
|
const fundedOnConceded = /* @__PURE__ */ new Set();
|
|
107139
|
-
const
|
|
107140
|
+
const breakConceded = (x, t) => ps.breakTarget === t && conceded.has(x) && !myCommanders.has(x);
|
|
107141
|
+
const concededSource = (x, t, cost) => concededSourceBase(x, t, cost) || leadConceded(x, t) || breakConceded(x, t);
|
|
107140
107142
|
const holdSource = (x, t) => leadSteps.has(t) && locked.has(x) && !conceded.has(x) && !myCommanders.has(x);
|
|
107141
107143
|
const holdKeep = (x, t) => {
|
|
107142
107144
|
const b = borderAt(x, (n) => captured.has(n) || n === t);
|
|
@@ -107266,6 +107268,7 @@ function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
|
|
|
107266
107268
|
const farKeep = far ? twoStepKeep(src, (n) => n === t) : 0;
|
|
107267
107269
|
const farBinds = far !== null && farKeep > 0 && farKeep >= keepOf(src, t);
|
|
107268
107270
|
const viaLead = !fromHold && !force && need2 > 0 && src !== fromConceded && leadConceded(src, t) && !concededSourceBase(src, t, tg.cost);
|
|
107271
|
+
const viaBreak = !viaLead && !fromHold && !force && need2 > 0 && src !== fromConceded && breakConceded(src, t) && !concededSourceBase(src, t, tg.cost);
|
|
107269
107272
|
deploy(src, need2);
|
|
107270
107273
|
const sent = noSplit ? Math.max(tg.cost, avail.get(src)) : tg.cost;
|
|
107271
107274
|
avail.set(src, avail.get(src) - sent);
|
|
@@ -107302,6 +107305,10 @@ function captureHelper(pc, ps, pass, book, threats, hd, tgt, prev) {
|
|
|
107302
107305
|
rationale.push(
|
|
107303
107306
|
`${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
107307
|
);
|
|
107308
|
+
} else if (viaBreak) {
|
|
107309
|
+
rationale.push(
|
|
107310
|
+
`${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).`
|
|
107311
|
+
);
|
|
107305
107312
|
} else if (farBinds) rationale.push(twoStepCite(src, far, (c) => `The attack on ${label3(t)} leaves ${label3(src)} ${c}.`));
|
|
107306
107313
|
else if (forHold > 0) {
|
|
107307
107314
|
const th = borderAt(src, (n) => captured.has(n));
|
|
@@ -107897,13 +107904,13 @@ function guardOffExposure(args) {
|
|
|
107897
107904
|
const { graph, board, me } = args;
|
|
107898
107905
|
const friends = args.friends ?? /* @__PURE__ */ new Set();
|
|
107899
107906
|
const byId2 = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
107900
|
-
const
|
|
107907
|
+
const ownerOf11 = (id) => {
|
|
107901
107908
|
const o = byId2.get(id)?.owner;
|
|
107902
107909
|
return o?.kind === "player" ? o.playerId : void 0;
|
|
107903
107910
|
};
|
|
107904
|
-
const isMine3 = (id) =>
|
|
107911
|
+
const isMine3 = (id) => ownerOf11(id) === me;
|
|
107905
107912
|
const isEnemy = (id) => {
|
|
107906
|
-
const p =
|
|
107913
|
+
const p = ownerOf11(id);
|
|
107907
107914
|
return p !== void 0 && p !== me && !friends.has(p);
|
|
107908
107915
|
};
|
|
107909
107916
|
const hidden = (id) => {
|
|
@@ -107923,11 +107930,11 @@ function guardOffExposure(args) {
|
|
|
107923
107930
|
const breaks = [];
|
|
107924
107931
|
for (const t of [...board.territories].sort((a, b) => a.territoryId - b.territoryId)) {
|
|
107925
107932
|
const id = t.territoryId;
|
|
107926
|
-
const owner =
|
|
107933
|
+
const owner = ownerOf11(id);
|
|
107927
107934
|
if (owner === void 0 || !isEnemy(id) || t.armies !== 0 || t.specialUnits?.length || attacked.has(id)) continue;
|
|
107928
107935
|
const from = neighborsOf(graph, id).filter(isMine3).sort((a, b) => a - b)[0];
|
|
107929
107936
|
if (from === void 0) continue;
|
|
107930
|
-
const held = [...graph.bonusById.values()].filter((b) => b.value > 0 && b.territoryIds.includes(id) && b.territoryIds.every((x) =>
|
|
107937
|
+
const held = [...graph.bonusById.values()].filter((b) => b.value > 0 && b.territoryIds.includes(id) && b.territoryIds.every((x) => ownerOf11(x) === owner)).sort((a, b) => b.value - a.value || a.id - b.id)[0];
|
|
107931
107938
|
if (held) breaks.push({ territoryId: id, from, playerId: owner, bonusId: held.id, value: held.value });
|
|
107932
107939
|
}
|
|
107933
107940
|
return { emptied, breaks };
|
|
@@ -108407,7 +108414,7 @@ function finishOffHelper(pc, ps, book, threats, hd, tgt, cap) {
|
|
|
108407
108414
|
staged
|
|
108408
108415
|
} = ps;
|
|
108409
108416
|
const { guardAt, deploy, roomAt, valueOf, stakeAt } = book;
|
|
108410
|
-
const { ownedBy: ownedBy3, ownerOf:
|
|
108417
|
+
const { ownedBy: ownedBy3, ownerOf: ownerOf11, fogAnywhere, deployReaching, holdArmies, bombSized, borderAt } = threats;
|
|
108411
108418
|
const { stayAt } = hd;
|
|
108412
108419
|
const { targets, frontierDelta, repulsed } = tgt;
|
|
108413
108420
|
const { notCompleted, worstCase, finishedOff, tryCapture } = cap;
|
|
@@ -108488,7 +108495,7 @@ function finishOffHelper(pc, ps, book, threats, hd, tgt, cap) {
|
|
|
108488
108495
|
return cost > CONCEDE_FACTOR * worth && !myCommanders.has(x) ? null : { need: need2, cost, worth };
|
|
108489
108496
|
};
|
|
108490
108497
|
for (const x of mine3) {
|
|
108491
|
-
const h = holdCostAt(x, (n) =>
|
|
108498
|
+
const h = holdCostAt(x, (n) => ownerOf11(n) === p && !stay2.has(n));
|
|
108492
108499
|
if (!h) continue;
|
|
108493
108500
|
const { need: need2, cost, worth } = h;
|
|
108494
108501
|
if (sources.has(x)) {
|
|
@@ -108693,7 +108700,7 @@ function finishOffHelper(pc, ps, book, threats, hd, tgt, cap) {
|
|
|
108693
108700
|
if (chosen.all && !pressure && profile.format === "ffa" && profile.opponents >= 2) {
|
|
108694
108701
|
const next = [...new Set(ts.flatMap((t) => neighborsOf(g, t)))].sort(byNum2);
|
|
108695
108702
|
const exposed = next.filter((n) => {
|
|
108696
|
-
const o =
|
|
108703
|
+
const o = ownerOf11(n);
|
|
108697
108704
|
return o !== void 0 && o !== p && foe(o) && !neighborsOf(g, n).some((x) => mineSet.has(x));
|
|
108698
108705
|
});
|
|
108699
108706
|
if (exposed.length) {
|
|
@@ -108701,8 +108708,8 @@ function finishOffHelper(pc, ps, book, threats, hd, tgt, cap) {
|
|
|
108701
108708
|
const delta = frontierDelta(mineSet, ts, (x) => mineSet.has(x) ? stayAt(x) : survivorsAt.get(x) ?? 0).armies;
|
|
108702
108709
|
const gain = Math.max(0, incomeGain(after));
|
|
108703
108710
|
const limit = Math.max(paybackTurns * gain, income);
|
|
108704
|
-
const who2 = [...new Set(exposed.map((n) =>
|
|
108705
|
-
const exposure = `taking ${ts.map(label3).join(", ")} makes me border ${who2.map((q) => `player ${q}'s ${exposed.filter((n) =>
|
|
108711
|
+
const who2 = [...new Set(exposed.map((n) => ownerOf11(n)))].sort(byNum2);
|
|
108712
|
+
const exposure = `taking ${ts.map(label3).join(", ")} makes me border ${who2.map((q) => `player ${q}'s ${exposed.filter((n) => ownerOf11(n) === q).map(label3).join(", ")}`).join(" and ")}`;
|
|
108706
108713
|
const shown2 = Math.round(delta);
|
|
108707
108714
|
const cost = `the frontier's hold cost changes by ${shown2 >= 0 ? "+" : ""}${shown2} armies (its own threat gone)`;
|
|
108708
108715
|
if (delta > limit) {
|
|
@@ -108804,7 +108811,7 @@ function commanderStrikes(pc, ps, book, threats, hd, tgt, cap) {
|
|
|
108804
108811
|
} = pc;
|
|
108805
108812
|
const { warnings, rationale, deployed, avail, captured } = ps;
|
|
108806
108813
|
const { orderOf, describeOrder, local, roomAt, spareAt } = book;
|
|
108807
|
-
const { ownedBy: ownedBy3, ownerOf:
|
|
108814
|
+
const { ownedBy: ownedBy3, ownerOf: ownerOf11, deployReaching, holdArmies, borderAt } = threats;
|
|
108808
108815
|
const { stayAt, keepFor } = hd;
|
|
108809
108816
|
const { targets } = tgt;
|
|
108810
108817
|
const { mustHold, strikes, worstCase, tryCapture } = cap;
|
|
@@ -108864,7 +108871,7 @@ function commanderStrikes(pc, ps, book, threats, hd, tgt, cap) {
|
|
|
108864
108871
|
const by = /* @__PURE__ */ new Map();
|
|
108865
108872
|
for (const x of land)
|
|
108866
108873
|
for (const n of neighborsOf(g, x)) {
|
|
108867
|
-
const o =
|
|
108874
|
+
const o = ownerOf11(n);
|
|
108868
108875
|
if (o === void 0 || o === p || !foe(o)) continue;
|
|
108869
108876
|
if (!(by.get(o) ?? []).includes(x)) by.set(o, [...by.get(o) ?? [], x]);
|
|
108870
108877
|
}
|
|
@@ -109207,7 +109214,7 @@ function fundFromSecondSizing(pc, ps, book, threats, hd, caps) {
|
|
|
109207
109214
|
}
|
|
109208
109215
|
const spare = /* @__PURE__ */ new Map();
|
|
109209
109216
|
const keepOf = /* @__PURE__ */ new Map();
|
|
109210
|
-
const
|
|
109217
|
+
const ownerOf11 = (m) => state.get(m.to).owner.playerId;
|
|
109211
109218
|
const deployLeft = /* @__PURE__ */ new Map();
|
|
109212
109219
|
for (const [owner, list3] of [...byOwner].sort((a, b) => a[0] - b[0])) {
|
|
109213
109220
|
if (list3.length < 2) continue;
|
|
@@ -109274,7 +109281,7 @@ function fundFromSecondSizing(pc, ps, book, threats, hd, caps) {
|
|
|
109274
109281
|
const from = takes.map(
|
|
109275
109282
|
({ m, n, before }) => `${n} from the attack on ${label3(m.to)} from ${label3(m.from)} (${before} down to ${m.armies}: still sure against the ${defenceAt(m.to)} there now, and against up to ${worstCase.get(m.to) - defenceAt(m.to)} deployed there first)`
|
|
109276
109283
|
).join(" and ");
|
|
109277
|
-
const kept = [...new Map(takes.map(({ m }) => [
|
|
109284
|
+
const kept = [...new Map(takes.map(({ m }) => [ownerOf11(m), m])).keys()].sort((a, b) => a - b).map((o) => {
|
|
109278
109285
|
const keep = keepOf.get(o);
|
|
109279
109286
|
return `player ${o}'s ~${threats.reinforcementAt(keep.to)} deploy reinforces one of its targets, not two, and the attack on ${label3(keep.to)} keeps its size for it`;
|
|
109280
109287
|
}).join("; ");
|
|
@@ -110897,11 +110904,11 @@ function spendUnderCap(pc, ps, book, threats, hd, tgt, caps) {
|
|
|
110897
110904
|
ps.capRefused.set(t, why);
|
|
110898
110905
|
};
|
|
110899
110906
|
const taken = [];
|
|
110900
|
-
const
|
|
110907
|
+
const ownerOf11 = (t) => {
|
|
110901
110908
|
const o = state.get(t)?.owner;
|
|
110902
110909
|
return o?.kind === "player" ? o.playerId : void 0;
|
|
110903
110910
|
};
|
|
110904
|
-
const lostBy = (p) => [...captured].filter((x) =>
|
|
110911
|
+
const lostBy = (p) => [...captured].filter((x) => ownerOf11(x) === p).sort(byNum2);
|
|
110905
110912
|
const tryOne = (t, i2, list3, fork) => {
|
|
110906
110913
|
const now = nextCap();
|
|
110907
110914
|
if (now.eaten <= 0) return "stop";
|
|
@@ -110943,7 +110950,7 @@ function spendUnderCap(pc, ps, book, threats, hd, tgt, caps) {
|
|
|
110943
110950
|
const exposed = kit.exposure(t);
|
|
110944
110951
|
taken.push(t);
|
|
110945
110952
|
const paid = before - ps.budget;
|
|
110946
|
-
const p =
|
|
110953
|
+
const p = ownerOf11(t);
|
|
110947
110954
|
const lost = p === void 0 ? [] : lostBy(p);
|
|
110948
110955
|
const forkText = () => {
|
|
110949
110956
|
const est = Math.max(0, ...lost.map((x) => threats.reinforcementAt(x)));
|
|
@@ -110987,9 +110994,9 @@ function spendUnderCap(pc, ps, book, threats, hd, tgt, caps) {
|
|
|
110987
110994
|
forks.push(t);
|
|
110988
110995
|
}
|
|
110989
110996
|
forks.sort((a, b) => lossAt(a) - lossAt(b) || gainWith([b]) - gainWith([a]) || targets.get(a).cost - targets.get(b).cost || a - b);
|
|
110990
|
-
const open5 = forks.filter((t) => lostBy(
|
|
110997
|
+
const open5 = forks.filter((t) => lostBy(ownerOf11(t)).length > 0);
|
|
110991
110998
|
for (const [i2, t] of open5.entries()) {
|
|
110992
|
-
if (!lostBy(
|
|
110999
|
+
if (!lostBy(ownerOf11(t)).length) continue;
|
|
110993
111000
|
if (tryOne(t, i2, open5, true) === "stop") break;
|
|
110994
111001
|
}
|
|
110995
111002
|
} finally {
|
|
@@ -111090,7 +111097,7 @@ function transfers(pc, ps, book, threats, hd, caps, staging) {
|
|
|
111090
111097
|
const { g, me, s, foe, territories: state, label: label3, bonusName, mine: mine3, mineSet, unitsAt, toTake, noSplit, myCommanders } = pc;
|
|
111091
111098
|
const { warnings, rationale, avail, locked, coverKeep, centralKeep, captured, moves } = ps;
|
|
111092
111099
|
const { guardAt, coverOf, orderOf, warnSplit } = book;
|
|
111093
|
-
const { holdArmies, borderAt, ownerOf:
|
|
111100
|
+
const { holdArmies, borderAt, ownerOf: ownerOf11, borders } = threats;
|
|
111094
111101
|
const { arrived, conceded, threatened: threatened2, stayAt, twoStepCite, twoStepHold, twoStepKeep } = hd;
|
|
111095
111102
|
const { strikes, worstCase } = caps;
|
|
111096
111103
|
const transfer = (from, to, armies, reason) => {
|
|
@@ -111228,7 +111235,7 @@ function transfers(pc, ps, book, threats, hd, caps, staging) {
|
|
|
111228
111235
|
rationale.push(breachLine(pc, t, n, land));
|
|
111229
111236
|
continue;
|
|
111230
111237
|
}
|
|
111231
|
-
if (myCommanders.has(t) && neighborsOf(g, t).some((x) => (
|
|
111238
|
+
if (myCommanders.has(t) && neighborsOf(g, t).some((x) => (ownerOf11(x) ?? me) !== me || conceded.has(x)))
|
|
111232
111239
|
continue;
|
|
111233
111240
|
const d = dist.get(t);
|
|
111234
111241
|
if (d === void 0 || d <= 1) continue;
|
|
@@ -111839,7 +111846,8 @@ function reportOffence(pc, ps, book, threats, hd, tgt, holdLocked, leadSpareFor)
|
|
|
111839
111846
|
leadLever,
|
|
111840
111847
|
ffaLeader,
|
|
111841
111848
|
leadText,
|
|
111842
|
-
myCommanders
|
|
111849
|
+
myCommanders,
|
|
111850
|
+
guard
|
|
111843
111851
|
} = pc;
|
|
111844
111852
|
const { warnings, rationale, deployed, avail, spared, unabsorbed, captured, moves } = ps;
|
|
111845
111853
|
const { gainWith, orderOf, pools, coverOf } = book;
|
|
@@ -111952,6 +111960,17 @@ function reportOffence(pc, ps, book, threats, hd, tgt, holdLocked, leadSpareFor)
|
|
|
111952
111960
|
const st = state.get(n);
|
|
111953
111961
|
return !mineSet.has(n) && !attacked.has(n) && st?.owner.kind === "player" && foe(st.owner.playerId) && st.armies !== null;
|
|
111954
111962
|
});
|
|
111963
|
+
const baitNote = (n) => {
|
|
111964
|
+
const owner = state.get(n).owner;
|
|
111965
|
+
const stacks = neighborsOf(g, n).flatMap((x) => {
|
|
111966
|
+
const st = state.get(x);
|
|
111967
|
+
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 }] : [];
|
|
111968
|
+
}).sort((a, b) => b.moves - a.moves || a.x - b.x);
|
|
111969
|
+
if (!stacks.length) return "";
|
|
111970
|
+
const k = stacks.reduce((t, s) => t + s.moves, 0);
|
|
111971
|
+
const then = costAt(n, defenceAt(n) + k);
|
|
111972
|
+
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)`;
|
|
111973
|
+
};
|
|
111955
111974
|
const reasonFor = (n) => {
|
|
111956
111975
|
const st = state.get(n);
|
|
111957
111976
|
const p = st.owner.playerId;
|
|
@@ -111986,8 +112005,8 @@ function reportOffence(pc, ps, book, threats, hd, tgt, holdLocked, leadSpareFor)
|
|
|
111986
112005
|
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
112006
|
}
|
|
111988
112007
|
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)` : ""}`;
|
|
112008
|
+
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)}`;
|
|
112009
|
+
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
112010
|
};
|
|
111992
112011
|
const capNote = (n) => {
|
|
111993
112012
|
const why = ps.capRefused.get(n);
|
|
@@ -112023,7 +112042,7 @@ function finishPlan(pc, ps, pass, threats, hd, tgt, expected, sentAt, slotOf, fa
|
|
|
112023
112042
|
toTake
|
|
112024
112043
|
} = pc;
|
|
112025
112044
|
const { warnings, rationale, deployed, captured, combined, moves } = ps;
|
|
112026
|
-
const { reinforcementAt, borders, ownedBy: ownedBy3, ownerOf:
|
|
112045
|
+
const { reinforcementAt, borders, ownedBy: ownedBy3, ownerOf: ownerOf11, fogEdge } = threats;
|
|
112027
112046
|
const { conceded, stayAt } = hd;
|
|
112028
112047
|
const { offence, offenceSkip } = tgt;
|
|
112029
112048
|
const { completed, nextIncome, atRisk, ifFall, reportRisk, frontier, gates } = expected;
|
|
@@ -112055,7 +112074,7 @@ function finishPlan(pc, ps, pass, threats, hd, tgt, expected, sentAt, slotOf, fa
|
|
|
112055
112074
|
if (!foe(p)) continue;
|
|
112056
112075
|
const broken = g.map.bonuses.filter((b) => b.value > 0).filter((b) => {
|
|
112057
112076
|
const members2 = bonusTerritories(g, b.id);
|
|
112058
|
-
return members2.length > 0 && members2.every((t) =>
|
|
112077
|
+
return members2.length > 0 && members2.every((t) => ownerOf11(t) === p) && members2.some((t) => captured.has(t));
|
|
112059
112078
|
}).sort((a, b) => a.id - b.id);
|
|
112060
112079
|
if (!broken.length) continue;
|
|
112061
112080
|
const left = ts.filter((t) => !captured.has(t));
|
|
@@ -112716,6 +112735,14 @@ function planPass(input2, pass) {
|
|
|
112716
112735
|
});
|
|
112717
112736
|
return true;
|
|
112718
112737
|
};
|
|
112738
|
+
const asBreak = (t, f) => {
|
|
112739
|
+
ps.breakTarget = t;
|
|
112740
|
+
try {
|
|
112741
|
+
return f();
|
|
112742
|
+
} finally {
|
|
112743
|
+
ps.breakTarget = void 0;
|
|
112744
|
+
}
|
|
112745
|
+
};
|
|
112719
112746
|
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
112747
|
const pileBreak = (() => {
|
|
112721
112748
|
if (!pc.pile) return void 0;
|
|
@@ -112774,13 +112801,13 @@ function planPass(input2, pass) {
|
|
|
112774
112801
|
const was = worstCase.get(o.t);
|
|
112775
112802
|
targets.set(o.t, { ...tg, cost: o.cost });
|
|
112776
112803
|
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)`))) {
|
|
112804
|
+
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
112805
|
targets.set(o.t, tg);
|
|
112779
112806
|
if (was === void 0) worstCase.delete(o.t);
|
|
112780
112807
|
else worstCase.set(o.t, was);
|
|
112781
112808
|
return;
|
|
112782
112809
|
}
|
|
112783
|
-
} else if (!tryCapture(o.t, reasonOf2(breakReason(b)))) return;
|
|
112810
|
+
} else if (!asBreak(o.t, () => tryCapture(o.t, reasonOf2(breakReason(b))))) return;
|
|
112784
112811
|
ps.anchor ??= moves[moves.length - 1].from;
|
|
112785
112812
|
warnRetake(b, o);
|
|
112786
112813
|
})
|
|
@@ -112824,7 +112851,7 @@ function planPass(input2, pass) {
|
|
|
112824
112851
|
const was = worstCase.get(o.t);
|
|
112825
112852
|
if (raised) targets.set(o.t, { ...tg, cost: o.cost });
|
|
112826
112853
|
worstCase.set(o.t, Math.max(was ?? 0, defenceAt(o.t) + partial2));
|
|
112827
|
-
const ok = tryCapture(o.t, reason);
|
|
112854
|
+
const ok = asBreak(o.t, () => tryCapture(o.t, reason));
|
|
112828
112855
|
if (raised) targets.set(o.t, tg);
|
|
112829
112856
|
if (!ok) {
|
|
112830
112857
|
if (was === void 0) worstCase.delete(o.t);
|
|
@@ -113058,7 +113085,7 @@ function planPass(input2, pass) {
|
|
|
113058
113085
|
const left = expansionLeft;
|
|
113059
113086
|
c.run();
|
|
113060
113087
|
const after2 = new Set(fundable(pending, ps.budget));
|
|
113061
|
-
const starved = before.filter((u) => !after2.has(u));
|
|
113088
|
+
const starved = before.filter((u) => !after2.has(u) && !(u.hubOnly && u.floored));
|
|
113062
113089
|
const lost = starved.reduce((n, u) => n + u.value, 0);
|
|
113063
113090
|
const kept2 = starved.map((u) => keptShort(u, local ? Math.min(ps.budget, leftFor(u)) : ps.budget));
|
|
113064
113091
|
const conceding = starved.filter((_, i2) => !kept2[i2]).reduce((n, u) => n + u.value, 0);
|
|
@@ -116117,7 +116144,7 @@ function serverBuild() {
|
|
|
116117
116144
|
}
|
|
116118
116145
|
|
|
116119
116146
|
// src/version.ts
|
|
116120
|
-
var VERSION2 = "0.
|
|
116147
|
+
var VERSION2 = "0.22.0";
|
|
116121
116148
|
|
|
116122
116149
|
// src/decision-log.ts
|
|
116123
116150
|
var DECISION_LOG_VERSION = 1;
|
|
@@ -119256,11 +119283,11 @@ function reader(cb) {
|
|
|
119256
119283
|
...cb.settings?.offensiveKillRate !== void 0 ? { offensiveKillRate: cb.settings.offensiveKillRate } : {},
|
|
119257
119284
|
...cb.settings?.defensiveKillRate !== void 0 ? { defensiveKillRate: cb.settings.defensiveKillRate } : {}
|
|
119258
119285
|
};
|
|
119259
|
-
const
|
|
119286
|
+
const ownerOf11 = (t) => {
|
|
119260
119287
|
const o = state.get(t)?.owner;
|
|
119261
119288
|
return o?.kind === "player" ? o.playerId : void 0;
|
|
119262
119289
|
};
|
|
119263
|
-
const isMine3 = (t) =>
|
|
119290
|
+
const isMine3 = (t) => ownerOf11(t) === cb.me;
|
|
119264
119291
|
const foe = (p) => p !== void 0 && p !== cb.me && !cb.friends?.has(p);
|
|
119265
119292
|
const armiesOf3 = (t) => state.get(t)?.armies ?? 0;
|
|
119266
119293
|
const commanderOf = (t, who2) => (state.get(t)?.specialUnits ?? []).some((u) => u.kind === "commander" && who2(u.playerId));
|
|
@@ -119274,7 +119301,7 @@ function reader(cb) {
|
|
|
119274
119301
|
const reachOf = (t, bombed) => {
|
|
119275
119302
|
const by = /* @__PURE__ */ new Map();
|
|
119276
119303
|
for (const n of neighborsOf(cb.graph, t)) {
|
|
119277
|
-
const p =
|
|
119304
|
+
const p = ownerOf11(n);
|
|
119278
119305
|
if (!foe(p) || state.get(n)?.armies === null) continue;
|
|
119279
119306
|
const e = by.get(p) ?? { others: 0, hasOther: false };
|
|
119280
119307
|
if (n === bombed) e.bombed = armiesOf3(n);
|
|
@@ -119295,7 +119322,7 @@ function reader(cb) {
|
|
|
119295
119322
|
const reachByPlayer = (t) => {
|
|
119296
119323
|
const by = /* @__PURE__ */ new Map();
|
|
119297
119324
|
for (const n of neighborsOf(cb.graph, t)) {
|
|
119298
|
-
const p =
|
|
119325
|
+
const p = ownerOf11(n);
|
|
119299
119326
|
if (!foe(p) || state.get(n)?.armies === null) continue;
|
|
119300
119327
|
by.set(p, (by.get(p) ?? cb.enemyDeploy) + Math.max(0, armiesOf3(n) - guard));
|
|
119301
119328
|
}
|
|
@@ -119307,7 +119334,7 @@ function reader(cb) {
|
|
|
119307
119334
|
while (toTake(h + extra) <= reach) h++;
|
|
119308
119335
|
return h;
|
|
119309
119336
|
};
|
|
119310
|
-
return { state, guard, rates, ownerOf:
|
|
119337
|
+
return { state, guard, rates, ownerOf: ownerOf11, isMine: isMine3, foe, armiesOf: armiesOf3, commanderOf, deployAt, outOf, transfersInto, attacksOn: attacksOn2, after, toTake, ids: ids2, reachOf, reachByPlayer, holdNeed };
|
|
119311
119338
|
}
|
|
119312
119339
|
var KIND_RANK = { commander: 0, hold: 1, capture: 2 };
|
|
119313
119340
|
function bombAdvice(cb) {
|
|
@@ -141968,16 +141995,16 @@ function borderGuess(input2) {
|
|
|
141968
141995
|
const allies = alliesOf(me, input2.players);
|
|
141969
141996
|
const state = /* @__PURE__ */ new Map();
|
|
141970
141997
|
for (const t of board.territories) if (g.territoryById.has(t.territoryId)) state.set(t.territoryId, t);
|
|
141971
|
-
const
|
|
141998
|
+
const ownerOf11 = (id) => {
|
|
141972
141999
|
const t = state.get(id);
|
|
141973
142000
|
return t?.owner.kind === "player" ? t.owner.playerId : null;
|
|
141974
142001
|
};
|
|
141975
142002
|
const foe = (p) => p !== null && p !== me && !allies.has(p);
|
|
141976
|
-
const foeStack = (id) => foe(
|
|
141977
|
-
const mine3 = [...state.values()].filter((t) =>
|
|
142003
|
+
const foeStack = (id) => foe(ownerOf11(id)) && state.get(id).armies !== null;
|
|
142004
|
+
const mine3 = [...state.values()].filter((t) => ownerOf11(t.territoryId) === me).map((t) => t.territoryId).sort(byNum13);
|
|
141978
142005
|
const mineSet = new Set(mine3);
|
|
141979
142006
|
const opponents = /* @__PURE__ */ new Set();
|
|
141980
|
-
for (const t of mine3) for (const n of neighborsOf(g, t)) if (foeStack(n)) opponents.add(
|
|
142007
|
+
for (const t of mine3) for (const n of neighborsOf(g, t)) if (foeStack(n)) opponents.add(ownerOf11(n));
|
|
141981
142008
|
if (opponents.size === 0) return skip("no-contact", "No opponent stack is in sight next to my territories.");
|
|
141982
142009
|
if (opponents.size > 1)
|
|
141983
142010
|
return skip("several-opponents", `${opponents.size} opponents touch my borders: the guess models one opponent with one deploy.`);
|
|
@@ -141985,7 +142012,7 @@ function borderGuess(input2) {
|
|
|
141985
142012
|
if (input2.enemyDeploy === void 0 && input2.untrusted?.includes(opp))
|
|
141986
142013
|
return skip("untrusted", `Player ${opp}'s deploy estimate is untrusted (#275): the plan sized its borders above it, and a guess drawn from the estimate would undo that.`);
|
|
141987
142014
|
const D = Math.max(0, Math.floor(input2.enemyDeploy ?? input2.estimates?.find((e) => e.playerId === opp)?.estimate ?? plan.enemyDeploy));
|
|
141988
|
-
const ids2 = mine3.filter((t) => neighborsOf(g, t).some((n) => foeStack(n) &&
|
|
142015
|
+
const ids2 = mine3.filter((t) => neighborsOf(g, t).some((n) => foeStack(n) && ownerOf11(n) === opp));
|
|
141989
142016
|
if (ids2.length < 2) return skip("one-border", "The opponent touches only one of my territories: there is nothing to guess between.");
|
|
141990
142017
|
if (ids2.length > MAX_GUESS_BORDERS)
|
|
141991
142018
|
return skip("too-many-borders", `The opponent touches ${ids2.length} of my territories (at most ${MAX_GUESS_BORDERS} are modelled).`);
|
|
@@ -142012,7 +142039,7 @@ function borderGuess(input2) {
|
|
|
142012
142039
|
const armies = t.armies ?? 0;
|
|
142013
142040
|
const myUnits = (t.specialUnits ?? []).filter((u) => u.playerId === me);
|
|
142014
142041
|
const strength = specialUnitStrength(myUnits);
|
|
142015
|
-
const stack = neighborsOf(g, id).filter((n) => foeStack(n) &&
|
|
142042
|
+
const stack = neighborsOf(g, id).filter((n) => foeStack(n) && ownerOf11(n) === opp).reduce((a, n) => {
|
|
142016
142043
|
const nt = state.get(n);
|
|
142017
142044
|
const units = (nt.specialUnits ?? []).filter((u) => u.playerId === opp);
|
|
142018
142045
|
return a + Math.max(0, (nt.armies ?? 0) - guard) + specialUnitStrength(units);
|
|
@@ -145754,7 +145781,7 @@ function storeBoards(boards, ids2, key) {
|
|
|
145754
145781
|
const known2 = new Set(ids2);
|
|
145755
145782
|
const index = /* @__PURE__ */ new Map();
|
|
145756
145783
|
const owners = [];
|
|
145757
|
-
const
|
|
145784
|
+
const ownerOf11 = (o) => {
|
|
145758
145785
|
if (o.kind === "neutral") return OWNER_NEUTRAL2;
|
|
145759
145786
|
if (o.kind === "available") return OWNER_AVAILABLE;
|
|
145760
145787
|
if (o.kind !== "player" || !known2.has(o.playerId)) return OWNER_UNKNOWN;
|
|
@@ -145766,7 +145793,7 @@ function storeBoards(boards, ids2, key) {
|
|
|
145766
145793
|
return i2;
|
|
145767
145794
|
};
|
|
145768
145795
|
const rowOf = (x) => {
|
|
145769
|
-
const row2 = [x.territoryId,
|
|
145796
|
+
const row2 = [x.territoryId, ownerOf11(x.owner), x.armies];
|
|
145770
145797
|
return x.fogLevel && x.fogLevel !== "Visible" && FOG_WORD.test(x.fogLevel) ? [...row2, x.fogLevel] : row2;
|
|
145771
145798
|
};
|
|
145772
145799
|
let prev;
|
|
@@ -145808,7 +145835,7 @@ var hasBoards = (rec2) => rec2.status === "captured" && Array.isArray(rec2.board
|
|
|
145808
145835
|
function decodeHistory(rec2, byKey) {
|
|
145809
145836
|
const me = byKey.get(rec2.me);
|
|
145810
145837
|
const owners = rec2.boardOwners.map((k) => byKey.get(k));
|
|
145811
|
-
const
|
|
145838
|
+
const ownerOf11 = (o) => {
|
|
145812
145839
|
if (o === OWNER_NEUTRAL2) return { kind: "neutral" };
|
|
145813
145840
|
if (o === OWNER_AVAILABLE) return { kind: "available" };
|
|
145814
145841
|
const id = owners[o];
|
|
@@ -145822,7 +145849,7 @@ function decodeHistory(rec2, byKey) {
|
|
|
145822
145849
|
}
|
|
145823
145850
|
const territoryOf3 = ([territoryId, owner, armies, fogLevel]) => ({
|
|
145824
145851
|
territoryId,
|
|
145825
|
-
owner:
|
|
145852
|
+
owner: ownerOf11(owner),
|
|
145826
145853
|
armies,
|
|
145827
145854
|
...fogLevel !== void 0 ? { fogLevel } : {}
|
|
145828
145855
|
});
|
|
@@ -146176,7 +146203,7 @@ function checkMoveOptions(args) {
|
|
|
146176
146203
|
const { moves, board, myInGameId: me, teammates } = args;
|
|
146177
146204
|
const s = args.settings;
|
|
146178
146205
|
const standing = new Map(board.map((t) => [t.territoryId, t]));
|
|
146179
|
-
const
|
|
146206
|
+
const ownerOf11 = (id) => {
|
|
146180
146207
|
const t = standing.get(id);
|
|
146181
146208
|
return t && !t.fogged ? t.owner : void 0;
|
|
146182
146209
|
};
|
|
@@ -146200,7 +146227,7 @@ function checkMoveOptions(args) {
|
|
|
146200
146227
|
hint: "Send it without `mode`: an ordinary attack/transfer."
|
|
146201
146228
|
});
|
|
146202
146229
|
}
|
|
146203
|
-
const target =
|
|
146230
|
+
const target = ownerOf11(m.to.id);
|
|
146204
146231
|
const friendly = target === me || target !== void 0 && teammates.has(target) && !m.attackTeammates;
|
|
146205
146232
|
if (m.mode === "transfer-only" && !friendly) {
|
|
146206
146233
|
warnings.push(
|
|
@@ -148412,12 +148439,12 @@ function stagingCandidates(input2, plain, guardOn = true) {
|
|
|
148412
148439
|
const { graph, board, me } = input2;
|
|
148413
148440
|
const guard = guardOn ? 1 : 0;
|
|
148414
148441
|
const at2 = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
148415
|
-
const
|
|
148442
|
+
const ownerOf11 = (id) => {
|
|
148416
148443
|
const t = at2.get(id);
|
|
148417
148444
|
if (!t || t.armies === null) return void 0;
|
|
148418
148445
|
return t.owner.kind === "player" ? t.owner.playerId : t.owner.kind === "neutral" ? "neutral" : void 0;
|
|
148419
148446
|
};
|
|
148420
|
-
const isMine3 = (id) =>
|
|
148447
|
+
const isMine3 = (id) => ownerOf11(id) === me;
|
|
148421
148448
|
const armies = (id) => at2.get(id)?.armies ?? 0;
|
|
148422
148449
|
const commanderOn2 = (id) => at2.get(id)?.specialUnits?.some((u) => u.kind === "commander" && u.playerId === me) === true;
|
|
148423
148450
|
const conceded = new Set(plain.conceded);
|
|
@@ -148433,15 +148460,15 @@ function stagingCandidates(input2, plain, guardOn = true) {
|
|
|
148433
148460
|
if (b.value <= 0 || !b.territoryIds.includes(t)) continue;
|
|
148434
148461
|
const others = b.territoryIds.filter((x) => x !== t);
|
|
148435
148462
|
if (others.every(mineAfter)) gain += b.value;
|
|
148436
|
-
const owner =
|
|
148437
|
-
if (typeof owner === "number" && b.territoryIds.every((x) =>
|
|
148463
|
+
const owner = ownerOf11(t);
|
|
148464
|
+
if (typeof owner === "number" && b.territoryIds.every((x) => ownerOf11(x) === owner)) gain += b.value;
|
|
148438
148465
|
}
|
|
148439
148466
|
return gain;
|
|
148440
148467
|
};
|
|
148441
148468
|
const out = [];
|
|
148442
|
-
const targets = board.territories.map((t) => t.territoryId).filter((t) => !isMine3(t) &&
|
|
148469
|
+
const targets = board.territories.map((t) => t.territoryId).filter((t) => !isMine3(t) && ownerOf11(t) !== void 0 && !taken.has(t)).map((t) => ({ t, gain: gainOf(t) })).filter((x) => x.gain > 0).sort((a, b) => b.gain - a.gain || a.t - b.t);
|
|
148443
148470
|
for (const { t, gain } of targets.slice(0, 3)) {
|
|
148444
|
-
const defenders2 = armies(t) + (typeof
|
|
148471
|
+
const defenders2 = armies(t) + (typeof ownerOf11(t) === "number" ? plain.enemyDeploy : 0);
|
|
148445
148472
|
const attack = armiesToTake(defenders2, {
|
|
148446
148473
|
...rates.offensiveKillRate !== void 0 ? { offensiveKillRate: rates.offensiveKillRate } : {},
|
|
148447
148474
|
...rates.defensiveKillRate !== void 0 ? { defensiveKillRate: rates.defensiveKillRate } : {}
|
|
@@ -148552,7 +148579,7 @@ function bombedBoard(board, target) {
|
|
|
148552
148579
|
function bombCandidates(input2) {
|
|
148553
148580
|
const { graph, board, me } = input2;
|
|
148554
148581
|
const at2 = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
148555
|
-
const
|
|
148582
|
+
const ownerOf11 = (id) => {
|
|
148556
148583
|
const t = at2.get(id);
|
|
148557
148584
|
return t?.owner.kind === "player" && t.armies !== null ? t.owner.playerId : void 0;
|
|
148558
148585
|
};
|
|
@@ -148563,13 +148590,13 @@ function bombCandidates(input2) {
|
|
|
148563
148590
|
);
|
|
148564
148591
|
const out = [];
|
|
148565
148592
|
for (const t of board.territories) {
|
|
148566
|
-
const owner =
|
|
148593
|
+
const owner = ownerOf11(t.territoryId);
|
|
148567
148594
|
if (owner === void 0 || friend(owner) || peace.has(owner)) continue;
|
|
148568
|
-
if (!neighborsOf(graph, t.territoryId).some((n) =>
|
|
148595
|
+
if (!neighborsOf(graph, t.territoryId).some((n) => ownerOf11(n) === me)) continue;
|
|
148569
148596
|
const armies = t.armies ?? 0;
|
|
148570
148597
|
if (armies < 2) continue;
|
|
148571
148598
|
const breaks = [...graph.bonusById.values()].some(
|
|
148572
|
-
(b) => b.value > 0 && b.territoryIds.includes(t.territoryId) && b.territoryIds.every((x) =>
|
|
148599
|
+
(b) => b.value > 0 && b.territoryIds.includes(t.territoryId) && b.territoryIds.every((x) => ownerOf11(x) === owner)
|
|
148573
148600
|
);
|
|
148574
148601
|
out.push({ target: t.territoryId, kind: breaks ? "break-bonus" : "cut-stack", armies, left: bombLeaves(armies) });
|
|
148575
148602
|
}
|
|
@@ -148732,6 +148759,12 @@ function stressPlan(input2) {
|
|
|
148732
148759
|
for (const s of stacks) {
|
|
148733
148760
|
const dep = deployOn(opp, s);
|
|
148734
148761
|
if (myTargets.has(s) && dep > 0) candidates2.push({ player: opp.id, kind: "reinforce", deployTo: s, deploy: dep, orders: [] });
|
|
148762
|
+
if (myTargets.has(s) && input2.firstMover !== "me") {
|
|
148763
|
+
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);
|
|
148764
|
+
if (beside.length) {
|
|
148765
|
+
candidates2.push({ player: opp.id, kind: "gather", deployTo: s, deploy: dep, orders: beside.map((n) => ({ from: n, to: s, armies: allOf(n, 0) })) });
|
|
148766
|
+
}
|
|
148767
|
+
}
|
|
148735
148768
|
}
|
|
148736
148769
|
if (reach.size >= 2) {
|
|
148737
148770
|
const bySize = [...reach.keys()].sort((a, b) => (start.get(b)?.armies ?? 0) - (start.get(a)?.armies ?? 0) || a - b);
|
|
@@ -148861,6 +148894,9 @@ function stressPlan(input2) {
|
|
|
148861
148894
|
deployTo: c.deployTo,
|
|
148862
148895
|
deploy: c.deploy,
|
|
148863
148896
|
...single ? { from: c.orders[0].from, to: c.orders[0].to, armies: sent ?? 0 } : {},
|
|
148897
|
+
...c.kind === "gather" ? {
|
|
148898
|
+
movedIn: c.orders.map((o, i2) => ({ from: o.from, armies: r.log.find((e) => e.player === c.player && e.index === i2)?.sent ?? 0 }))
|
|
148899
|
+
} : {},
|
|
148864
148900
|
...c.kind === "all-attack" || c.kind === "joint" ? { attacks: sides.flatMap((x) => x.orders.map((o) => ({ from: o.from, to: o.to }))) } : {},
|
|
148865
148901
|
...c.partner ? { partner: c.partner.player, partnerDeployTo: c.partner.deployTo, partnerDeploy: c.partner.deploy } : {},
|
|
148866
148902
|
...run2.firstOpponent !== void 0 ? { firstOpponent: run2.firstOpponent } : {},
|
|
@@ -148881,7 +148917,7 @@ function stressPlan(input2) {
|
|
|
148881
148917
|
};
|
|
148882
148918
|
const signature = (x) => JSON.stringify({ ...x, firstMover: void 0, firstOpponent: void 0 });
|
|
148883
148919
|
const runsFor = (c) => {
|
|
148884
|
-
const firsts = c.kind === "dodge" ? ["opponent"] : input2.firstMover !== void 0 ? [input2.firstMover] : ["me", "opponent"];
|
|
148920
|
+
const firsts = c.kind === "dodge" || c.kind === "gather" ? ["opponent"] : input2.firstMover !== void 0 ? [input2.firstMover] : ["me", "opponent"];
|
|
148885
148921
|
if (!c.partner) return firsts.map((f) => ({ firstMover: f, moveOrder: f === "me" ? [me, c.player] : [c.player, me] }));
|
|
148886
148922
|
const pair2 = [c.player, c.partner.player];
|
|
148887
148923
|
return firsts.flatMap(
|
|
@@ -149163,6 +149199,361 @@ function planBlockade(a) {
|
|
|
149163
149199
|
return best ? { best, considered } : { considered };
|
|
149164
149200
|
}
|
|
149165
149201
|
|
|
149202
|
+
// src/analysis/options.ts
|
|
149203
|
+
var STRATEGY_NOTE = "Mechanics, not advice: capture costs at the game's kill rates with no luck beyond them, deploy estimates as warapp_plan_turn reads them, and each alternative stress-tested against single-deploy replies only (as warapp_check_plan). The default plan is the planner's pick; choosing another or your own is yours to judge \u2014 check it with warapp_check_plan.";
|
|
149204
|
+
var MAX_OPTIONS = 15;
|
|
149205
|
+
var ownerOf8 = (t) => t?.owner.kind === "neutral" ? "neutral" : t?.owner.kind === "player" ? t.owner.playerId : null;
|
|
149206
|
+
function turnOptions(input2, limit = MAX_OPTIONS) {
|
|
149207
|
+
const { graph: g, board, me } = input2;
|
|
149208
|
+
const state = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
149209
|
+
const guard = input2.guard === false ? 0 : 1;
|
|
149210
|
+
const mine3 = new Set(board.territories.filter((t) => ownerOf8(t) === me).map((t) => t.territoryId));
|
|
149211
|
+
const foe = (o) => typeof o === "number" && o !== me && !input2.friends?.has(o);
|
|
149212
|
+
const armies = (t) => state.get(t)?.armies ?? 0;
|
|
149213
|
+
const take = (defenders2) => armiesToTake(defenders2, input2.rates);
|
|
149214
|
+
const bonusesOf3 = /* @__PURE__ */ new Map();
|
|
149215
|
+
for (const b of g.map.bonuses) for (const t of bonusTerritories(g, b.id)) bonusesOf3.set(t, [...bonusesOf3.get(t) ?? [], b.id]);
|
|
149216
|
+
const missing = (bonusId, held) => bonusTerritories(g, bonusId).filter((t) => !held.has(t)).length;
|
|
149217
|
+
const captures = [];
|
|
149218
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
149219
|
+
for (const m of [...mine3].sort((a, b) => a - b))
|
|
149220
|
+
for (const t of neighborsOf(g, m)) {
|
|
149221
|
+
if (mine3.has(t) || seen2.has(t)) continue;
|
|
149222
|
+
seen2.add(t);
|
|
149223
|
+
const st = state.get(t);
|
|
149224
|
+
const owner = ownerOf8(st);
|
|
149225
|
+
if (owner === null || st.armies === null) continue;
|
|
149226
|
+
if (typeof owner === "number" && input2.friends?.has(owner)) continue;
|
|
149227
|
+
const defenders2 = st.armies;
|
|
149228
|
+
const after = /* @__PURE__ */ new Set([...mine3, t]);
|
|
149229
|
+
const completes = [];
|
|
149230
|
+
const advances = [];
|
|
149231
|
+
for (const id of bonusesOf3.get(t) ?? []) {
|
|
149232
|
+
const b = g.bonusById.get(id);
|
|
149233
|
+
if (b.value <= 0) continue;
|
|
149234
|
+
const left = missing(id, after);
|
|
149235
|
+
if (left === 0) completes.push({ bonusId: id, value: b.value });
|
|
149236
|
+
else advances.push({ bonusId: id, value: b.value, missingAfter: left });
|
|
149237
|
+
}
|
|
149238
|
+
const opens = neighborsOf(g, t).filter(
|
|
149239
|
+
(n) => !mine3.has(n) && foe(ownerOf8(state.get(n))) && !neighborsOf(g, n).some((x) => mine3.has(x))
|
|
149240
|
+
).length;
|
|
149241
|
+
captures.push({
|
|
149242
|
+
target: t,
|
|
149243
|
+
owner,
|
|
149244
|
+
defenders: defenders2,
|
|
149245
|
+
needs: take(defenders2),
|
|
149246
|
+
...typeof owner === "number" ? { needsIfReinforced: take(defenders2 + Math.max(0, input2.deployOf(owner))) } : {},
|
|
149247
|
+
from: neighborsOf(g, t).filter((n) => mine3.has(n)).map((n) => ({ territoryId: n, spare: Math.max(0, armies(n) - guard) })).sort((a, b) => b.spare - a.spare || a.territoryId - b.territoryId),
|
|
149248
|
+
completes,
|
|
149249
|
+
advances: advances.sort((a, b) => a.missingAfter - b.missingAfter || b.value - a.value || a.bonusId - b.bonusId),
|
|
149250
|
+
incomeGain: completes.reduce((n, c) => n + c.value, 0),
|
|
149251
|
+
opensBorders: opens
|
|
149252
|
+
});
|
|
149253
|
+
}
|
|
149254
|
+
const nearest = (c) => c.advances.length ? c.advances[0].missingAfter : Infinity;
|
|
149255
|
+
const cost = (c) => c.needs ?? Infinity;
|
|
149256
|
+
captures.sort(
|
|
149257
|
+
(a, b) => b.incomeGain / Math.max(1, cost(b)) - a.incomeGain / Math.max(1, cost(a)) || nearest(a) - nearest(b) || cost(a) - cost(b) || a.target - b.target
|
|
149258
|
+
);
|
|
149259
|
+
const holds = [];
|
|
149260
|
+
for (const t of [...mine3].sort((a, b) => a - b)) {
|
|
149261
|
+
const byPlayer = /* @__PURE__ */ new Map();
|
|
149262
|
+
for (const n of neighborsOf(g, t)) {
|
|
149263
|
+
const o = ownerOf8(state.get(n));
|
|
149264
|
+
if (!foe(o)) continue;
|
|
149265
|
+
byPlayer.set(o, (byPlayer.get(o) ?? 0) + Math.max(0, armies(n) - guard));
|
|
149266
|
+
}
|
|
149267
|
+
if (!byPlayer.size) continue;
|
|
149268
|
+
const have = armies(t);
|
|
149269
|
+
const facing = [...byPlayer].sort((a, b) => a[0] - b[0]).map(([player2, stacks2]) => ({ player: player2, stacks: stacks2, deploy: Math.max(0, input2.deployOf(player2)) }));
|
|
149270
|
+
const add = (attack) => {
|
|
149271
|
+
let n = 0;
|
|
149272
|
+
while ((take(have + n) ?? Infinity) <= attack) n++;
|
|
149273
|
+
return n;
|
|
149274
|
+
};
|
|
149275
|
+
const stacks = Math.max(...facing.map((f) => f.stacks));
|
|
149276
|
+
const deployed = Math.max(...facing.map((f) => f.stacks + f.deploy));
|
|
149277
|
+
const protects = (bonusesOf3.get(t) ?? []).map((id) => g.bonusById.get(id)).filter((b) => b.value > 0 && bonusTerritories(g, b.id).every((x) => mine3.has(x))).map((b) => ({ bonusId: b.id, value: b.value }));
|
|
149278
|
+
holds.push({ territoryId: t, armies: have, facing, addAgainstStacks: add(stacks), addAgainstDeploy: add(deployed), protects });
|
|
149279
|
+
}
|
|
149280
|
+
const worth = (h) => h.protects.reduce((n, p) => n + p.value, 0);
|
|
149281
|
+
holds.sort((a, b) => worth(b) - worth(a) || b.addAgainstDeploy - a.addAgainstDeploy || a.territoryId - b.territoryId);
|
|
149282
|
+
return { captures: captures.slice(0, limit), holds: holds.slice(0, limit) };
|
|
149283
|
+
}
|
|
149284
|
+
var ALTERNATIVE_GOALS = ["expand", "defend"];
|
|
149285
|
+
function alternativePlans(input2, base, stress) {
|
|
149286
|
+
const view = (name, p) => {
|
|
149287
|
+
const s = stress?.(p);
|
|
149288
|
+
return {
|
|
149289
|
+
name,
|
|
149290
|
+
goal: p.goal,
|
|
149291
|
+
deploys: p.deploys.map((d) => ({ territoryId: d.territoryId, armies: d.armies })),
|
|
149292
|
+
moves: p.moves.map((m) => ({ from: m.from, to: m.to, armies: m.armies, kind: m.kind })),
|
|
149293
|
+
expected: {
|
|
149294
|
+
nextIncome: p.expected.nextIncome,
|
|
149295
|
+
captures: p.expected.captures,
|
|
149296
|
+
bonusesCompleted: p.expected.bonusesCompleted,
|
|
149297
|
+
...p.expected.nextIncomeIfConcededFall !== void 0 ? { nextIncomeIfConcededFall: p.expected.nextIncomeIfConcededFall } : {}
|
|
149298
|
+
},
|
|
149299
|
+
conceded: p.conceded,
|
|
149300
|
+
...s ? { stress: s } : {}
|
|
149301
|
+
};
|
|
149302
|
+
};
|
|
149303
|
+
const key = (p) => JSON.stringify([p.deploys.map((d) => [d.territoryId, d.armies]), p.moves.map((m) => [m.from, m.to, m.armies])]);
|
|
149304
|
+
const out = [view("default", base)];
|
|
149305
|
+
const keys = /* @__PURE__ */ new Set([key(base)]);
|
|
149306
|
+
for (const goal of ALTERNATIVE_GOALS) {
|
|
149307
|
+
if (goal === base.goal) continue;
|
|
149308
|
+
const p = planTurn({ ...input2, options: { ...input2.options, goal } });
|
|
149309
|
+
if (keys.has(key(p))) continue;
|
|
149310
|
+
keys.add(key(p));
|
|
149311
|
+
out.push(view(goal, p));
|
|
149312
|
+
}
|
|
149313
|
+
return out;
|
|
149314
|
+
}
|
|
149315
|
+
function stressSummary(r) {
|
|
149316
|
+
return {
|
|
149317
|
+
safe: r.considered === 0 ? null : r.harmful === 0,
|
|
149318
|
+
harmful: r.harmful,
|
|
149319
|
+
considered: r.considered,
|
|
149320
|
+
...r.worst ? { worst: { opponent: r.worst.opponent, lost: r.worst.lost, capturesFailed: r.worst.capturesFailed, incomeLost: r.worst.incomeLost } } : {}
|
|
149321
|
+
};
|
|
149322
|
+
}
|
|
149323
|
+
|
|
149324
|
+
// src/analysis/situation.ts
|
|
149325
|
+
var MAX_SITUATION_TERRITORIES = 400;
|
|
149326
|
+
var MAX_SITUATION_BONUSES = 60;
|
|
149327
|
+
var SITUATION_PAST_TURNS = 10;
|
|
149328
|
+
var ownerOf9 = (t, me) => {
|
|
149329
|
+
if (!t || t.owner.kind === "unknown") return "fog";
|
|
149330
|
+
if (t.owner.kind !== "player") return "neutral";
|
|
149331
|
+
return t.owner.playerId === me ? "me" : t.owner.playerId;
|
|
149332
|
+
};
|
|
149333
|
+
function situation(input2) {
|
|
149334
|
+
const { graph: g, board, me } = input2;
|
|
149335
|
+
const guard = input2.guard === false ? 0 : 1;
|
|
149336
|
+
const state = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
149337
|
+
const owner = (id) => ownerOf9(state.get(id), me);
|
|
149338
|
+
const armiesOf3 = (id) => state.get(id)?.armies ?? null;
|
|
149339
|
+
const mine3 = [...state.keys()].filter((id) => owner(id) === "me").sort((a, b) => a - b);
|
|
149340
|
+
const mineSet = new Set(mine3);
|
|
149341
|
+
const take = (n) => armiesToTake(n, input2.rates);
|
|
149342
|
+
const dist = new Map(mine3.map((m) => [m, 0]));
|
|
149343
|
+
let frontier = mine3;
|
|
149344
|
+
while (frontier.length) {
|
|
149345
|
+
const next = [];
|
|
149346
|
+
for (const t of frontier)
|
|
149347
|
+
for (const n of neighborsOf(g, t))
|
|
149348
|
+
if (!dist.has(n)) {
|
|
149349
|
+
dist.set(n, dist.get(t) + 1);
|
|
149350
|
+
next.push(n);
|
|
149351
|
+
}
|
|
149352
|
+
frontier = next;
|
|
149353
|
+
}
|
|
149354
|
+
const bonusesOf3 = /* @__PURE__ */ new Map();
|
|
149355
|
+
for (const b of g.map.bonuses) for (const t of bonusTerritories(g, b.id)) bonusesOf3.set(t, [...bonusesOf3.get(t) ?? [], b.id]);
|
|
149356
|
+
const listed = [...g.territoryById.keys()].filter((id) => owner(id) !== "fog" || neighborsOf(g, id).some((n) => mineSet.has(n))).sort((a, b) => (dist.get(a) ?? Infinity) - (dist.get(b) ?? Infinity) || a - b);
|
|
149357
|
+
const territories = listed.slice(0, MAX_SITUATION_TERRITORIES).map((id) => {
|
|
149358
|
+
const t = state.get(id);
|
|
149359
|
+
const units = t?.specialUnits?.map((u) => ({ kind: u.kind, owner: u.playerId === me ? "me" : u.playerId }));
|
|
149360
|
+
return {
|
|
149361
|
+
id,
|
|
149362
|
+
name: g.territoryById.get(id)?.name ?? String(id),
|
|
149363
|
+
owner: owner(id),
|
|
149364
|
+
armies: armiesOf3(id),
|
|
149365
|
+
...units?.length ? { units } : {},
|
|
149366
|
+
distance: dist.get(id) ?? -1,
|
|
149367
|
+
bonuses: bonusesOf3.get(id) ?? [],
|
|
149368
|
+
neighbors: [...neighborsOf(g, id)]
|
|
149369
|
+
};
|
|
149370
|
+
});
|
|
149371
|
+
const bonuses = [];
|
|
149372
|
+
for (const b of g.map.bonuses) {
|
|
149373
|
+
if (b.value <= 0) continue;
|
|
149374
|
+
const members2 = bonusTerritories(g, b.id);
|
|
149375
|
+
let mineN = 0;
|
|
149376
|
+
let neutral = 0;
|
|
149377
|
+
let fogged = 0;
|
|
149378
|
+
const players = /* @__PURE__ */ new Map();
|
|
149379
|
+
for (const t of members2) {
|
|
149380
|
+
const o = owner(t);
|
|
149381
|
+
if (o === "me") mineN++;
|
|
149382
|
+
else if (o === "neutral") neutral++;
|
|
149383
|
+
else if (o === "fog") fogged++;
|
|
149384
|
+
else players.set(o, (players.get(o) ?? 0) + 1);
|
|
149385
|
+
}
|
|
149386
|
+
const heldBy3 = mineN === members2.length ? "me" : players.size === 1 && [...players.values()][0] === members2.length ? [...players.keys()][0] : null;
|
|
149387
|
+
const near2 = members2.some((t) => (dist.get(t) ?? Infinity) <= 1);
|
|
149388
|
+
if (!near2 && heldBy3 === null) continue;
|
|
149389
|
+
const missing = members2.filter((t) => owner(t) !== "me");
|
|
149390
|
+
const hidden = missing.some((t) => armiesOf3(t) === null);
|
|
149391
|
+
bonuses.push({
|
|
149392
|
+
bonusId: b.id,
|
|
149393
|
+
name: b.name,
|
|
149394
|
+
value: b.value,
|
|
149395
|
+
size: members2.length,
|
|
149396
|
+
mine: mineN,
|
|
149397
|
+
neutral,
|
|
149398
|
+
fogged,
|
|
149399
|
+
players: [...players].sort((x, y) => x[0] - y[0]).map(([player2, count4]) => ({ player: player2, count: count4 })),
|
|
149400
|
+
heldBy: heldBy3,
|
|
149401
|
+
missing,
|
|
149402
|
+
armiesToFinish: hidden ? null : missing.reduce((n, t) => n + (take(armiesOf3(t)) ?? Infinity), 0),
|
|
149403
|
+
reachable: missing.filter((t) => neighborsOf(g, t).some((n) => mineSet.has(n)))
|
|
149404
|
+
});
|
|
149405
|
+
}
|
|
149406
|
+
bonuses.sort(
|
|
149407
|
+
(a, b) => Number(b.heldBy === "me") - Number(a.heldBy === "me") || a.missing.length - b.missing.length || b.value - a.value || a.bonusId - b.bonusId
|
|
149408
|
+
);
|
|
149409
|
+
const opponents = [...input2.opponents].filter((o) => o.playerId !== me && !input2.friends?.has(o.playerId)).sort((a, b) => a.playerId - b.playerId).map((o) => {
|
|
149410
|
+
const theirs = [...state.keys()].filter((id) => owner(id) === o.playerId);
|
|
149411
|
+
const besideMe = theirs.filter((id) => neighborsOf(g, id).some((n) => mineSet.has(n))).map((id) => ({ territoryId: id, armies: armiesOf3(id) ?? 0, borders: neighborsOf(g, id).filter((n) => mineSet.has(n)) }));
|
|
149412
|
+
return {
|
|
149413
|
+
player: o.playerId,
|
|
149414
|
+
income: {
|
|
149415
|
+
estimate: o.estimate,
|
|
149416
|
+
...o.source !== void 0 ? { source: o.source } : {},
|
|
149417
|
+
...o.visibleIncome !== void 0 ? { visible: o.visibleIncome } : {},
|
|
149418
|
+
...o.tracked !== void 0 ? { tracked: o.tracked } : {},
|
|
149419
|
+
...o.range !== void 0 ? { range: o.range } : {},
|
|
149420
|
+
...o.coverage !== void 0 ? { coverage: o.coverage } : {}
|
|
149421
|
+
},
|
|
149422
|
+
...o.history?.length ? { history: o.history.map((h) => ({ turn: h.turn, observed: h.observed })) } : {},
|
|
149423
|
+
territoriesInView: theirs.length,
|
|
149424
|
+
armiesInView: theirs.reduce((n, id) => n + (armiesOf3(id) ?? 0), 0),
|
|
149425
|
+
bonusesHeld: bonuses.filter((b) => b.heldBy === o.playerId).map((b) => ({ bonusId: b.bonusId, value: b.value })),
|
|
149426
|
+
besideMe,
|
|
149427
|
+
movableBesideMe: besideMe.reduce((n, s) => n + Math.max(0, s.armies - guard), 0)
|
|
149428
|
+
};
|
|
149429
|
+
});
|
|
149430
|
+
let changes = null;
|
|
149431
|
+
if (input2.previousBoard) {
|
|
149432
|
+
const prev = new Map(input2.previousBoard.territories.map((t) => [t.territoryId, t]));
|
|
149433
|
+
const was = (id) => ownerOf9(prev.get(id), me);
|
|
149434
|
+
const lost = [];
|
|
149435
|
+
const gained = [];
|
|
149436
|
+
const moved = [];
|
|
149437
|
+
for (const id of [.../* @__PURE__ */ new Set([...prev.keys(), ...state.keys()])].sort((a, b) => a - b)) {
|
|
149438
|
+
const before = was(id);
|
|
149439
|
+
const now = owner(id);
|
|
149440
|
+
if (before === "me" && now !== "me") lost.push({ territoryId: id, to: now });
|
|
149441
|
+
else if (now === "me" && before !== "me") gained.push({ territoryId: id, from: before });
|
|
149442
|
+
else if (typeof now === "number" && before === now) {
|
|
149443
|
+
const a = prev.get(id)?.armies;
|
|
149444
|
+
const b = armiesOf3(id);
|
|
149445
|
+
if (a !== null && a !== void 0 && b !== null && a !== b) moved.push({ territoryId: id, owner: now, was: a, now: b });
|
|
149446
|
+
}
|
|
149447
|
+
}
|
|
149448
|
+
moved.sort((x, y) => Math.abs(y.now - y.was) - Math.abs(x.now - x.was) || x.territoryId - y.territoryId);
|
|
149449
|
+
changes = { lost, gained, moved: moved.slice(0, MAX_SITUATION_BONUSES) };
|
|
149450
|
+
}
|
|
149451
|
+
const past = [...input2.pastBoards ?? []].sort((a, b) => a.turn - b.turn).slice(-SITUATION_PAST_TURNS).map((p) => {
|
|
149452
|
+
const at2 = new Map(p.board.territories.map((t) => [t.territoryId, t]));
|
|
149453
|
+
const sides = /* @__PURE__ */ new Map();
|
|
149454
|
+
for (const t of p.board.territories) {
|
|
149455
|
+
const o = ownerOf9(t, me);
|
|
149456
|
+
if (o === "fog" || o === "neutral") continue;
|
|
149457
|
+
const side2 = sides.get(o) ?? { territories: 0, armies: 0 };
|
|
149458
|
+
side2.territories++;
|
|
149459
|
+
side2.armies += t.armies ?? 0;
|
|
149460
|
+
sides.set(o, side2);
|
|
149461
|
+
}
|
|
149462
|
+
const held = (o) => g.map.bonuses.filter((b) => b.value > 0 && bonusTerritories(g, b.id).every((t) => ownerOf9(at2.get(t), me) === o)).map((b) => b.id);
|
|
149463
|
+
return {
|
|
149464
|
+
turn: p.turn,
|
|
149465
|
+
sides: [...sides].sort((a, b) => a[0] === "me" ? -1 : b[0] === "me" ? 1 : a[0] - b[0]).map(([o, v]) => ({ owner: o, ...v, bonusesHeld: held(o) })),
|
|
149466
|
+
...p.orders ? {
|
|
149467
|
+
myOrders: {
|
|
149468
|
+
deploys: p.orders.deploys.map((d) => ({ territoryId: d.territoryId, armies: d.armies })),
|
|
149469
|
+
moves: p.orders.moves.map((m) => ({ from: m.from, to: m.to, armies: m.armies }))
|
|
149470
|
+
}
|
|
149471
|
+
} : {}
|
|
149472
|
+
};
|
|
149473
|
+
});
|
|
149474
|
+
return {
|
|
149475
|
+
me: {
|
|
149476
|
+
income: input2.myIncome,
|
|
149477
|
+
incomeHistory: [...input2.incomeHistory ?? []],
|
|
149478
|
+
territories: mine3.length,
|
|
149479
|
+
armies: mine3.reduce((n, id) => n + (armiesOf3(id) ?? 0), 0),
|
|
149480
|
+
bonusesHeld: bonuses.filter((b) => b.heldBy === "me").map((b) => ({ bonusId: b.bonusId, value: b.value }))
|
|
149481
|
+
},
|
|
149482
|
+
territories,
|
|
149483
|
+
territoriesOmitted: Math.max(0, listed.length - MAX_SITUATION_TERRITORIES),
|
|
149484
|
+
bonuses: bonuses.slice(0, MAX_SITUATION_BONUSES),
|
|
149485
|
+
bonusesOmitted: Math.max(0, bonuses.length - MAX_SITUATION_BONUSES),
|
|
149486
|
+
opponents,
|
|
149487
|
+
changes,
|
|
149488
|
+
past
|
|
149489
|
+
};
|
|
149490
|
+
}
|
|
149491
|
+
var FACT_PARTS = ["me", "territories", "bonuses", "opponents", "changes", "past"];
|
|
149492
|
+
var FACTS_AVAILABLE = {
|
|
149493
|
+
me: "my income and its history, land, armies and bonuses held",
|
|
149494
|
+
territories: "every territory in view and each hidden one beside my land, nearest first: owner, armies, special units, bonuses, neighbours",
|
|
149495
|
+
bonuses: "each bonus that matters: who holds how much of it, what finishing it costs, the members in reach",
|
|
149496
|
+
opponents: "each opponent's income estimate with how it was read (source, visible, tracked, range, coverage, per-turn deploys), its bonuses and its stacks beside me",
|
|
149497
|
+
changes: "what changed since last turn: territories lost and gained, stacks that grew or shrank",
|
|
149498
|
+
past: "each of the last 10 turns kept: every side in view, its bonuses, my orders"
|
|
149499
|
+
};
|
|
149500
|
+
function pickFacts(s, parts) {
|
|
149501
|
+
const want = new Set(parts);
|
|
149502
|
+
return {
|
|
149503
|
+
...want.has("me") ? { me: s.me } : {},
|
|
149504
|
+
...want.has("territories") ? { territories: s.territories, territoriesOmitted: s.territoriesOmitted } : {},
|
|
149505
|
+
...want.has("bonuses") ? { bonuses: s.bonuses, bonusesOmitted: s.bonusesOmitted } : {},
|
|
149506
|
+
...want.has("opponents") ? { opponents: s.opponents } : {},
|
|
149507
|
+
...want.has("changes") ? { changes: s.changes } : {},
|
|
149508
|
+
...want.has("past") ? { past: s.past } : {}
|
|
149509
|
+
};
|
|
149510
|
+
}
|
|
149511
|
+
var MORE_ON_REQUEST = 'Ask for more when you want to weigh the plan or build your own: strategy: true adds ranked captures and holds and the plan beside expand/defend alternatives, each stress-tested; facts: ["me","territories","bonuses","opponents","changes","past"] (any of them) adds the raw game state behind them. Test any orders with warapp_check_plan.';
|
|
149512
|
+
var OWN_PLAN_STEPS = [
|
|
149513
|
+
"The plan, options and alternatives are inputs to your judgement, not the answer; ask warapp_plan_turn for the facts your decision needs (facts: me, territories, bonuses, opponents, changes, past).",
|
|
149514
|
+
"Write your own deploys and moves (any mix of the options, the alternatives or neither).",
|
|
149515
|
+
"Test them with warapp_check_plan (every opponent's replies, both move orders, one turn ahead); change and test again as needed.",
|
|
149516
|
+
"Look deeper when it matters: warapp_turn_history (what happened turn by turn), warapp_track_opponents and warapp_profile_opponents (how each opponent plays), warapp_plan_route (paths), warapp_get_map (the whole map), warapp_strategy (notes for this game), warapp_get_chat.",
|
|
149517
|
+
"Submit with warapp_submit_turn; when your orders differ from the plan, pass override_reason so the decision log keeps why."
|
|
149518
|
+
];
|
|
149519
|
+
|
|
149520
|
+
// src/tools/bait.ts
|
|
149521
|
+
function baitAttackWarning(input2) {
|
|
149522
|
+
const { graph, board, me, settings, label: label3, name } = input2;
|
|
149523
|
+
const teammates = input2.teammates ?? /* @__PURE__ */ new Set();
|
|
149524
|
+
const standing = new Map(board.map((t) => [t.territoryId, t]));
|
|
149525
|
+
const guard = settings.oneArmyStandsGuard === false ? 0 : 1;
|
|
149526
|
+
const rates = {
|
|
149527
|
+
...settings.offensiveKillRate !== void 0 ? { offensiveKillRate: settings.offensiveKillRate } : {},
|
|
149528
|
+
...settings.defensiveKillRate !== void 0 ? { defensiveKillRate: settings.defensiveKillRate } : {}
|
|
149529
|
+
};
|
|
149530
|
+
const byTarget = /* @__PURE__ */ new Map();
|
|
149531
|
+
for (const m of input2.moves) {
|
|
149532
|
+
const t = standing.get(m.to.id);
|
|
149533
|
+
if (m.mode === "transfer-only" || !t || t.fogged || t.owner === me || t.owner < 0) continue;
|
|
149534
|
+
if (teammates.has(t.owner) && m.attackTeammates !== true) continue;
|
|
149535
|
+
const power = m.armies + (m.commander ? COMMANDER_STRENGTH : 0);
|
|
149536
|
+
const g = byTarget.get(m.to.id);
|
|
149537
|
+
if (g) g.armies += power;
|
|
149538
|
+
else byTarget.set(m.to.id, { from: m.from, to: m.to, armies: power });
|
|
149539
|
+
}
|
|
149540
|
+
const parts = [];
|
|
149541
|
+
for (const [id, a] of byTarget) {
|
|
149542
|
+
const target = standing.get(id);
|
|
149543
|
+
const owner = target.owner;
|
|
149544
|
+
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);
|
|
149545
|
+
if (!stacks.length) continue;
|
|
149546
|
+
const defenders2 = (target.armies ?? 0) + specialUnitStrength(target.specialUnits) + stacks.reduce((n, s) => n + s.moves, 0);
|
|
149547
|
+
const needs = armiesToTake(defenders2, rates);
|
|
149548
|
+
if (needs !== null && a.armies >= needs) continue;
|
|
149549
|
+
parts.push(
|
|
149550
|
+
`${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}`}`
|
|
149551
|
+
);
|
|
149552
|
+
}
|
|
149553
|
+
if (!parts.length) return void 0;
|
|
149554
|
+
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).`;
|
|
149555
|
+
}
|
|
149556
|
+
|
|
149166
149557
|
// src/analysis/chat-advice.ts
|
|
149167
149558
|
var CLOSE_RATIO = 0.85;
|
|
149168
149559
|
var CLEAR_LEAD_RATIO = 1.2;
|
|
@@ -150693,7 +151084,7 @@ var OUTREACH_DRAFTS = 2;
|
|
|
150693
151084
|
var COALITION_NOTE_IDS = ["ffa-coalition-match-commitment", "ffa-second-needs-third"];
|
|
150694
151085
|
function leaderBonuses(graph, board, leader, candidates2) {
|
|
150695
151086
|
const at2 = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
150696
|
-
const
|
|
151087
|
+
const ownerOf11 = (id) => {
|
|
150697
151088
|
const o = at2.get(id)?.owner;
|
|
150698
151089
|
return o?.kind === "player" ? o.playerId : void 0;
|
|
150699
151090
|
};
|
|
@@ -150701,13 +151092,13 @@ function leaderBonuses(graph, board, leader, candidates2) {
|
|
|
150701
151092
|
for (const bonus of [...graph.bonusById.values()].sort((a, b) => a.id - b.id)) {
|
|
150702
151093
|
if (bonus.value <= 0) continue;
|
|
150703
151094
|
const ts = bonusTerritories(graph, bonus.id);
|
|
150704
|
-
if (!ts.length || !ts.every((t) =>
|
|
151095
|
+
if (!ts.length || !ts.every((t) => ownerOf11(t) === leader)) continue;
|
|
150705
151096
|
const by = /* @__PURE__ */ new Map();
|
|
150706
151097
|
for (const t of [...ts].sort((a, b) => a - b)) {
|
|
150707
151098
|
const defenders2 = (at2.get(t)?.armies ?? 0) + specialUnitStrength(at2.get(t)?.specialUnits);
|
|
150708
151099
|
const beside = /* @__PURE__ */ new Map();
|
|
150709
151100
|
for (const n of neighborsOf(graph, t)) {
|
|
150710
|
-
const p =
|
|
151101
|
+
const p = ownerOf11(n);
|
|
150711
151102
|
if (p !== void 0 && p !== leader && candidates2.has(p)) beside.set(p, (beside.get(p) ?? 0) + (at2.get(n)?.armies ?? 0));
|
|
150712
151103
|
}
|
|
150713
151104
|
for (const [p, armies] of beside) {
|
|
@@ -154948,7 +155339,9 @@ async function livePlanSetup(ctx, a) {
|
|
|
154948
155339
|
commerce,
|
|
154949
155340
|
statedShifts: shifts,
|
|
154950
155341
|
// #427: the last turn's Reinforcement plays, for warapp_plan_turn to keep (only when plays show).
|
|
154951
|
-
seenPlays: playsShown ? lastPlays : void 0
|
|
155342
|
+
seenPlays: playsShown ? lastPlays : void 0,
|
|
155343
|
+
// #606: the earlier boards (and my orders on them) for the strategy view's summary of past turns.
|
|
155344
|
+
pastBoards: history.boards
|
|
154952
155345
|
};
|
|
154953
155346
|
}
|
|
154954
155347
|
var CARD_AIRLIFT2 = 6;
|
|
@@ -155410,13 +155803,19 @@ function registerTurnTools(server, ctx, opts = {}) {
|
|
|
155410
155803
|
keep_cards: external_exports.coerce.number().int().min(0).max(100).optional().describe(
|
|
155411
155804
|
"Airlift cards to keep in reserve: `airliftPlan` plays only those held beyond this many (default 0). Changes nothing when you hold no Airlift."
|
|
155412
155805
|
),
|
|
155806
|
+
strategy: external_exports.boolean().optional().describe(
|
|
155807
|
+
"true adds `strategy` (#606), a menu for choosing a turn yourself: `options.captures` \u2014 each territory in view beside yours that is not yours, ranked by income gained per army: its defenders, the attackers that take it (and, a player's, after its owner's whole deploy), the spare armies beside it, the bonuses it completes or advances and the new borders facing a player it opens; `options.holds` \u2014 each border facing a player: the armies to add to hold against the stacks beside it alone and against them plus one whole deploy, and the held bonuses it protects; `alternatives` \u2014 this plan and the planner under the goals expand and defend, each with its orders, what it expects and its stress test against the opponents' replies (safe, harmful replies, the worst one); `available` \u2014 the raw facts you can ask for with `facts`; and `steps`. Choose, combine or build your own, then check with warapp_check_plan; warapp_submit_turn keeps an override reason in the decision log. Default false."
|
|
155808
|
+
),
|
|
155809
|
+
facts: external_exports.array(external_exports.enum(FACT_PARTS)).min(1).optional().describe(
|
|
155810
|
+
"The raw game state behind the plan, only the parts you name (#606), as `facts`: `me` (" + FACTS_AVAILABLE.me + "), `territories` (" + FACTS_AVAILABLE.territories + "), `bonuses` (" + FACTS_AVAILABLE.bonuses + "), `opponents` (" + FACTS_AVAILABLE.opponents + "), `changes` (" + FACTS_AVAILABLE.changes + "), `past` (" + FACTS_AVAILABLE.past + "). Ask for what your decision needs; whole past boards are in warapp_turn_history. Default none."
|
|
155811
|
+
),
|
|
155413
155812
|
view: viewArg(
|
|
155414
155813
|
VIEWS6,
|
|
155415
155814
|
`compact (default) gives the plan and orders (the profile as format, phase and standing); "full" adds each move's reason, the whole profile and the settings the plan assumed.`
|
|
155416
155815
|
)
|
|
155417
155816
|
})
|
|
155418
155817
|
},
|
|
155419
|
-
async ({ game_id, player: player2, goal, siege_target, jabs, focus, reserve, enemy_deploy, known_income, fogged_attackers, avoid_territories, avoid_players, min_win_chance, first_mover, keep_cards, view }) => {
|
|
155818
|
+
async ({ game_id, player: player2, goal, siege_target, jabs, focus, reserve, enemy_deploy, known_income, fogged_attackers, avoid_territories, avoid_players, min_win_chance, first_mover, keep_cards, strategy, facts, view }) => {
|
|
155420
155819
|
const feed = await ctx.client.getGame(game_id, { settings: true, chat: true });
|
|
155421
155820
|
requireTurnPhase(feed);
|
|
155422
155821
|
const map2 = mapOf(feed);
|
|
@@ -155728,6 +156127,74 @@ function registerTurnTools(server, ctx, opts = {}) {
|
|
|
155728
156127
|
guessSkip = { reason: "commander", message };
|
|
155729
156128
|
}
|
|
155730
156129
|
}
|
|
156130
|
+
const factsView = facts ? pickFacts(
|
|
156131
|
+
situation({
|
|
156132
|
+
graph,
|
|
156133
|
+
board,
|
|
156134
|
+
...setup.input.previousBoard ? { previousBoard: setup.input.previousBoard } : {},
|
|
156135
|
+
me: me.id,
|
|
156136
|
+
...setup.teams ? { friends: new Set([...setup.teams].filter(([id, t]) => id !== me.id && t === setup.teams.get(me.id)).map(([id]) => id)) } : {},
|
|
156137
|
+
rates: { offensiveKillRate: settings.offensiveKillRate, defensiveKillRate: settings.defensiveKillRate },
|
|
156138
|
+
guard: settings.oneArmyStandsGuard !== false,
|
|
156139
|
+
myIncome: income,
|
|
156140
|
+
...setup.input.incomeHistory ? { incomeHistory: setup.input.incomeHistory } : {},
|
|
156141
|
+
pastBoards: setup.pastBoards,
|
|
156142
|
+
opponents: estimates.map((e) => {
|
|
156143
|
+
const t = tracks?.find((x) => x.playerId === e.playerId);
|
|
156144
|
+
return {
|
|
156145
|
+
playerId: e.playerId,
|
|
156146
|
+
estimate: e.estimate,
|
|
156147
|
+
source: e.source,
|
|
156148
|
+
visibleIncome: e.base + e.bonusIncome,
|
|
156149
|
+
tracked: t?.income ?? null,
|
|
156150
|
+
range: e.thinEvidence ? { low: e.thinEvidence.lower, high: e.thinEvidence.upper } : null,
|
|
156151
|
+
coverage: t?.coverage?.share ?? null,
|
|
156152
|
+
...t ? { history: t.turns.map((x) => ({ turn: x.to, observed: x.observed })) } : {}
|
|
156153
|
+
};
|
|
156154
|
+
})
|
|
156155
|
+
}),
|
|
156156
|
+
facts
|
|
156157
|
+
) : void 0;
|
|
156158
|
+
const strategyView = strategy ? (() => {
|
|
156159
|
+
const deployOf = (p) => estimates.find((e) => e.playerId === p)?.estimate ?? 0;
|
|
156160
|
+
const stressOpp = estimates.map((e) => ({ id: e.playerId, deploy: e.estimate }));
|
|
156161
|
+
const stress = (p) => {
|
|
156162
|
+
if (!stressOpp.length) return void 0;
|
|
156163
|
+
try {
|
|
156164
|
+
return stressSummary(
|
|
156165
|
+
stressPlan({
|
|
156166
|
+
graph,
|
|
156167
|
+
board,
|
|
156168
|
+
me: me.id,
|
|
156169
|
+
deploys: p.deploys,
|
|
156170
|
+
moves: p.moves.map((m) => ({ from: m.from, to: m.to, armies: m.armies })),
|
|
156171
|
+
opponents: stressOpp,
|
|
156172
|
+
settings,
|
|
156173
|
+
...setup.teams ? { teams: setup.teams } : {},
|
|
156174
|
+
lookAhead: false,
|
|
156175
|
+
maxReplies: 1
|
|
156176
|
+
})
|
|
156177
|
+
);
|
|
156178
|
+
} catch {
|
|
156179
|
+
return void 0;
|
|
156180
|
+
}
|
|
156181
|
+
};
|
|
156182
|
+
return {
|
|
156183
|
+
options: turnOptions({
|
|
156184
|
+
graph,
|
|
156185
|
+
board,
|
|
156186
|
+
me: me.id,
|
|
156187
|
+
deployOf,
|
|
156188
|
+
rates: { offensiveKillRate: settings.offensiveKillRate, defensiveKillRate: settings.defensiveKillRate },
|
|
156189
|
+
guard: settings.oneArmyStandsGuard !== false,
|
|
156190
|
+
...setup.teams ? { friends: new Set([...setup.teams].filter(([id, t]) => id !== me.id && t === setup.teams.get(me.id)).map(([id]) => id)) } : {}
|
|
156191
|
+
}),
|
|
156192
|
+
alternatives: alternativePlans(setup.input, plan, stress),
|
|
156193
|
+
available: FACTS_AVAILABLE,
|
|
156194
|
+
steps: OWN_PLAN_STEPS,
|
|
156195
|
+
note: STRATEGY_NOTE
|
|
156196
|
+
};
|
|
156197
|
+
})() : void 0;
|
|
155731
156198
|
const headroom = safeHeadroom({
|
|
155732
156199
|
graph,
|
|
155733
156200
|
board,
|
|
@@ -156050,6 +156517,11 @@ function registerTurnTools(server, ctx, opts = {}) {
|
|
|
156050
156517
|
...plan.incomeTrend ? {
|
|
156051
156518
|
incomeTrend: rung === "full" ? plan.incomeTrend : `${plan.incomeTrend.turns.map((t) => t.income).join(" \u2192 ")} over turns ${plan.incomeTrend.turns[0].turn}\u2013${plan.incomeTrend.turns[plan.incomeTrend.turns.length - 1].turn}: ${plan.incomeTrend.slope >= 0 ? "+" : ""}${plan.incomeTrend.slope}/turn${plan.incomeTrend.flat ? ", flat" : ""}`
|
|
156052
156519
|
} : {},
|
|
156520
|
+
// #606: the mechanics for the calling model's own choice (opt-in).
|
|
156521
|
+
...strategyView ? { strategy: strategyView } : {},
|
|
156522
|
+
...factsView ? { facts: factsView } : {},
|
|
156523
|
+
// #606: every plan says what more can be asked for (the menu itself names the facts).
|
|
156524
|
+
...strategyView ? {} : { more: MORE_ON_REQUEST },
|
|
156053
156525
|
// #275 (a): each border's headroom, the weakest first (compact: the first few).
|
|
156054
156526
|
headroom: headroomView(headroom, map2, myIncome, rung === "full", !teamsKnown, (p) => estimates.find((e) => e.playerId === p)?.estimate),
|
|
156055
156527
|
...rung !== "full" && headroom.length > HEADROOM_COMPACT ? { headroomMore: headroom.length - HEADROOM_COMPACT } : {},
|
|
@@ -156680,6 +157152,17 @@ function registerTurnTools(server, ctx, opts = {}) {
|
|
|
156680
157152
|
);
|
|
156681
157153
|
const hopeless = hopelessAttackWarning(attacks, label2);
|
|
156682
157154
|
if (hopeless) warnings.push(hopeless);
|
|
157155
|
+
const bait = baitAttackWarning({
|
|
157156
|
+
graph: graphOf(map2),
|
|
157157
|
+
board: territories,
|
|
157158
|
+
me: playerId,
|
|
157159
|
+
moves: moves.map((m, i2) => ({ ...m, armies: m.percent ? options.estimates.get(i2) ?? 0 : m.armies })),
|
|
157160
|
+
settings: plannerSettings(game.settings),
|
|
157161
|
+
label: label2,
|
|
157162
|
+
name: (id) => ({ id, name: map2.territories.find((t) => t.id === id)?.name ?? String(id) }),
|
|
157163
|
+
teammates
|
|
157164
|
+
});
|
|
157165
|
+
if (bait) warnings.push(bait);
|
|
156683
157166
|
const subTeams = teamsOf(game.players);
|
|
156684
157167
|
const givenDeploys = deploys.map((d) => ({ territoryId: d.territory.id, armies: d.armies }));
|
|
156685
157168
|
const givenMoves = moves.map((m, i2) => ({
|
|
@@ -160321,7 +160804,7 @@ function registerCheckPlanTool(server, ctx) {
|
|
|
160321
160804
|
{
|
|
160322
160805
|
title: "Stress-test a planned turn in a war.app game",
|
|
160323
160806
|
description: untrustedDescription(
|
|
160324
|
-
`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.`
|
|
160807
|
+
`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.`
|
|
160325
160808
|
),
|
|
160326
160809
|
_meta: lookupMeta(["check my plan", "stress test my orders", "what can my opponent do to this turn", "is this plan safe"]),
|
|
160327
160810
|
annotations: readAnnotations("Stress-test a war.app turn"),
|
|
@@ -160599,7 +161082,7 @@ function registerCheckPlanTool(server, ctx) {
|
|
|
160599
161082
|
const some = (ids2) => `${ids2.slice(0, LIST_MAX2).join(", ")}${ids2.length > LIST_MAX2 ? ` and ${ids2.length - LIST_MAX2} more` : ""}`;
|
|
160600
161083
|
const capped2 = (ids2) => ids2.slice(0, LIST_MAX2).map(name);
|
|
160601
161084
|
const sentence = (r) => {
|
|
160602
|
-
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}`;
|
|
161085
|
+
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}`;
|
|
160603
161086
|
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` : "");
|
|
160604
161087
|
const cost = r.commanderLost ? ["you lose your commander and the game"] : [
|
|
160605
161088
|
...r.lost.length ? [`you lose territor${r.lost.length === 1 ? "y" : "ies"} ${some(r.lost)}`] : [],
|
|
@@ -160617,6 +161100,8 @@ function registerCheckPlanTool(server, ctx) {
|
|
|
160617
161100
|
deploy: r.deploy,
|
|
160618
161101
|
deployTo: name(r.deployTo),
|
|
160619
161102
|
...r.kind === "attack" || r.kind === "dodge" || r.kind === "chain" ? { attack: { from: name(r.from), to: name(r.to), armies: r.armies } } : {},
|
|
161103
|
+
// #593 5c: the stacks a gather moved into the target, and what arrived from each.
|
|
161104
|
+
...r.movedIn ? { movedIn: r.movedIn.map((m) => ({ from: name(m.from), armies: m.armies })) } : {},
|
|
160620
161105
|
// #180: a chain's every territory, and a joint strike's second opponent.
|
|
160621
161106
|
...r.path ? { path: r.path.map(name) } : {},
|
|
160622
161107
|
...r.partner !== void 0 ? {
|
|
@@ -160738,13 +161223,13 @@ function registerCheckPlanTool(server, ctx) {
|
|
|
160738
161223
|
const belowPlan = await bordersBelowPlan(ctx, { game, map: map2, me, turn, territories, info, history, teamsKnown, given: { deploys, moves } });
|
|
160739
161224
|
const avoidT = new Set((intel.avoidTerritories ?? []).map((t) => resolveTerritory(map2, t).id));
|
|
160740
161225
|
const avoidP = new Set(intel.avoidPlayers ?? []);
|
|
160741
|
-
const
|
|
161226
|
+
const ownerOf11 = (id) => {
|
|
160742
161227
|
const o = board.territories.find((t) => t.territoryId === id)?.owner;
|
|
160743
161228
|
return o?.kind === "player" ? o.playerId : void 0;
|
|
160744
161229
|
};
|
|
160745
|
-
const allyHits = modRead ? attacksOnAllies(modRead, moves,
|
|
161230
|
+
const allyHits = modRead ? attacksOnAllies(modRead, moves, ownerOf11) : [];
|
|
160746
161231
|
const avoidedHits = [...new Set(moves.map((m) => m.to))].filter(
|
|
160747
|
-
(to) => !mine3.has(to) && (avoidT.has(to) || avoidP.has(
|
|
161232
|
+
(to) => !mine3.has(to) && (avoidT.has(to) || avoidP.has(ownerOf11(to) ?? Number.NaN))
|
|
160748
161233
|
);
|
|
160749
161234
|
const capOver = territoryCapOverruns(binding, {
|
|
160750
161235
|
mine: mine3,
|
|
@@ -166610,13 +167095,13 @@ function registerCalibrationTool(server, dataDir2) {
|
|
|
166610
167095
|
// src/tools/turn-history.ts
|
|
166611
167096
|
var MAX_HISTORY_TURNS = 20;
|
|
166612
167097
|
var DEFAULT_HISTORY_TURNS = 5;
|
|
166613
|
-
var
|
|
167098
|
+
var ownerOf10 = (t) => t.owner.kind === "player" ? t.owner.playerId : t.owner.kind === "neutral" ? "neutral" : null;
|
|
166614
167099
|
function boardSummary(board, me) {
|
|
166615
167100
|
const players = /* @__PURE__ */ new Map();
|
|
166616
167101
|
let neutral = 0;
|
|
166617
167102
|
let hidden = 0;
|
|
166618
167103
|
for (const t of board.territories) {
|
|
166619
|
-
const o =
|
|
167104
|
+
const o = ownerOf10(t);
|
|
166620
167105
|
if (o === null) hidden++;
|
|
166621
167106
|
else if (o === "neutral") neutral++;
|
|
166622
167107
|
else {
|
|
@@ -166637,10 +167122,10 @@ function boardSummary(board, me) {
|
|
|
166637
167122
|
};
|
|
166638
167123
|
}
|
|
166639
167124
|
function ownerChanges(before, after) {
|
|
166640
|
-
const was = new Map(before.territories.map((t) => [t.territoryId,
|
|
167125
|
+
const was = new Map(before.territories.map((t) => [t.territoryId, ownerOf10(t)]));
|
|
166641
167126
|
const out = [];
|
|
166642
167127
|
for (const t of after.territories) {
|
|
166643
|
-
const now =
|
|
167128
|
+
const now = ownerOf10(t);
|
|
166644
167129
|
const prev = was.get(t.territoryId);
|
|
166645
167130
|
if (prev === void 0 || prev === null || now === null || prev === now) continue;
|
|
166646
167131
|
out.push([t.territoryId, prev, now]);
|
|
@@ -166668,7 +167153,7 @@ function seenByPlayer(orders) {
|
|
|
166668
167153
|
}
|
|
166669
167154
|
return out;
|
|
166670
167155
|
}
|
|
166671
|
-
var boardRows = (b) => [...b.territories].sort((x, y) => x.territoryId - y.territoryId).map((t) => [t.territoryId,
|
|
167156
|
+
var boardRows = (b) => [...b.territories].sort((x, y) => x.territoryId - y.territoryId).map((t) => [t.territoryId, ownerOf10(t), t.armies]);
|
|
166672
167157
|
function historyTurn(log, turn, opts = {}) {
|
|
166673
167158
|
const e = log.turns[String(turn)] ?? {};
|
|
166674
167159
|
const me = log.playerId;
|