@chrischall/warapp-mcp 0.20.0 → 0.21.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 +1 -1
- package/dist/analysis/options.js +157 -0
- package/dist/analysis/situation.js +243 -0
- package/dist/bundle.js +481 -82
- package/dist/tools/turn.js +102 -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;
|
|
@@ -103186,7 +103186,7 @@ function enemyDeployReaching(estimate, free, pools, on2, perTerritory) {
|
|
|
103186
103186
|
const anywhere = perTerritory ? Math.max(Math.min(estimate, free), estimate - pooled) : free;
|
|
103187
103187
|
return Math.min(estimate, anywhere + here);
|
|
103188
103188
|
}
|
|
103189
|
-
function couldHoldBonusPools(g, players,
|
|
103189
|
+
function couldHoldBonusPools(g, players, ownerOf11) {
|
|
103190
103190
|
const out = /* @__PURE__ */ new Map();
|
|
103191
103191
|
for (const p of players) out.set(p, []);
|
|
103192
103192
|
for (const b of [...g.map.bonuses].sort((x, y) => x.id - y.id)) {
|
|
@@ -103196,7 +103196,7 @@ function couldHoldBonusPools(g, players, ownerOf9) {
|
|
|
103196
103196
|
const members2 = new Set(ts);
|
|
103197
103197
|
for (const p of players)
|
|
103198
103198
|
if (ts.every((t) => {
|
|
103199
|
-
const o =
|
|
103199
|
+
const o = ownerOf11(t);
|
|
103200
103200
|
return o === void 0 || o === p;
|
|
103201
103201
|
}))
|
|
103202
103202
|
out.get(p).push({ bonusId: b.id, value: b.value, members: members2 });
|
|
@@ -106079,7 +106079,7 @@ function visibleOpponents(pc, input2) {
|
|
|
106079
106079
|
if (st.owner.kind !== "player" || !foe(st.owner.playerId) || st.armies === null) continue;
|
|
106080
106080
|
ownedBy3.set(st.owner.playerId, [...ownedBy3.get(st.owner.playerId) ?? [], id]);
|
|
106081
106081
|
}
|
|
106082
|
-
const
|
|
106082
|
+
const ownerOf11 = (id) => {
|
|
106083
106083
|
const o = state.get(id)?.owner;
|
|
106084
106084
|
return o?.kind === "player" ? o.playerId : void 0;
|
|
106085
106085
|
};
|
|
@@ -106104,7 +106104,7 @@ function visibleOpponents(pc, input2) {
|
|
|
106104
106104
|
const p = previousOwner.get(id);
|
|
106105
106105
|
return p !== void 0 && p !== me && weak.has(p) ? p : void 0;
|
|
106106
106106
|
};
|
|
106107
|
-
return { ownedBy: ownedBy3, ownerOf:
|
|
106107
|
+
return { ownedBy: ownedBy3, ownerOf: ownerOf11, hidden, fogAnywhere, fogEdge, inReach, weak, previousOwner, recentlyTakenFrom };
|
|
106108
106108
|
}
|
|
106109
106109
|
|
|
106110
106110
|
// src/analysis/plan/targets.ts
|
|
@@ -106923,23 +106923,23 @@ function deadAdvanceOf(pc, t, held, conceded, carried, completable2 = () => fals
|
|
|
106923
106923
|
return dead;
|
|
106924
106924
|
}
|
|
106925
106925
|
function breaksForAttacker(pc, t, ts, now) {
|
|
106926
|
-
const
|
|
106926
|
+
const ownerOf11 = (x) => {
|
|
106927
106927
|
const o = pc.territories.get(x)?.owner;
|
|
106928
106928
|
return o?.kind === "player" ? o.playerId : null;
|
|
106929
106929
|
};
|
|
106930
106930
|
const attackers = /* @__PURE__ */ new Set();
|
|
106931
106931
|
for (const m of now)
|
|
106932
106932
|
for (const n of pc.g.neighbors.get(m) ?? []) {
|
|
106933
|
-
const p =
|
|
106933
|
+
const p = ownerOf11(n);
|
|
106934
106934
|
const st = pc.territories.get(n);
|
|
106935
106935
|
if (p !== null && pc.foe(p) && (st?.armies ?? 0) > 0) attackers.add(p);
|
|
106936
106936
|
}
|
|
106937
106937
|
if (!attackers.size) return false;
|
|
106938
|
-
const owner =
|
|
106938
|
+
const owner = ownerOf11(t);
|
|
106939
106939
|
if (owner !== null) return attackers.has(owner);
|
|
106940
106940
|
if (pc.territories.get(t)?.owner.kind !== "neutral") return false;
|
|
106941
106941
|
const conceded = new Set(now);
|
|
106942
|
-
return [...attackers].some((a) => ts.every((x) => x === t || conceded.has(x) ||
|
|
106942
|
+
return [...attackers].some((a) => ts.every((x) => x === t || conceded.has(x) || ownerOf11(x) === a));
|
|
106943
106943
|
}
|
|
106944
106944
|
function deadAdvanceLine(pc, t, d) {
|
|
106945
106945
|
const members2 = d.members.map(pc.label).join(", ");
|
|
@@ -107897,13 +107897,13 @@ function guardOffExposure(args) {
|
|
|
107897
107897
|
const { graph, board, me } = args;
|
|
107898
107898
|
const friends = args.friends ?? /* @__PURE__ */ new Set();
|
|
107899
107899
|
const byId2 = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
107900
|
-
const
|
|
107900
|
+
const ownerOf11 = (id) => {
|
|
107901
107901
|
const o = byId2.get(id)?.owner;
|
|
107902
107902
|
return o?.kind === "player" ? o.playerId : void 0;
|
|
107903
107903
|
};
|
|
107904
|
-
const isMine3 = (id) =>
|
|
107904
|
+
const isMine3 = (id) => ownerOf11(id) === me;
|
|
107905
107905
|
const isEnemy = (id) => {
|
|
107906
|
-
const p =
|
|
107906
|
+
const p = ownerOf11(id);
|
|
107907
107907
|
return p !== void 0 && p !== me && !friends.has(p);
|
|
107908
107908
|
};
|
|
107909
107909
|
const hidden = (id) => {
|
|
@@ -107923,11 +107923,11 @@ function guardOffExposure(args) {
|
|
|
107923
107923
|
const breaks = [];
|
|
107924
107924
|
for (const t of [...board.territories].sort((a, b) => a.territoryId - b.territoryId)) {
|
|
107925
107925
|
const id = t.territoryId;
|
|
107926
|
-
const owner =
|
|
107926
|
+
const owner = ownerOf11(id);
|
|
107927
107927
|
if (owner === void 0 || !isEnemy(id) || t.armies !== 0 || t.specialUnits?.length || attacked.has(id)) continue;
|
|
107928
107928
|
const from = neighborsOf(graph, id).filter(isMine3).sort((a, b) => a - b)[0];
|
|
107929
107929
|
if (from === void 0) continue;
|
|
107930
|
-
const held = [...graph.bonusById.values()].filter((b) => b.value > 0 && b.territoryIds.includes(id) && b.territoryIds.every((x) =>
|
|
107930
|
+
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
107931
|
if (held) breaks.push({ territoryId: id, from, playerId: owner, bonusId: held.id, value: held.value });
|
|
107932
107932
|
}
|
|
107933
107933
|
return { emptied, breaks };
|
|
@@ -108407,7 +108407,7 @@ function finishOffHelper(pc, ps, book, threats, hd, tgt, cap) {
|
|
|
108407
108407
|
staged
|
|
108408
108408
|
} = ps;
|
|
108409
108409
|
const { guardAt, deploy, roomAt, valueOf, stakeAt } = book;
|
|
108410
|
-
const { ownedBy: ownedBy3, ownerOf:
|
|
108410
|
+
const { ownedBy: ownedBy3, ownerOf: ownerOf11, fogAnywhere, deployReaching, holdArmies, bombSized, borderAt } = threats;
|
|
108411
108411
|
const { stayAt } = hd;
|
|
108412
108412
|
const { targets, frontierDelta, repulsed } = tgt;
|
|
108413
108413
|
const { notCompleted, worstCase, finishedOff, tryCapture } = cap;
|
|
@@ -108488,7 +108488,7 @@ function finishOffHelper(pc, ps, book, threats, hd, tgt, cap) {
|
|
|
108488
108488
|
return cost > CONCEDE_FACTOR * worth && !myCommanders.has(x) ? null : { need: need2, cost, worth };
|
|
108489
108489
|
};
|
|
108490
108490
|
for (const x of mine3) {
|
|
108491
|
-
const h = holdCostAt(x, (n) =>
|
|
108491
|
+
const h = holdCostAt(x, (n) => ownerOf11(n) === p && !stay2.has(n));
|
|
108492
108492
|
if (!h) continue;
|
|
108493
108493
|
const { need: need2, cost, worth } = h;
|
|
108494
108494
|
if (sources.has(x)) {
|
|
@@ -108693,7 +108693,7 @@ function finishOffHelper(pc, ps, book, threats, hd, tgt, cap) {
|
|
|
108693
108693
|
if (chosen.all && !pressure && profile.format === "ffa" && profile.opponents >= 2) {
|
|
108694
108694
|
const next = [...new Set(ts.flatMap((t) => neighborsOf(g, t)))].sort(byNum2);
|
|
108695
108695
|
const exposed = next.filter((n) => {
|
|
108696
|
-
const o =
|
|
108696
|
+
const o = ownerOf11(n);
|
|
108697
108697
|
return o !== void 0 && o !== p && foe(o) && !neighborsOf(g, n).some((x) => mineSet.has(x));
|
|
108698
108698
|
});
|
|
108699
108699
|
if (exposed.length) {
|
|
@@ -108701,8 +108701,8 @@ function finishOffHelper(pc, ps, book, threats, hd, tgt, cap) {
|
|
|
108701
108701
|
const delta = frontierDelta(mineSet, ts, (x) => mineSet.has(x) ? stayAt(x) : survivorsAt.get(x) ?? 0).armies;
|
|
108702
108702
|
const gain = Math.max(0, incomeGain(after));
|
|
108703
108703
|
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) =>
|
|
108704
|
+
const who2 = [...new Set(exposed.map((n) => ownerOf11(n)))].sort(byNum2);
|
|
108705
|
+
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
108706
|
const shown2 = Math.round(delta);
|
|
108707
108707
|
const cost = `the frontier's hold cost changes by ${shown2 >= 0 ? "+" : ""}${shown2} armies (its own threat gone)`;
|
|
108708
108708
|
if (delta > limit) {
|
|
@@ -108804,7 +108804,7 @@ function commanderStrikes(pc, ps, book, threats, hd, tgt, cap) {
|
|
|
108804
108804
|
} = pc;
|
|
108805
108805
|
const { warnings, rationale, deployed, avail, captured } = ps;
|
|
108806
108806
|
const { orderOf, describeOrder, local, roomAt, spareAt } = book;
|
|
108807
|
-
const { ownedBy: ownedBy3, ownerOf:
|
|
108807
|
+
const { ownedBy: ownedBy3, ownerOf: ownerOf11, deployReaching, holdArmies, borderAt } = threats;
|
|
108808
108808
|
const { stayAt, keepFor } = hd;
|
|
108809
108809
|
const { targets } = tgt;
|
|
108810
108810
|
const { mustHold, strikes, worstCase, tryCapture } = cap;
|
|
@@ -108864,7 +108864,7 @@ function commanderStrikes(pc, ps, book, threats, hd, tgt, cap) {
|
|
|
108864
108864
|
const by = /* @__PURE__ */ new Map();
|
|
108865
108865
|
for (const x of land)
|
|
108866
108866
|
for (const n of neighborsOf(g, x)) {
|
|
108867
|
-
const o =
|
|
108867
|
+
const o = ownerOf11(n);
|
|
108868
108868
|
if (o === void 0 || o === p || !foe(o)) continue;
|
|
108869
108869
|
if (!(by.get(o) ?? []).includes(x)) by.set(o, [...by.get(o) ?? [], x]);
|
|
108870
108870
|
}
|
|
@@ -109207,7 +109207,7 @@ function fundFromSecondSizing(pc, ps, book, threats, hd, caps) {
|
|
|
109207
109207
|
}
|
|
109208
109208
|
const spare = /* @__PURE__ */ new Map();
|
|
109209
109209
|
const keepOf = /* @__PURE__ */ new Map();
|
|
109210
|
-
const
|
|
109210
|
+
const ownerOf11 = (m) => state.get(m.to).owner.playerId;
|
|
109211
109211
|
const deployLeft = /* @__PURE__ */ new Map();
|
|
109212
109212
|
for (const [owner, list3] of [...byOwner].sort((a, b) => a[0] - b[0])) {
|
|
109213
109213
|
if (list3.length < 2) continue;
|
|
@@ -109274,7 +109274,7 @@ function fundFromSecondSizing(pc, ps, book, threats, hd, caps) {
|
|
|
109274
109274
|
const from = takes.map(
|
|
109275
109275
|
({ 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
109276
|
).join(" and ");
|
|
109277
|
-
const kept = [...new Map(takes.map(({ m }) => [
|
|
109277
|
+
const kept = [...new Map(takes.map(({ m }) => [ownerOf11(m), m])).keys()].sort((a, b) => a - b).map((o) => {
|
|
109278
109278
|
const keep = keepOf.get(o);
|
|
109279
109279
|
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
109280
|
}).join("; ");
|
|
@@ -110897,11 +110897,11 @@ function spendUnderCap(pc, ps, book, threats, hd, tgt, caps) {
|
|
|
110897
110897
|
ps.capRefused.set(t, why);
|
|
110898
110898
|
};
|
|
110899
110899
|
const taken = [];
|
|
110900
|
-
const
|
|
110900
|
+
const ownerOf11 = (t) => {
|
|
110901
110901
|
const o = state.get(t)?.owner;
|
|
110902
110902
|
return o?.kind === "player" ? o.playerId : void 0;
|
|
110903
110903
|
};
|
|
110904
|
-
const lostBy = (p) => [...captured].filter((x) =>
|
|
110904
|
+
const lostBy = (p) => [...captured].filter((x) => ownerOf11(x) === p).sort(byNum2);
|
|
110905
110905
|
const tryOne = (t, i2, list3, fork) => {
|
|
110906
110906
|
const now = nextCap();
|
|
110907
110907
|
if (now.eaten <= 0) return "stop";
|
|
@@ -110943,7 +110943,7 @@ function spendUnderCap(pc, ps, book, threats, hd, tgt, caps) {
|
|
|
110943
110943
|
const exposed = kit.exposure(t);
|
|
110944
110944
|
taken.push(t);
|
|
110945
110945
|
const paid = before - ps.budget;
|
|
110946
|
-
const p =
|
|
110946
|
+
const p = ownerOf11(t);
|
|
110947
110947
|
const lost = p === void 0 ? [] : lostBy(p);
|
|
110948
110948
|
const forkText = () => {
|
|
110949
110949
|
const est = Math.max(0, ...lost.map((x) => threats.reinforcementAt(x)));
|
|
@@ -110987,9 +110987,9 @@ function spendUnderCap(pc, ps, book, threats, hd, tgt, caps) {
|
|
|
110987
110987
|
forks.push(t);
|
|
110988
110988
|
}
|
|
110989
110989
|
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(
|
|
110990
|
+
const open5 = forks.filter((t) => lostBy(ownerOf11(t)).length > 0);
|
|
110991
110991
|
for (const [i2, t] of open5.entries()) {
|
|
110992
|
-
if (!lostBy(
|
|
110992
|
+
if (!lostBy(ownerOf11(t)).length) continue;
|
|
110993
110993
|
if (tryOne(t, i2, open5, true) === "stop") break;
|
|
110994
110994
|
}
|
|
110995
110995
|
} finally {
|
|
@@ -111090,7 +111090,7 @@ function transfers(pc, ps, book, threats, hd, caps, staging) {
|
|
|
111090
111090
|
const { g, me, s, foe, territories: state, label: label3, bonusName, mine: mine3, mineSet, unitsAt, toTake, noSplit, myCommanders } = pc;
|
|
111091
111091
|
const { warnings, rationale, avail, locked, coverKeep, centralKeep, captured, moves } = ps;
|
|
111092
111092
|
const { guardAt, coverOf, orderOf, warnSplit } = book;
|
|
111093
|
-
const { holdArmies, borderAt, ownerOf:
|
|
111093
|
+
const { holdArmies, borderAt, ownerOf: ownerOf11, borders } = threats;
|
|
111094
111094
|
const { arrived, conceded, threatened: threatened2, stayAt, twoStepCite, twoStepHold, twoStepKeep } = hd;
|
|
111095
111095
|
const { strikes, worstCase } = caps;
|
|
111096
111096
|
const transfer = (from, to, armies, reason) => {
|
|
@@ -111228,7 +111228,7 @@ function transfers(pc, ps, book, threats, hd, caps, staging) {
|
|
|
111228
111228
|
rationale.push(breachLine(pc, t, n, land));
|
|
111229
111229
|
continue;
|
|
111230
111230
|
}
|
|
111231
|
-
if (myCommanders.has(t) && neighborsOf(g, t).some((x) => (
|
|
111231
|
+
if (myCommanders.has(t) && neighborsOf(g, t).some((x) => (ownerOf11(x) ?? me) !== me || conceded.has(x)))
|
|
111232
111232
|
continue;
|
|
111233
111233
|
const d = dist.get(t);
|
|
111234
111234
|
if (d === void 0 || d <= 1) continue;
|
|
@@ -112023,7 +112023,7 @@ function finishPlan(pc, ps, pass, threats, hd, tgt, expected, sentAt, slotOf, fa
|
|
|
112023
112023
|
toTake
|
|
112024
112024
|
} = pc;
|
|
112025
112025
|
const { warnings, rationale, deployed, captured, combined, moves } = ps;
|
|
112026
|
-
const { reinforcementAt, borders, ownedBy: ownedBy3, ownerOf:
|
|
112026
|
+
const { reinforcementAt, borders, ownedBy: ownedBy3, ownerOf: ownerOf11, fogEdge } = threats;
|
|
112027
112027
|
const { conceded, stayAt } = hd;
|
|
112028
112028
|
const { offence, offenceSkip } = tgt;
|
|
112029
112029
|
const { completed, nextIncome, atRisk, ifFall, reportRisk, frontier, gates } = expected;
|
|
@@ -112055,7 +112055,7 @@ function finishPlan(pc, ps, pass, threats, hd, tgt, expected, sentAt, slotOf, fa
|
|
|
112055
112055
|
if (!foe(p)) continue;
|
|
112056
112056
|
const broken = g.map.bonuses.filter((b) => b.value > 0).filter((b) => {
|
|
112057
112057
|
const members2 = bonusTerritories(g, b.id);
|
|
112058
|
-
return members2.length > 0 && members2.every((t) =>
|
|
112058
|
+
return members2.length > 0 && members2.every((t) => ownerOf11(t) === p) && members2.some((t) => captured.has(t));
|
|
112059
112059
|
}).sort((a, b) => a.id - b.id);
|
|
112060
112060
|
if (!broken.length) continue;
|
|
112061
112061
|
const left = ts.filter((t) => !captured.has(t));
|
|
@@ -116117,7 +116117,7 @@ function serverBuild() {
|
|
|
116117
116117
|
}
|
|
116118
116118
|
|
|
116119
116119
|
// src/version.ts
|
|
116120
|
-
var VERSION2 = "0.
|
|
116120
|
+
var VERSION2 = "0.21.0";
|
|
116121
116121
|
|
|
116122
116122
|
// src/decision-log.ts
|
|
116123
116123
|
var DECISION_LOG_VERSION = 1;
|
|
@@ -119256,11 +119256,11 @@ function reader(cb) {
|
|
|
119256
119256
|
...cb.settings?.offensiveKillRate !== void 0 ? { offensiveKillRate: cb.settings.offensiveKillRate } : {},
|
|
119257
119257
|
...cb.settings?.defensiveKillRate !== void 0 ? { defensiveKillRate: cb.settings.defensiveKillRate } : {}
|
|
119258
119258
|
};
|
|
119259
|
-
const
|
|
119259
|
+
const ownerOf11 = (t) => {
|
|
119260
119260
|
const o = state.get(t)?.owner;
|
|
119261
119261
|
return o?.kind === "player" ? o.playerId : void 0;
|
|
119262
119262
|
};
|
|
119263
|
-
const isMine3 = (t) =>
|
|
119263
|
+
const isMine3 = (t) => ownerOf11(t) === cb.me;
|
|
119264
119264
|
const foe = (p) => p !== void 0 && p !== cb.me && !cb.friends?.has(p);
|
|
119265
119265
|
const armiesOf3 = (t) => state.get(t)?.armies ?? 0;
|
|
119266
119266
|
const commanderOf = (t, who2) => (state.get(t)?.specialUnits ?? []).some((u) => u.kind === "commander" && who2(u.playerId));
|
|
@@ -119274,7 +119274,7 @@ function reader(cb) {
|
|
|
119274
119274
|
const reachOf = (t, bombed) => {
|
|
119275
119275
|
const by = /* @__PURE__ */ new Map();
|
|
119276
119276
|
for (const n of neighborsOf(cb.graph, t)) {
|
|
119277
|
-
const p =
|
|
119277
|
+
const p = ownerOf11(n);
|
|
119278
119278
|
if (!foe(p) || state.get(n)?.armies === null) continue;
|
|
119279
119279
|
const e = by.get(p) ?? { others: 0, hasOther: false };
|
|
119280
119280
|
if (n === bombed) e.bombed = armiesOf3(n);
|
|
@@ -119295,7 +119295,7 @@ function reader(cb) {
|
|
|
119295
119295
|
const reachByPlayer = (t) => {
|
|
119296
119296
|
const by = /* @__PURE__ */ new Map();
|
|
119297
119297
|
for (const n of neighborsOf(cb.graph, t)) {
|
|
119298
|
-
const p =
|
|
119298
|
+
const p = ownerOf11(n);
|
|
119299
119299
|
if (!foe(p) || state.get(n)?.armies === null) continue;
|
|
119300
119300
|
by.set(p, (by.get(p) ?? cb.enemyDeploy) + Math.max(0, armiesOf3(n) - guard));
|
|
119301
119301
|
}
|
|
@@ -119307,7 +119307,7 @@ function reader(cb) {
|
|
|
119307
119307
|
while (toTake(h + extra) <= reach) h++;
|
|
119308
119308
|
return h;
|
|
119309
119309
|
};
|
|
119310
|
-
return { state, guard, rates, ownerOf:
|
|
119310
|
+
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
119311
|
}
|
|
119312
119312
|
var KIND_RANK = { commander: 0, hold: 1, capture: 2 };
|
|
119313
119313
|
function bombAdvice(cb) {
|
|
@@ -141968,16 +141968,16 @@ function borderGuess(input2) {
|
|
|
141968
141968
|
const allies = alliesOf(me, input2.players);
|
|
141969
141969
|
const state = /* @__PURE__ */ new Map();
|
|
141970
141970
|
for (const t of board.territories) if (g.territoryById.has(t.territoryId)) state.set(t.territoryId, t);
|
|
141971
|
-
const
|
|
141971
|
+
const ownerOf11 = (id) => {
|
|
141972
141972
|
const t = state.get(id);
|
|
141973
141973
|
return t?.owner.kind === "player" ? t.owner.playerId : null;
|
|
141974
141974
|
};
|
|
141975
141975
|
const foe = (p) => p !== null && p !== me && !allies.has(p);
|
|
141976
|
-
const foeStack = (id) => foe(
|
|
141977
|
-
const mine3 = [...state.values()].filter((t) =>
|
|
141976
|
+
const foeStack = (id) => foe(ownerOf11(id)) && state.get(id).armies !== null;
|
|
141977
|
+
const mine3 = [...state.values()].filter((t) => ownerOf11(t.territoryId) === me).map((t) => t.territoryId).sort(byNum13);
|
|
141978
141978
|
const mineSet = new Set(mine3);
|
|
141979
141979
|
const opponents = /* @__PURE__ */ new Set();
|
|
141980
|
-
for (const t of mine3) for (const n of neighborsOf(g, t)) if (foeStack(n)) opponents.add(
|
|
141980
|
+
for (const t of mine3) for (const n of neighborsOf(g, t)) if (foeStack(n)) opponents.add(ownerOf11(n));
|
|
141981
141981
|
if (opponents.size === 0) return skip("no-contact", "No opponent stack is in sight next to my territories.");
|
|
141982
141982
|
if (opponents.size > 1)
|
|
141983
141983
|
return skip("several-opponents", `${opponents.size} opponents touch my borders: the guess models one opponent with one deploy.`);
|
|
@@ -141985,7 +141985,7 @@ function borderGuess(input2) {
|
|
|
141985
141985
|
if (input2.enemyDeploy === void 0 && input2.untrusted?.includes(opp))
|
|
141986
141986
|
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
141987
|
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) &&
|
|
141988
|
+
const ids2 = mine3.filter((t) => neighborsOf(g, t).some((n) => foeStack(n) && ownerOf11(n) === opp));
|
|
141989
141989
|
if (ids2.length < 2) return skip("one-border", "The opponent touches only one of my territories: there is nothing to guess between.");
|
|
141990
141990
|
if (ids2.length > MAX_GUESS_BORDERS)
|
|
141991
141991
|
return skip("too-many-borders", `The opponent touches ${ids2.length} of my territories (at most ${MAX_GUESS_BORDERS} are modelled).`);
|
|
@@ -142012,7 +142012,7 @@ function borderGuess(input2) {
|
|
|
142012
142012
|
const armies = t.armies ?? 0;
|
|
142013
142013
|
const myUnits = (t.specialUnits ?? []).filter((u) => u.playerId === me);
|
|
142014
142014
|
const strength = specialUnitStrength(myUnits);
|
|
142015
|
-
const stack = neighborsOf(g, id).filter((n) => foeStack(n) &&
|
|
142015
|
+
const stack = neighborsOf(g, id).filter((n) => foeStack(n) && ownerOf11(n) === opp).reduce((a, n) => {
|
|
142016
142016
|
const nt = state.get(n);
|
|
142017
142017
|
const units = (nt.specialUnits ?? []).filter((u) => u.playerId === opp);
|
|
142018
142018
|
return a + Math.max(0, (nt.armies ?? 0) - guard) + specialUnitStrength(units);
|
|
@@ -145754,7 +145754,7 @@ function storeBoards(boards, ids2, key) {
|
|
|
145754
145754
|
const known2 = new Set(ids2);
|
|
145755
145755
|
const index = /* @__PURE__ */ new Map();
|
|
145756
145756
|
const owners = [];
|
|
145757
|
-
const
|
|
145757
|
+
const ownerOf11 = (o) => {
|
|
145758
145758
|
if (o.kind === "neutral") return OWNER_NEUTRAL2;
|
|
145759
145759
|
if (o.kind === "available") return OWNER_AVAILABLE;
|
|
145760
145760
|
if (o.kind !== "player" || !known2.has(o.playerId)) return OWNER_UNKNOWN;
|
|
@@ -145766,7 +145766,7 @@ function storeBoards(boards, ids2, key) {
|
|
|
145766
145766
|
return i2;
|
|
145767
145767
|
};
|
|
145768
145768
|
const rowOf = (x) => {
|
|
145769
|
-
const row2 = [x.territoryId,
|
|
145769
|
+
const row2 = [x.territoryId, ownerOf11(x.owner), x.armies];
|
|
145770
145770
|
return x.fogLevel && x.fogLevel !== "Visible" && FOG_WORD.test(x.fogLevel) ? [...row2, x.fogLevel] : row2;
|
|
145771
145771
|
};
|
|
145772
145772
|
let prev;
|
|
@@ -145808,7 +145808,7 @@ var hasBoards = (rec2) => rec2.status === "captured" && Array.isArray(rec2.board
|
|
|
145808
145808
|
function decodeHistory(rec2, byKey) {
|
|
145809
145809
|
const me = byKey.get(rec2.me);
|
|
145810
145810
|
const owners = rec2.boardOwners.map((k) => byKey.get(k));
|
|
145811
|
-
const
|
|
145811
|
+
const ownerOf11 = (o) => {
|
|
145812
145812
|
if (o === OWNER_NEUTRAL2) return { kind: "neutral" };
|
|
145813
145813
|
if (o === OWNER_AVAILABLE) return { kind: "available" };
|
|
145814
145814
|
const id = owners[o];
|
|
@@ -145822,7 +145822,7 @@ function decodeHistory(rec2, byKey) {
|
|
|
145822
145822
|
}
|
|
145823
145823
|
const territoryOf3 = ([territoryId, owner, armies, fogLevel]) => ({
|
|
145824
145824
|
territoryId,
|
|
145825
|
-
owner:
|
|
145825
|
+
owner: ownerOf11(owner),
|
|
145826
145826
|
armies,
|
|
145827
145827
|
...fogLevel !== void 0 ? { fogLevel } : {}
|
|
145828
145828
|
});
|
|
@@ -146176,7 +146176,7 @@ function checkMoveOptions(args) {
|
|
|
146176
146176
|
const { moves, board, myInGameId: me, teammates } = args;
|
|
146177
146177
|
const s = args.settings;
|
|
146178
146178
|
const standing = new Map(board.map((t) => [t.territoryId, t]));
|
|
146179
|
-
const
|
|
146179
|
+
const ownerOf11 = (id) => {
|
|
146180
146180
|
const t = standing.get(id);
|
|
146181
146181
|
return t && !t.fogged ? t.owner : void 0;
|
|
146182
146182
|
};
|
|
@@ -146200,7 +146200,7 @@ function checkMoveOptions(args) {
|
|
|
146200
146200
|
hint: "Send it without `mode`: an ordinary attack/transfer."
|
|
146201
146201
|
});
|
|
146202
146202
|
}
|
|
146203
|
-
const target =
|
|
146203
|
+
const target = ownerOf11(m.to.id);
|
|
146204
146204
|
const friendly = target === me || target !== void 0 && teammates.has(target) && !m.attackTeammates;
|
|
146205
146205
|
if (m.mode === "transfer-only" && !friendly) {
|
|
146206
146206
|
warnings.push(
|
|
@@ -148412,12 +148412,12 @@ function stagingCandidates(input2, plain, guardOn = true) {
|
|
|
148412
148412
|
const { graph, board, me } = input2;
|
|
148413
148413
|
const guard = guardOn ? 1 : 0;
|
|
148414
148414
|
const at2 = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
148415
|
-
const
|
|
148415
|
+
const ownerOf11 = (id) => {
|
|
148416
148416
|
const t = at2.get(id);
|
|
148417
148417
|
if (!t || t.armies === null) return void 0;
|
|
148418
148418
|
return t.owner.kind === "player" ? t.owner.playerId : t.owner.kind === "neutral" ? "neutral" : void 0;
|
|
148419
148419
|
};
|
|
148420
|
-
const isMine3 = (id) =>
|
|
148420
|
+
const isMine3 = (id) => ownerOf11(id) === me;
|
|
148421
148421
|
const armies = (id) => at2.get(id)?.armies ?? 0;
|
|
148422
148422
|
const commanderOn2 = (id) => at2.get(id)?.specialUnits?.some((u) => u.kind === "commander" && u.playerId === me) === true;
|
|
148423
148423
|
const conceded = new Set(plain.conceded);
|
|
@@ -148433,15 +148433,15 @@ function stagingCandidates(input2, plain, guardOn = true) {
|
|
|
148433
148433
|
if (b.value <= 0 || !b.territoryIds.includes(t)) continue;
|
|
148434
148434
|
const others = b.territoryIds.filter((x) => x !== t);
|
|
148435
148435
|
if (others.every(mineAfter)) gain += b.value;
|
|
148436
|
-
const owner =
|
|
148437
|
-
if (typeof owner === "number" && b.territoryIds.every((x) =>
|
|
148436
|
+
const owner = ownerOf11(t);
|
|
148437
|
+
if (typeof owner === "number" && b.territoryIds.every((x) => ownerOf11(x) === owner)) gain += b.value;
|
|
148438
148438
|
}
|
|
148439
148439
|
return gain;
|
|
148440
148440
|
};
|
|
148441
148441
|
const out = [];
|
|
148442
|
-
const targets = board.territories.map((t) => t.territoryId).filter((t) => !isMine3(t) &&
|
|
148442
|
+
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
148443
|
for (const { t, gain } of targets.slice(0, 3)) {
|
|
148444
|
-
const defenders2 = armies(t) + (typeof
|
|
148444
|
+
const defenders2 = armies(t) + (typeof ownerOf11(t) === "number" ? plain.enemyDeploy : 0);
|
|
148445
148445
|
const attack = armiesToTake(defenders2, {
|
|
148446
148446
|
...rates.offensiveKillRate !== void 0 ? { offensiveKillRate: rates.offensiveKillRate } : {},
|
|
148447
148447
|
...rates.defensiveKillRate !== void 0 ? { defensiveKillRate: rates.defensiveKillRate } : {}
|
|
@@ -148552,7 +148552,7 @@ function bombedBoard(board, target) {
|
|
|
148552
148552
|
function bombCandidates(input2) {
|
|
148553
148553
|
const { graph, board, me } = input2;
|
|
148554
148554
|
const at2 = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
148555
|
-
const
|
|
148555
|
+
const ownerOf11 = (id) => {
|
|
148556
148556
|
const t = at2.get(id);
|
|
148557
148557
|
return t?.owner.kind === "player" && t.armies !== null ? t.owner.playerId : void 0;
|
|
148558
148558
|
};
|
|
@@ -148563,13 +148563,13 @@ function bombCandidates(input2) {
|
|
|
148563
148563
|
);
|
|
148564
148564
|
const out = [];
|
|
148565
148565
|
for (const t of board.territories) {
|
|
148566
|
-
const owner =
|
|
148566
|
+
const owner = ownerOf11(t.territoryId);
|
|
148567
148567
|
if (owner === void 0 || friend(owner) || peace.has(owner)) continue;
|
|
148568
|
-
if (!neighborsOf(graph, t.territoryId).some((n) =>
|
|
148568
|
+
if (!neighborsOf(graph, t.territoryId).some((n) => ownerOf11(n) === me)) continue;
|
|
148569
148569
|
const armies = t.armies ?? 0;
|
|
148570
148570
|
if (armies < 2) continue;
|
|
148571
148571
|
const breaks = [...graph.bonusById.values()].some(
|
|
148572
|
-
(b) => b.value > 0 && b.territoryIds.includes(t.territoryId) && b.territoryIds.every((x) =>
|
|
148572
|
+
(b) => b.value > 0 && b.territoryIds.includes(t.territoryId) && b.territoryIds.every((x) => ownerOf11(x) === owner)
|
|
148573
148573
|
);
|
|
148574
148574
|
out.push({ target: t.territoryId, kind: breaks ? "break-bonus" : "cut-stack", armies, left: bombLeaves(armies) });
|
|
148575
148575
|
}
|
|
@@ -149163,6 +149163,324 @@ function planBlockade(a) {
|
|
|
149163
149163
|
return best ? { best, considered } : { considered };
|
|
149164
149164
|
}
|
|
149165
149165
|
|
|
149166
|
+
// src/analysis/options.ts
|
|
149167
|
+
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.";
|
|
149168
|
+
var MAX_OPTIONS = 15;
|
|
149169
|
+
var ownerOf8 = (t) => t?.owner.kind === "neutral" ? "neutral" : t?.owner.kind === "player" ? t.owner.playerId : null;
|
|
149170
|
+
function turnOptions(input2, limit = MAX_OPTIONS) {
|
|
149171
|
+
const { graph: g, board, me } = input2;
|
|
149172
|
+
const state = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
149173
|
+
const guard = input2.guard === false ? 0 : 1;
|
|
149174
|
+
const mine3 = new Set(board.territories.filter((t) => ownerOf8(t) === me).map((t) => t.territoryId));
|
|
149175
|
+
const foe = (o) => typeof o === "number" && o !== me && !input2.friends?.has(o);
|
|
149176
|
+
const armies = (t) => state.get(t)?.armies ?? 0;
|
|
149177
|
+
const take = (defenders2) => armiesToTake(defenders2, input2.rates);
|
|
149178
|
+
const bonusesOf3 = /* @__PURE__ */ new Map();
|
|
149179
|
+
for (const b of g.map.bonuses) for (const t of bonusTerritories(g, b.id)) bonusesOf3.set(t, [...bonusesOf3.get(t) ?? [], b.id]);
|
|
149180
|
+
const missing = (bonusId, held) => bonusTerritories(g, bonusId).filter((t) => !held.has(t)).length;
|
|
149181
|
+
const captures = [];
|
|
149182
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
149183
|
+
for (const m of [...mine3].sort((a, b) => a - b))
|
|
149184
|
+
for (const t of neighborsOf(g, m)) {
|
|
149185
|
+
if (mine3.has(t) || seen2.has(t)) continue;
|
|
149186
|
+
seen2.add(t);
|
|
149187
|
+
const st = state.get(t);
|
|
149188
|
+
const owner = ownerOf8(st);
|
|
149189
|
+
if (owner === null || st.armies === null) continue;
|
|
149190
|
+
if (typeof owner === "number" && input2.friends?.has(owner)) continue;
|
|
149191
|
+
const defenders2 = st.armies;
|
|
149192
|
+
const after = /* @__PURE__ */ new Set([...mine3, t]);
|
|
149193
|
+
const completes = [];
|
|
149194
|
+
const advances = [];
|
|
149195
|
+
for (const id of bonusesOf3.get(t) ?? []) {
|
|
149196
|
+
const b = g.bonusById.get(id);
|
|
149197
|
+
if (b.value <= 0) continue;
|
|
149198
|
+
const left = missing(id, after);
|
|
149199
|
+
if (left === 0) completes.push({ bonusId: id, value: b.value });
|
|
149200
|
+
else advances.push({ bonusId: id, value: b.value, missingAfter: left });
|
|
149201
|
+
}
|
|
149202
|
+
const opens = neighborsOf(g, t).filter(
|
|
149203
|
+
(n) => !mine3.has(n) && foe(ownerOf8(state.get(n))) && !neighborsOf(g, n).some((x) => mine3.has(x))
|
|
149204
|
+
).length;
|
|
149205
|
+
captures.push({
|
|
149206
|
+
target: t,
|
|
149207
|
+
owner,
|
|
149208
|
+
defenders: defenders2,
|
|
149209
|
+
needs: take(defenders2),
|
|
149210
|
+
...typeof owner === "number" ? { needsIfReinforced: take(defenders2 + Math.max(0, input2.deployOf(owner))) } : {},
|
|
149211
|
+
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),
|
|
149212
|
+
completes,
|
|
149213
|
+
advances: advances.sort((a, b) => a.missingAfter - b.missingAfter || b.value - a.value || a.bonusId - b.bonusId),
|
|
149214
|
+
incomeGain: completes.reduce((n, c) => n + c.value, 0),
|
|
149215
|
+
opensBorders: opens
|
|
149216
|
+
});
|
|
149217
|
+
}
|
|
149218
|
+
const nearest = (c) => c.advances.length ? c.advances[0].missingAfter : Infinity;
|
|
149219
|
+
const cost = (c) => c.needs ?? Infinity;
|
|
149220
|
+
captures.sort(
|
|
149221
|
+
(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
|
|
149222
|
+
);
|
|
149223
|
+
const holds = [];
|
|
149224
|
+
for (const t of [...mine3].sort((a, b) => a - b)) {
|
|
149225
|
+
const byPlayer = /* @__PURE__ */ new Map();
|
|
149226
|
+
for (const n of neighborsOf(g, t)) {
|
|
149227
|
+
const o = ownerOf8(state.get(n));
|
|
149228
|
+
if (!foe(o)) continue;
|
|
149229
|
+
byPlayer.set(o, (byPlayer.get(o) ?? 0) + Math.max(0, armies(n) - guard));
|
|
149230
|
+
}
|
|
149231
|
+
if (!byPlayer.size) continue;
|
|
149232
|
+
const have = armies(t);
|
|
149233
|
+
const facing = [...byPlayer].sort((a, b) => a[0] - b[0]).map(([player2, stacks2]) => ({ player: player2, stacks: stacks2, deploy: Math.max(0, input2.deployOf(player2)) }));
|
|
149234
|
+
const add = (attack) => {
|
|
149235
|
+
let n = 0;
|
|
149236
|
+
while ((take(have + n) ?? Infinity) <= attack) n++;
|
|
149237
|
+
return n;
|
|
149238
|
+
};
|
|
149239
|
+
const stacks = Math.max(...facing.map((f) => f.stacks));
|
|
149240
|
+
const deployed = Math.max(...facing.map((f) => f.stacks + f.deploy));
|
|
149241
|
+
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 }));
|
|
149242
|
+
holds.push({ territoryId: t, armies: have, facing, addAgainstStacks: add(stacks), addAgainstDeploy: add(deployed), protects });
|
|
149243
|
+
}
|
|
149244
|
+
const worth = (h) => h.protects.reduce((n, p) => n + p.value, 0);
|
|
149245
|
+
holds.sort((a, b) => worth(b) - worth(a) || b.addAgainstDeploy - a.addAgainstDeploy || a.territoryId - b.territoryId);
|
|
149246
|
+
return { captures: captures.slice(0, limit), holds: holds.slice(0, limit) };
|
|
149247
|
+
}
|
|
149248
|
+
var ALTERNATIVE_GOALS = ["expand", "defend"];
|
|
149249
|
+
function alternativePlans(input2, base, stress) {
|
|
149250
|
+
const view = (name, p) => {
|
|
149251
|
+
const s = stress?.(p);
|
|
149252
|
+
return {
|
|
149253
|
+
name,
|
|
149254
|
+
goal: p.goal,
|
|
149255
|
+
deploys: p.deploys.map((d) => ({ territoryId: d.territoryId, armies: d.armies })),
|
|
149256
|
+
moves: p.moves.map((m) => ({ from: m.from, to: m.to, armies: m.armies, kind: m.kind })),
|
|
149257
|
+
expected: {
|
|
149258
|
+
nextIncome: p.expected.nextIncome,
|
|
149259
|
+
captures: p.expected.captures,
|
|
149260
|
+
bonusesCompleted: p.expected.bonusesCompleted,
|
|
149261
|
+
...p.expected.nextIncomeIfConcededFall !== void 0 ? { nextIncomeIfConcededFall: p.expected.nextIncomeIfConcededFall } : {}
|
|
149262
|
+
},
|
|
149263
|
+
conceded: p.conceded,
|
|
149264
|
+
...s ? { stress: s } : {}
|
|
149265
|
+
};
|
|
149266
|
+
};
|
|
149267
|
+
const key = (p) => JSON.stringify([p.deploys.map((d) => [d.territoryId, d.armies]), p.moves.map((m) => [m.from, m.to, m.armies])]);
|
|
149268
|
+
const out = [view("default", base)];
|
|
149269
|
+
const keys = /* @__PURE__ */ new Set([key(base)]);
|
|
149270
|
+
for (const goal of ALTERNATIVE_GOALS) {
|
|
149271
|
+
if (goal === base.goal) continue;
|
|
149272
|
+
const p = planTurn({ ...input2, options: { ...input2.options, goal } });
|
|
149273
|
+
if (keys.has(key(p))) continue;
|
|
149274
|
+
keys.add(key(p));
|
|
149275
|
+
out.push(view(goal, p));
|
|
149276
|
+
}
|
|
149277
|
+
return out;
|
|
149278
|
+
}
|
|
149279
|
+
function stressSummary(r) {
|
|
149280
|
+
return {
|
|
149281
|
+
safe: r.considered === 0 ? null : r.harmful === 0,
|
|
149282
|
+
harmful: r.harmful,
|
|
149283
|
+
considered: r.considered,
|
|
149284
|
+
...r.worst ? { worst: { opponent: r.worst.opponent, lost: r.worst.lost, capturesFailed: r.worst.capturesFailed, incomeLost: r.worst.incomeLost } } : {}
|
|
149285
|
+
};
|
|
149286
|
+
}
|
|
149287
|
+
|
|
149288
|
+
// src/analysis/situation.ts
|
|
149289
|
+
var MAX_SITUATION_TERRITORIES = 400;
|
|
149290
|
+
var MAX_SITUATION_BONUSES = 60;
|
|
149291
|
+
var SITUATION_PAST_TURNS = 10;
|
|
149292
|
+
var ownerOf9 = (t, me) => {
|
|
149293
|
+
if (!t || t.owner.kind === "unknown") return "fog";
|
|
149294
|
+
if (t.owner.kind !== "player") return "neutral";
|
|
149295
|
+
return t.owner.playerId === me ? "me" : t.owner.playerId;
|
|
149296
|
+
};
|
|
149297
|
+
function situation(input2) {
|
|
149298
|
+
const { graph: g, board, me } = input2;
|
|
149299
|
+
const guard = input2.guard === false ? 0 : 1;
|
|
149300
|
+
const state = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
149301
|
+
const owner = (id) => ownerOf9(state.get(id), me);
|
|
149302
|
+
const armiesOf3 = (id) => state.get(id)?.armies ?? null;
|
|
149303
|
+
const mine3 = [...state.keys()].filter((id) => owner(id) === "me").sort((a, b) => a - b);
|
|
149304
|
+
const mineSet = new Set(mine3);
|
|
149305
|
+
const take = (n) => armiesToTake(n, input2.rates);
|
|
149306
|
+
const dist = new Map(mine3.map((m) => [m, 0]));
|
|
149307
|
+
let frontier = mine3;
|
|
149308
|
+
while (frontier.length) {
|
|
149309
|
+
const next = [];
|
|
149310
|
+
for (const t of frontier)
|
|
149311
|
+
for (const n of neighborsOf(g, t))
|
|
149312
|
+
if (!dist.has(n)) {
|
|
149313
|
+
dist.set(n, dist.get(t) + 1);
|
|
149314
|
+
next.push(n);
|
|
149315
|
+
}
|
|
149316
|
+
frontier = next;
|
|
149317
|
+
}
|
|
149318
|
+
const bonusesOf3 = /* @__PURE__ */ new Map();
|
|
149319
|
+
for (const b of g.map.bonuses) for (const t of bonusTerritories(g, b.id)) bonusesOf3.set(t, [...bonusesOf3.get(t) ?? [], b.id]);
|
|
149320
|
+
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);
|
|
149321
|
+
const territories = listed.slice(0, MAX_SITUATION_TERRITORIES).map((id) => {
|
|
149322
|
+
const t = state.get(id);
|
|
149323
|
+
const units = t?.specialUnits?.map((u) => ({ kind: u.kind, owner: u.playerId === me ? "me" : u.playerId }));
|
|
149324
|
+
return {
|
|
149325
|
+
id,
|
|
149326
|
+
name: g.territoryById.get(id)?.name ?? String(id),
|
|
149327
|
+
owner: owner(id),
|
|
149328
|
+
armies: armiesOf3(id),
|
|
149329
|
+
...units?.length ? { units } : {},
|
|
149330
|
+
distance: dist.get(id) ?? -1,
|
|
149331
|
+
bonuses: bonusesOf3.get(id) ?? [],
|
|
149332
|
+
neighbors: [...neighborsOf(g, id)]
|
|
149333
|
+
};
|
|
149334
|
+
});
|
|
149335
|
+
const bonuses = [];
|
|
149336
|
+
for (const b of g.map.bonuses) {
|
|
149337
|
+
if (b.value <= 0) continue;
|
|
149338
|
+
const members2 = bonusTerritories(g, b.id);
|
|
149339
|
+
let mineN = 0;
|
|
149340
|
+
let neutral = 0;
|
|
149341
|
+
let fogged = 0;
|
|
149342
|
+
const players = /* @__PURE__ */ new Map();
|
|
149343
|
+
for (const t of members2) {
|
|
149344
|
+
const o = owner(t);
|
|
149345
|
+
if (o === "me") mineN++;
|
|
149346
|
+
else if (o === "neutral") neutral++;
|
|
149347
|
+
else if (o === "fog") fogged++;
|
|
149348
|
+
else players.set(o, (players.get(o) ?? 0) + 1);
|
|
149349
|
+
}
|
|
149350
|
+
const heldBy3 = mineN === members2.length ? "me" : players.size === 1 && [...players.values()][0] === members2.length ? [...players.keys()][0] : null;
|
|
149351
|
+
const near2 = members2.some((t) => (dist.get(t) ?? Infinity) <= 1);
|
|
149352
|
+
if (!near2 && heldBy3 === null) continue;
|
|
149353
|
+
const missing = members2.filter((t) => owner(t) !== "me");
|
|
149354
|
+
const hidden = missing.some((t) => armiesOf3(t) === null);
|
|
149355
|
+
bonuses.push({
|
|
149356
|
+
bonusId: b.id,
|
|
149357
|
+
name: b.name,
|
|
149358
|
+
value: b.value,
|
|
149359
|
+
size: members2.length,
|
|
149360
|
+
mine: mineN,
|
|
149361
|
+
neutral,
|
|
149362
|
+
fogged,
|
|
149363
|
+
players: [...players].sort((x, y) => x[0] - y[0]).map(([player2, count4]) => ({ player: player2, count: count4 })),
|
|
149364
|
+
heldBy: heldBy3,
|
|
149365
|
+
missing,
|
|
149366
|
+
armiesToFinish: hidden ? null : missing.reduce((n, t) => n + (take(armiesOf3(t)) ?? Infinity), 0),
|
|
149367
|
+
reachable: missing.filter((t) => neighborsOf(g, t).some((n) => mineSet.has(n)))
|
|
149368
|
+
});
|
|
149369
|
+
}
|
|
149370
|
+
bonuses.sort(
|
|
149371
|
+
(a, b) => Number(b.heldBy === "me") - Number(a.heldBy === "me") || a.missing.length - b.missing.length || b.value - a.value || a.bonusId - b.bonusId
|
|
149372
|
+
);
|
|
149373
|
+
const opponents = [...input2.opponents].filter((o) => o.playerId !== me && !input2.friends?.has(o.playerId)).sort((a, b) => a.playerId - b.playerId).map((o) => {
|
|
149374
|
+
const theirs = [...state.keys()].filter((id) => owner(id) === o.playerId);
|
|
149375
|
+
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)) }));
|
|
149376
|
+
return {
|
|
149377
|
+
player: o.playerId,
|
|
149378
|
+
income: {
|
|
149379
|
+
estimate: o.estimate,
|
|
149380
|
+
...o.source !== void 0 ? { source: o.source } : {},
|
|
149381
|
+
...o.visibleIncome !== void 0 ? { visible: o.visibleIncome } : {},
|
|
149382
|
+
...o.tracked !== void 0 ? { tracked: o.tracked } : {},
|
|
149383
|
+
...o.range !== void 0 ? { range: o.range } : {},
|
|
149384
|
+
...o.coverage !== void 0 ? { coverage: o.coverage } : {}
|
|
149385
|
+
},
|
|
149386
|
+
...o.history?.length ? { history: o.history.map((h) => ({ turn: h.turn, observed: h.observed })) } : {},
|
|
149387
|
+
territoriesInView: theirs.length,
|
|
149388
|
+
armiesInView: theirs.reduce((n, id) => n + (armiesOf3(id) ?? 0), 0),
|
|
149389
|
+
bonusesHeld: bonuses.filter((b) => b.heldBy === o.playerId).map((b) => ({ bonusId: b.bonusId, value: b.value })),
|
|
149390
|
+
besideMe,
|
|
149391
|
+
movableBesideMe: besideMe.reduce((n, s) => n + Math.max(0, s.armies - guard), 0)
|
|
149392
|
+
};
|
|
149393
|
+
});
|
|
149394
|
+
let changes = null;
|
|
149395
|
+
if (input2.previousBoard) {
|
|
149396
|
+
const prev = new Map(input2.previousBoard.territories.map((t) => [t.territoryId, t]));
|
|
149397
|
+
const was = (id) => ownerOf9(prev.get(id), me);
|
|
149398
|
+
const lost = [];
|
|
149399
|
+
const gained = [];
|
|
149400
|
+
const moved = [];
|
|
149401
|
+
for (const id of [.../* @__PURE__ */ new Set([...prev.keys(), ...state.keys()])].sort((a, b) => a - b)) {
|
|
149402
|
+
const before = was(id);
|
|
149403
|
+
const now = owner(id);
|
|
149404
|
+
if (before === "me" && now !== "me") lost.push({ territoryId: id, to: now });
|
|
149405
|
+
else if (now === "me" && before !== "me") gained.push({ territoryId: id, from: before });
|
|
149406
|
+
else if (typeof now === "number" && before === now) {
|
|
149407
|
+
const a = prev.get(id)?.armies;
|
|
149408
|
+
const b = armiesOf3(id);
|
|
149409
|
+
if (a !== null && a !== void 0 && b !== null && a !== b) moved.push({ territoryId: id, owner: now, was: a, now: b });
|
|
149410
|
+
}
|
|
149411
|
+
}
|
|
149412
|
+
moved.sort((x, y) => Math.abs(y.now - y.was) - Math.abs(x.now - x.was) || x.territoryId - y.territoryId);
|
|
149413
|
+
changes = { lost, gained, moved: moved.slice(0, MAX_SITUATION_BONUSES) };
|
|
149414
|
+
}
|
|
149415
|
+
const past = [...input2.pastBoards ?? []].sort((a, b) => a.turn - b.turn).slice(-SITUATION_PAST_TURNS).map((p) => {
|
|
149416
|
+
const at2 = new Map(p.board.territories.map((t) => [t.territoryId, t]));
|
|
149417
|
+
const sides = /* @__PURE__ */ new Map();
|
|
149418
|
+
for (const t of p.board.territories) {
|
|
149419
|
+
const o = ownerOf9(t, me);
|
|
149420
|
+
if (o === "fog" || o === "neutral") continue;
|
|
149421
|
+
const side2 = sides.get(o) ?? { territories: 0, armies: 0 };
|
|
149422
|
+
side2.territories++;
|
|
149423
|
+
side2.armies += t.armies ?? 0;
|
|
149424
|
+
sides.set(o, side2);
|
|
149425
|
+
}
|
|
149426
|
+
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);
|
|
149427
|
+
return {
|
|
149428
|
+
turn: p.turn,
|
|
149429
|
+
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) })),
|
|
149430
|
+
...p.orders ? {
|
|
149431
|
+
myOrders: {
|
|
149432
|
+
deploys: p.orders.deploys.map((d) => ({ territoryId: d.territoryId, armies: d.armies })),
|
|
149433
|
+
moves: p.orders.moves.map((m) => ({ from: m.from, to: m.to, armies: m.armies }))
|
|
149434
|
+
}
|
|
149435
|
+
} : {}
|
|
149436
|
+
};
|
|
149437
|
+
});
|
|
149438
|
+
return {
|
|
149439
|
+
me: {
|
|
149440
|
+
income: input2.myIncome,
|
|
149441
|
+
incomeHistory: [...input2.incomeHistory ?? []],
|
|
149442
|
+
territories: mine3.length,
|
|
149443
|
+
armies: mine3.reduce((n, id) => n + (armiesOf3(id) ?? 0), 0),
|
|
149444
|
+
bonusesHeld: bonuses.filter((b) => b.heldBy === "me").map((b) => ({ bonusId: b.bonusId, value: b.value }))
|
|
149445
|
+
},
|
|
149446
|
+
territories,
|
|
149447
|
+
territoriesOmitted: Math.max(0, listed.length - MAX_SITUATION_TERRITORIES),
|
|
149448
|
+
bonuses: bonuses.slice(0, MAX_SITUATION_BONUSES),
|
|
149449
|
+
bonusesOmitted: Math.max(0, bonuses.length - MAX_SITUATION_BONUSES),
|
|
149450
|
+
opponents,
|
|
149451
|
+
changes,
|
|
149452
|
+
past
|
|
149453
|
+
};
|
|
149454
|
+
}
|
|
149455
|
+
var FACT_PARTS = ["me", "territories", "bonuses", "opponents", "changes", "past"];
|
|
149456
|
+
var FACTS_AVAILABLE = {
|
|
149457
|
+
me: "my income and its history, land, armies and bonuses held",
|
|
149458
|
+
territories: "every territory in view and each hidden one beside my land, nearest first: owner, armies, special units, bonuses, neighbours",
|
|
149459
|
+
bonuses: "each bonus that matters: who holds how much of it, what finishing it costs, the members in reach",
|
|
149460
|
+
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",
|
|
149461
|
+
changes: "what changed since last turn: territories lost and gained, stacks that grew or shrank",
|
|
149462
|
+
past: "each of the last 10 turns kept: every side in view, its bonuses, my orders"
|
|
149463
|
+
};
|
|
149464
|
+
function pickFacts(s, parts) {
|
|
149465
|
+
const want = new Set(parts);
|
|
149466
|
+
return {
|
|
149467
|
+
...want.has("me") ? { me: s.me } : {},
|
|
149468
|
+
...want.has("territories") ? { territories: s.territories, territoriesOmitted: s.territoriesOmitted } : {},
|
|
149469
|
+
...want.has("bonuses") ? { bonuses: s.bonuses, bonusesOmitted: s.bonusesOmitted } : {},
|
|
149470
|
+
...want.has("opponents") ? { opponents: s.opponents } : {},
|
|
149471
|
+
...want.has("changes") ? { changes: s.changes } : {},
|
|
149472
|
+
...want.has("past") ? { past: s.past } : {}
|
|
149473
|
+
};
|
|
149474
|
+
}
|
|
149475
|
+
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.';
|
|
149476
|
+
var OWN_PLAN_STEPS = [
|
|
149477
|
+
"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).",
|
|
149478
|
+
"Write your own deploys and moves (any mix of the options, the alternatives or neither).",
|
|
149479
|
+
"Test them with warapp_check_plan (every opponent's replies, both move orders, one turn ahead); change and test again as needed.",
|
|
149480
|
+
"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.",
|
|
149481
|
+
"Submit with warapp_submit_turn; when your orders differ from the plan, pass override_reason so the decision log keeps why."
|
|
149482
|
+
];
|
|
149483
|
+
|
|
149166
149484
|
// src/analysis/chat-advice.ts
|
|
149167
149485
|
var CLOSE_RATIO = 0.85;
|
|
149168
149486
|
var CLEAR_LEAD_RATIO = 1.2;
|
|
@@ -150693,7 +151011,7 @@ var OUTREACH_DRAFTS = 2;
|
|
|
150693
151011
|
var COALITION_NOTE_IDS = ["ffa-coalition-match-commitment", "ffa-second-needs-third"];
|
|
150694
151012
|
function leaderBonuses(graph, board, leader, candidates2) {
|
|
150695
151013
|
const at2 = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
150696
|
-
const
|
|
151014
|
+
const ownerOf11 = (id) => {
|
|
150697
151015
|
const o = at2.get(id)?.owner;
|
|
150698
151016
|
return o?.kind === "player" ? o.playerId : void 0;
|
|
150699
151017
|
};
|
|
@@ -150701,13 +151019,13 @@ function leaderBonuses(graph, board, leader, candidates2) {
|
|
|
150701
151019
|
for (const bonus of [...graph.bonusById.values()].sort((a, b) => a.id - b.id)) {
|
|
150702
151020
|
if (bonus.value <= 0) continue;
|
|
150703
151021
|
const ts = bonusTerritories(graph, bonus.id);
|
|
150704
|
-
if (!ts.length || !ts.every((t) =>
|
|
151022
|
+
if (!ts.length || !ts.every((t) => ownerOf11(t) === leader)) continue;
|
|
150705
151023
|
const by = /* @__PURE__ */ new Map();
|
|
150706
151024
|
for (const t of [...ts].sort((a, b) => a - b)) {
|
|
150707
151025
|
const defenders2 = (at2.get(t)?.armies ?? 0) + specialUnitStrength(at2.get(t)?.specialUnits);
|
|
150708
151026
|
const beside = /* @__PURE__ */ new Map();
|
|
150709
151027
|
for (const n of neighborsOf(graph, t)) {
|
|
150710
|
-
const p =
|
|
151028
|
+
const p = ownerOf11(n);
|
|
150711
151029
|
if (p !== void 0 && p !== leader && candidates2.has(p)) beside.set(p, (beside.get(p) ?? 0) + (at2.get(n)?.armies ?? 0));
|
|
150712
151030
|
}
|
|
150713
151031
|
for (const [p, armies] of beside) {
|
|
@@ -154948,7 +155266,9 @@ async function livePlanSetup(ctx, a) {
|
|
|
154948
155266
|
commerce,
|
|
154949
155267
|
statedShifts: shifts,
|
|
154950
155268
|
// #427: the last turn's Reinforcement plays, for warapp_plan_turn to keep (only when plays show).
|
|
154951
|
-
seenPlays: playsShown ? lastPlays : void 0
|
|
155269
|
+
seenPlays: playsShown ? lastPlays : void 0,
|
|
155270
|
+
// #606: the earlier boards (and my orders on them) for the strategy view's summary of past turns.
|
|
155271
|
+
pastBoards: history.boards
|
|
154952
155272
|
};
|
|
154953
155273
|
}
|
|
154954
155274
|
var CARD_AIRLIFT2 = 6;
|
|
@@ -155410,13 +155730,19 @@ function registerTurnTools(server, ctx, opts = {}) {
|
|
|
155410
155730
|
keep_cards: external_exports.coerce.number().int().min(0).max(100).optional().describe(
|
|
155411
155731
|
"Airlift cards to keep in reserve: `airliftPlan` plays only those held beyond this many (default 0). Changes nothing when you hold no Airlift."
|
|
155412
155732
|
),
|
|
155733
|
+
strategy: external_exports.boolean().optional().describe(
|
|
155734
|
+
"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."
|
|
155735
|
+
),
|
|
155736
|
+
facts: external_exports.array(external_exports.enum(FACT_PARTS)).min(1).optional().describe(
|
|
155737
|
+
"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."
|
|
155738
|
+
),
|
|
155413
155739
|
view: viewArg(
|
|
155414
155740
|
VIEWS6,
|
|
155415
155741
|
`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
155742
|
)
|
|
155417
155743
|
})
|
|
155418
155744
|
},
|
|
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 }) => {
|
|
155745
|
+
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
155746
|
const feed = await ctx.client.getGame(game_id, { settings: true, chat: true });
|
|
155421
155747
|
requireTurnPhase(feed);
|
|
155422
155748
|
const map2 = mapOf(feed);
|
|
@@ -155728,6 +156054,74 @@ function registerTurnTools(server, ctx, opts = {}) {
|
|
|
155728
156054
|
guessSkip = { reason: "commander", message };
|
|
155729
156055
|
}
|
|
155730
156056
|
}
|
|
156057
|
+
const factsView = facts ? pickFacts(
|
|
156058
|
+
situation({
|
|
156059
|
+
graph,
|
|
156060
|
+
board,
|
|
156061
|
+
...setup.input.previousBoard ? { previousBoard: setup.input.previousBoard } : {},
|
|
156062
|
+
me: me.id,
|
|
156063
|
+
...setup.teams ? { friends: new Set([...setup.teams].filter(([id, t]) => id !== me.id && t === setup.teams.get(me.id)).map(([id]) => id)) } : {},
|
|
156064
|
+
rates: { offensiveKillRate: settings.offensiveKillRate, defensiveKillRate: settings.defensiveKillRate },
|
|
156065
|
+
guard: settings.oneArmyStandsGuard !== false,
|
|
156066
|
+
myIncome: income,
|
|
156067
|
+
...setup.input.incomeHistory ? { incomeHistory: setup.input.incomeHistory } : {},
|
|
156068
|
+
pastBoards: setup.pastBoards,
|
|
156069
|
+
opponents: estimates.map((e) => {
|
|
156070
|
+
const t = tracks?.find((x) => x.playerId === e.playerId);
|
|
156071
|
+
return {
|
|
156072
|
+
playerId: e.playerId,
|
|
156073
|
+
estimate: e.estimate,
|
|
156074
|
+
source: e.source,
|
|
156075
|
+
visibleIncome: e.base + e.bonusIncome,
|
|
156076
|
+
tracked: t?.income ?? null,
|
|
156077
|
+
range: e.thinEvidence ? { low: e.thinEvidence.lower, high: e.thinEvidence.upper } : null,
|
|
156078
|
+
coverage: t?.coverage?.share ?? null,
|
|
156079
|
+
...t ? { history: t.turns.map((x) => ({ turn: x.to, observed: x.observed })) } : {}
|
|
156080
|
+
};
|
|
156081
|
+
})
|
|
156082
|
+
}),
|
|
156083
|
+
facts
|
|
156084
|
+
) : void 0;
|
|
156085
|
+
const strategyView = strategy ? (() => {
|
|
156086
|
+
const deployOf = (p) => estimates.find((e) => e.playerId === p)?.estimate ?? 0;
|
|
156087
|
+
const stressOpp = estimates.map((e) => ({ id: e.playerId, deploy: e.estimate }));
|
|
156088
|
+
const stress = (p) => {
|
|
156089
|
+
if (!stressOpp.length) return void 0;
|
|
156090
|
+
try {
|
|
156091
|
+
return stressSummary(
|
|
156092
|
+
stressPlan({
|
|
156093
|
+
graph,
|
|
156094
|
+
board,
|
|
156095
|
+
me: me.id,
|
|
156096
|
+
deploys: p.deploys,
|
|
156097
|
+
moves: p.moves.map((m) => ({ from: m.from, to: m.to, armies: m.armies })),
|
|
156098
|
+
opponents: stressOpp,
|
|
156099
|
+
settings,
|
|
156100
|
+
...setup.teams ? { teams: setup.teams } : {},
|
|
156101
|
+
lookAhead: false,
|
|
156102
|
+
maxReplies: 1
|
|
156103
|
+
})
|
|
156104
|
+
);
|
|
156105
|
+
} catch {
|
|
156106
|
+
return void 0;
|
|
156107
|
+
}
|
|
156108
|
+
};
|
|
156109
|
+
return {
|
|
156110
|
+
options: turnOptions({
|
|
156111
|
+
graph,
|
|
156112
|
+
board,
|
|
156113
|
+
me: me.id,
|
|
156114
|
+
deployOf,
|
|
156115
|
+
rates: { offensiveKillRate: settings.offensiveKillRate, defensiveKillRate: settings.defensiveKillRate },
|
|
156116
|
+
guard: settings.oneArmyStandsGuard !== false,
|
|
156117
|
+
...setup.teams ? { friends: new Set([...setup.teams].filter(([id, t]) => id !== me.id && t === setup.teams.get(me.id)).map(([id]) => id)) } : {}
|
|
156118
|
+
}),
|
|
156119
|
+
alternatives: alternativePlans(setup.input, plan, stress),
|
|
156120
|
+
available: FACTS_AVAILABLE,
|
|
156121
|
+
steps: OWN_PLAN_STEPS,
|
|
156122
|
+
note: STRATEGY_NOTE
|
|
156123
|
+
};
|
|
156124
|
+
})() : void 0;
|
|
155731
156125
|
const headroom = safeHeadroom({
|
|
155732
156126
|
graph,
|
|
155733
156127
|
board,
|
|
@@ -156050,6 +156444,11 @@ function registerTurnTools(server, ctx, opts = {}) {
|
|
|
156050
156444
|
...plan.incomeTrend ? {
|
|
156051
156445
|
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
156446
|
} : {},
|
|
156447
|
+
// #606: the mechanics for the calling model's own choice (opt-in).
|
|
156448
|
+
...strategyView ? { strategy: strategyView } : {},
|
|
156449
|
+
...factsView ? { facts: factsView } : {},
|
|
156450
|
+
// #606: every plan says what more can be asked for (the menu itself names the facts).
|
|
156451
|
+
...strategyView ? {} : { more: MORE_ON_REQUEST },
|
|
156053
156452
|
// #275 (a): each border's headroom, the weakest first (compact: the first few).
|
|
156054
156453
|
headroom: headroomView(headroom, map2, myIncome, rung === "full", !teamsKnown, (p) => estimates.find((e) => e.playerId === p)?.estimate),
|
|
156055
156454
|
...rung !== "full" && headroom.length > HEADROOM_COMPACT ? { headroomMore: headroom.length - HEADROOM_COMPACT } : {},
|
|
@@ -160738,13 +161137,13 @@ function registerCheckPlanTool(server, ctx) {
|
|
|
160738
161137
|
const belowPlan = await bordersBelowPlan(ctx, { game, map: map2, me, turn, territories, info, history, teamsKnown, given: { deploys, moves } });
|
|
160739
161138
|
const avoidT = new Set((intel.avoidTerritories ?? []).map((t) => resolveTerritory(map2, t).id));
|
|
160740
161139
|
const avoidP = new Set(intel.avoidPlayers ?? []);
|
|
160741
|
-
const
|
|
161140
|
+
const ownerOf11 = (id) => {
|
|
160742
161141
|
const o = board.territories.find((t) => t.territoryId === id)?.owner;
|
|
160743
161142
|
return o?.kind === "player" ? o.playerId : void 0;
|
|
160744
161143
|
};
|
|
160745
|
-
const allyHits = modRead ? attacksOnAllies(modRead, moves,
|
|
161144
|
+
const allyHits = modRead ? attacksOnAllies(modRead, moves, ownerOf11) : [];
|
|
160746
161145
|
const avoidedHits = [...new Set(moves.map((m) => m.to))].filter(
|
|
160747
|
-
(to) => !mine3.has(to) && (avoidT.has(to) || avoidP.has(
|
|
161146
|
+
(to) => !mine3.has(to) && (avoidT.has(to) || avoidP.has(ownerOf11(to) ?? Number.NaN))
|
|
160748
161147
|
);
|
|
160749
161148
|
const capOver = territoryCapOverruns(binding, {
|
|
160750
161149
|
mine: mine3,
|
|
@@ -166610,13 +167009,13 @@ function registerCalibrationTool(server, dataDir2) {
|
|
|
166610
167009
|
// src/tools/turn-history.ts
|
|
166611
167010
|
var MAX_HISTORY_TURNS = 20;
|
|
166612
167011
|
var DEFAULT_HISTORY_TURNS = 5;
|
|
166613
|
-
var
|
|
167012
|
+
var ownerOf10 = (t) => t.owner.kind === "player" ? t.owner.playerId : t.owner.kind === "neutral" ? "neutral" : null;
|
|
166614
167013
|
function boardSummary(board, me) {
|
|
166615
167014
|
const players = /* @__PURE__ */ new Map();
|
|
166616
167015
|
let neutral = 0;
|
|
166617
167016
|
let hidden = 0;
|
|
166618
167017
|
for (const t of board.territories) {
|
|
166619
|
-
const o =
|
|
167018
|
+
const o = ownerOf10(t);
|
|
166620
167019
|
if (o === null) hidden++;
|
|
166621
167020
|
else if (o === "neutral") neutral++;
|
|
166622
167021
|
else {
|
|
@@ -166637,10 +167036,10 @@ function boardSummary(board, me) {
|
|
|
166637
167036
|
};
|
|
166638
167037
|
}
|
|
166639
167038
|
function ownerChanges(before, after) {
|
|
166640
|
-
const was = new Map(before.territories.map((t) => [t.territoryId,
|
|
167039
|
+
const was = new Map(before.territories.map((t) => [t.territoryId, ownerOf10(t)]));
|
|
166641
167040
|
const out = [];
|
|
166642
167041
|
for (const t of after.territories) {
|
|
166643
|
-
const now =
|
|
167042
|
+
const now = ownerOf10(t);
|
|
166644
167043
|
const prev = was.get(t.territoryId);
|
|
166645
167044
|
if (prev === void 0 || prev === null || now === null || prev === now) continue;
|
|
166646
167045
|
out.push([t.territoryId, prev, now]);
|
|
@@ -166668,7 +167067,7 @@ function seenByPlayer(orders) {
|
|
|
166668
167067
|
}
|
|
166669
167068
|
return out;
|
|
166670
167069
|
}
|
|
166671
|
-
var boardRows = (b) => [...b.territories].sort((x, y) => x.territoryId - y.territoryId).map((t) => [t.territoryId,
|
|
167070
|
+
var boardRows = (b) => [...b.territories].sort((x, y) => x.territoryId - y.territoryId).map((t) => [t.territoryId, ownerOf10(t), t.armies]);
|
|
166672
167071
|
function historyTurn(log, turn, opts = {}) {
|
|
166673
167072
|
const e = log.turns[String(turn)] ?? {};
|
|
166674
167073
|
const me = log.playerId;
|