@chrischall/warapp-mcp 0.1.0 → 0.2.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 +3 -3
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +28 -17
- package/dist/analysis/accept-surrender.js +56 -0
- package/dist/analysis/calibrate.js +239 -0
- package/dist/analysis/finished-game.js +136 -0
- package/dist/analysis/game-lessons.js +217 -0
- package/dist/analysis/local-deploy.js +37 -17
- package/dist/analysis/opponent-profile.js +6 -5
- package/dist/analysis/opponents.js +10 -2
- package/dist/analysis/outlook.js +63 -1
- package/dist/analysis/plan/shared.js +194 -7
- package/dist/analysis/plan/threats.js +103 -29
- package/dist/analysis/planner.js +10 -5
- package/dist/analysis/stress.js +14 -7
- package/dist/analysis/whereabouts.js +3 -0
- package/dist/bundle.js +12392 -9245
- package/dist/calibration-source.js +75 -0
- package/dist/chat.js +73 -0
- package/dist/client.js +85 -7
- package/dist/finished-store.js +357 -0
- package/dist/index.js +1 -1
- package/dist/lessons-store.js +356 -0
- package/dist/live.js +9 -0
- package/dist/map-details.js +127 -0
- package/dist/map-stats.js +14 -6
- package/dist/map-store.js +44 -6
- package/dist/my-games.js +44 -6
- package/dist/normalize.js +34 -2
- package/dist/notifications.js +143 -0
- package/dist/outlook-log.js +28 -1
- package/dist/player-record-store.js +2 -0
- package/dist/profile-store.js +61 -11
- package/dist/protocol/methods.js +86 -2
- package/dist/replay.js +16 -4
- package/dist/stats.js +26 -4
- package/dist/strategy/notes.js +64 -9
- package/dist/surrender-pending.js +126 -0
- package/dist/tools/accept-surrender.js +311 -0
- package/dist/tools/chat-inbox.js +17 -5
- package/dist/tools/chat-read-mark.js +179 -0
- package/dist/tools/chat.js +50 -8
- package/dist/tools/check-plan.js +1 -0
- package/dist/tools/commander-check.js +1 -0
- package/dist/tools/end-of-game.js +384 -0
- package/dist/tools/game.js +31 -6
- package/dist/tools/index.js +15 -5
- package/dist/tools/live-context.js +1 -1
- package/dist/tools/map-details.js +88 -0
- package/dist/tools/map-stats.js +15 -2
- package/dist/tools/map.js +10 -2
- package/dist/tools/my-games.js +77 -7
- package/dist/tools/notifications.js +484 -0
- package/dist/tools/opponents.js +14 -2
- package/dist/tools/past-games.js +94 -0
- package/dist/tools/picks.js +15 -2
- package/dist/tools/profile-opponents.js +1 -1
- package/dist/tools/profile-reads.js +3 -3
- package/dist/tools/push.js +72 -12
- package/dist/tools/strategy.js +65 -8
- package/dist/tools/stress-opponents.js +1 -1
- package/dist/tools/surrender-pending.js +74 -0
- package/dist/tools/surrender.js +10 -3
- package/dist/tools/team.js +1 -5
- package/dist/tools/turn.js +79 -15
- package/dist/tools/where.js +42 -17
- package/dist/tools/write-kit.js +6 -0
- package/dist/trend.js +145 -20
- package/dist/version.js +1 -1
- package/manifest.json +22 -2
- package/mint.yaml +14 -9
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/warapp-mcp/SKILL.md +141 -14
|
@@ -40,6 +40,18 @@ export const TRACKED_MIN_TURNS = 2;
|
|
|
40
40
|
* the gap. Unmeasured: four observed turns with its whole edge in view meet half-way.
|
|
41
41
|
*/
|
|
42
42
|
export const PRIOR_EVIDENCE_TURNS = 4;
|
|
43
|
+
/**
|
|
44
|
+
* #294: an opponent's tracked income was read from less than this share of its frontier
|
|
45
|
+
* ({@link frontierCoverage}, over its income window): it is read as low, and the estimate never
|
|
46
|
+
* falls below the tracked figure × {@link LOW_COVERAGE_FACTOR}. Unmeasured.
|
|
47
|
+
*/
|
|
48
|
+
export const LOW_COVERAGE = 0.5;
|
|
49
|
+
/**
|
|
50
|
+
* #294: while coverage is under {@link LOW_COVERAGE}, the estimate is at least the tracked figure ×
|
|
51
|
+
* this (at most what it could earn). Unmeasured: the play session's long fogged games tracked a half
|
|
52
|
+
* to a quarter of the income later seen, so 1.5 is a cautious floor, not a correction.
|
|
53
|
+
*/
|
|
54
|
+
export const LOW_COVERAGE_FACTOR = 1.5;
|
|
43
55
|
/** Fog reveals named in the observed-deploy rationale before "and N more". */
|
|
44
56
|
export const MAX_NAMED_REVEALS = 6;
|
|
45
57
|
/**
|
|
@@ -130,6 +142,16 @@ export const NEUTRAL_BORDER_COST = 0.25;
|
|
|
130
142
|
const CYCLIC_ORDERS = new Set(['Cycle', 'NoLuckCycle']);
|
|
131
143
|
/** A cyclic move order (GameFeed's `MoveOrder`): the order reverses every turn. */
|
|
132
144
|
export const isCyclicMoveOrder = (moveOrder) => moveOrder !== undefined && CYCLIC_ORDERS.has(moveOrder);
|
|
145
|
+
/**
|
|
146
|
+
* #293 review: an opponent's free income under Local Deployment on the turn read (`turn`), for
|
|
147
|
+
* {@link ObserveContext.localFree}: its base (never below `floor`) plus a Reinforcement card's armies
|
|
148
|
+
* when the clock says one can be in hand by then (unknown turn: yes, when one is in play). A card
|
|
149
|
+
* play is income it may deploy anywhere.
|
|
150
|
+
*/
|
|
151
|
+
export function localFreeOn(base, floor, clock, turn) {
|
|
152
|
+
const card = clock && clock.armies > 0 && (turn === null || turn === undefined || turn >= clock.firstTurn) ? clock.armies : 0;
|
|
153
|
+
return Math.max(floor, base) + card;
|
|
154
|
+
}
|
|
133
155
|
/** #271 review: whether an opponent may have played a Bomb on `turn` (unknown turn: yes, when one is in play). */
|
|
134
156
|
export function bombPossibleOn(settings, turn) {
|
|
135
157
|
return settings.bombFrom !== undefined && (turn === null || turn === undefined || turn >= settings.bombFrom);
|
|
@@ -293,6 +315,71 @@ export function ownerShown(t) {
|
|
|
293
315
|
return undefined;
|
|
294
316
|
return t;
|
|
295
317
|
}
|
|
318
|
+
/** #294: {@link FrontierCoverage} of one opponent on one observed turn. Pure. */
|
|
319
|
+
export function frontierCoverage(g, board, previous, playerId) {
|
|
320
|
+
const now = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
321
|
+
const before = new Map(previous.territories.map((t) => [t.territoryId, t]));
|
|
322
|
+
const its = (id) => {
|
|
323
|
+
const st = ownerShown(now.get(id));
|
|
324
|
+
return st?.owner.kind === 'player' && st.owner.playerId === playerId;
|
|
325
|
+
};
|
|
326
|
+
const shownIts = [...g.territoryById.keys()].filter(its);
|
|
327
|
+
const frontier = new Set();
|
|
328
|
+
let inView = 0;
|
|
329
|
+
for (const t of shownIts) {
|
|
330
|
+
const ns = neighborsOf(g, t);
|
|
331
|
+
if (ns.every(its))
|
|
332
|
+
continue;
|
|
333
|
+
frontier.add(t);
|
|
334
|
+
const a = visibleState(now.get(t));
|
|
335
|
+
const b = visibleState(before.get(t));
|
|
336
|
+
if (a && b)
|
|
337
|
+
inView++;
|
|
338
|
+
for (const n of ns)
|
|
339
|
+
if (!ownerShown(now.get(n)))
|
|
340
|
+
frontier.add(n);
|
|
341
|
+
}
|
|
342
|
+
let hiddenBonuses = 0;
|
|
343
|
+
for (const bonus of g.map.bonuses) {
|
|
344
|
+
const ts = bonusTerritories(g, bonus.id);
|
|
345
|
+
if (bonus.value <= 0 || !ts.length)
|
|
346
|
+
continue;
|
|
347
|
+
const taken = ts.some((t) => {
|
|
348
|
+
const st = ownerShown(now.get(t));
|
|
349
|
+
return st !== undefined && !(st.owner.kind === 'player' && st.owner.playerId === playerId);
|
|
350
|
+
});
|
|
351
|
+
if (!taken && ts.some((t) => !ownerShown(now.get(t))))
|
|
352
|
+
hiddenBonuses++;
|
|
353
|
+
}
|
|
354
|
+
const share = frontier.size ? inView / frontier.size : shownIts.length ? 1 : 0;
|
|
355
|
+
return { inView, frontier: frontier.size, share, hiddenBonuses };
|
|
356
|
+
}
|
|
357
|
+
/** #294: {@link TrackCoverage} over `turns` (those carrying a coverage); `null` when none does. */
|
|
358
|
+
export function trackCoverage(turns) {
|
|
359
|
+
const withIt = turns.filter((x) => x.coverage !== undefined);
|
|
360
|
+
if (!withIt.length)
|
|
361
|
+
return null;
|
|
362
|
+
const inView = withIt.reduce((n, x) => n + x.coverage.inView, 0);
|
|
363
|
+
const frontier = withIt.reduce((n, x) => n + x.coverage.frontier, 0);
|
|
364
|
+
const range = (xs) => ({ min: Math.min(...xs), max: Math.max(...xs) });
|
|
365
|
+
return {
|
|
366
|
+
turns: withIt.map((x) => x.from),
|
|
367
|
+
inView: range(withIt.map((x) => x.coverage.inView)),
|
|
368
|
+
frontier: range(withIt.map((x) => x.coverage.frontier)),
|
|
369
|
+
share: frontier ? inView / frontier : withIt.reduce((n, x) => n + x.coverage.share, 0) / withIt.length,
|
|
370
|
+
hiddenBonuses: withIt.at(-1).coverage.hiddenBonuses,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* #294: "1 of ~4 frontier territories (25%)" (a range, "1–2 of ~4–5", when the turns differ; the share
|
|
375
|
+
* is Σ read ÷ Σ frontier), and ", N bonus(es) it could hold out of view" when any: the words beside a
|
|
376
|
+
* tracked figure.
|
|
377
|
+
*/
|
|
378
|
+
export function coverageText(c) {
|
|
379
|
+
const b = c.hiddenBonuses;
|
|
380
|
+
const range = (r) => (r.min === r.max ? `${r.min}` : `${r.min}–${r.max}`);
|
|
381
|
+
return `${range(c.inView)} of ~${range(c.frontier)} frontier territories (${Math.round(c.share * 100)}%)${b ? `, ${b} ${b === 1 ? 'bonus' : 'bonuses'} it could hold out of view` : ''}`;
|
|
382
|
+
}
|
|
296
383
|
/**
|
|
297
384
|
* #226: what my failed attacks on `playerId` killed, by target, on the turn `before` → `after`: each
|
|
298
385
|
* move of mine onto a territory it holds on both boards (shown with armies both times), from a
|
|
@@ -654,6 +741,37 @@ export function observeSigned(g, board, previous, playerId, rates = {}, context
|
|
|
654
741
|
for (const t of board.territories)
|
|
655
742
|
if (g.territoryById.has(t.territoryId) && heldBothTimes(t.territoryId))
|
|
656
743
|
shrinkLeft.set(t.territoryId, Math.max(0, visibleState(before.get(t.territoryId)).armies - t.armies - killsAt(t.territoryId)));
|
|
744
|
+
/** Not shown with armies on both boards: armies could have left it unseen. */
|
|
745
|
+
const hidden = (id) => !visibleState(now.get(id)) || !visibleState(before.get(id));
|
|
746
|
+
// #294: each grown stack's growth split, against its own copy of the shrinks (captures claim theirs below).
|
|
747
|
+
// The stacks with no hidden neighbour claim first (what they leave can only be deploy, so a shrink
|
|
748
|
+
// taken by a stack beside the fog would turn a move into a false "can only be deploy"), then those
|
|
749
|
+
// beside the fog; each in id order, and reported in id order.
|
|
750
|
+
const stacks = [];
|
|
751
|
+
const shrinkForSplit = new Map(shrinkLeft);
|
|
752
|
+
const grown = [...shrinkLeft.keys()]
|
|
753
|
+
.sort(byNum)
|
|
754
|
+
.map((id) => ({
|
|
755
|
+
id,
|
|
756
|
+
growth: visibleState(now.get(id)).armies - visibleState(before.get(id)).armies + killsAt(id),
|
|
757
|
+
beside: neighborsOf(g, id).some(hidden),
|
|
758
|
+
}))
|
|
759
|
+
.filter((x) => x.growth > 0);
|
|
760
|
+
for (const { id, growth, beside } of [...grown.filter((x) => !x.beside), ...grown.filter((x) => x.beside)]) {
|
|
761
|
+
let left = growth;
|
|
762
|
+
const moved = [];
|
|
763
|
+
for (const n of [...neighborsOf(g, id)].sort(byNum)) {
|
|
764
|
+
const can = shrinkForSplit.get(n);
|
|
765
|
+
if (!can || !left)
|
|
766
|
+
continue;
|
|
767
|
+
const take = Math.min(can, left);
|
|
768
|
+
shrinkForSplit.set(n, can - take);
|
|
769
|
+
left -= take;
|
|
770
|
+
moved.push({ from: n, armies: take });
|
|
771
|
+
}
|
|
772
|
+
stacks.push({ territoryId: id, growth, moved, fog: beside ? left : 0, deploy: beside ? 0 : left });
|
|
773
|
+
}
|
|
774
|
+
stacks.sort((a, b) => a.territoryId - b.territoryId);
|
|
657
775
|
/**
|
|
658
776
|
* #271 (3): its territories shown with armies on the earlier board and hidden on the later one: what
|
|
659
777
|
* each could have sent (its armies less the guard), the most a capture beside it can have received
|
|
@@ -674,8 +792,6 @@ export function observeSigned(g, board, previous, playerId, rates = {}, context
|
|
|
674
792
|
let arrivals = 0;
|
|
675
793
|
const unseenAttackers = [];
|
|
676
794
|
let unseenAttackerArmies = 0;
|
|
677
|
-
/** Not shown with armies on both boards: armies could have left it unseen. */
|
|
678
|
-
const hidden = (id) => !visibleState(now.get(id)) || !visibleState(before.get(id));
|
|
679
795
|
for (const t of [...board.territories].sort((a, b) => a.territoryId - b.territoryId)) {
|
|
680
796
|
if (!g.territoryById.has(t.territoryId) || !visibleState(t))
|
|
681
797
|
continue;
|
|
@@ -790,16 +906,66 @@ export function observeSigned(g, board, previous, playerId, rates = {}, context
|
|
|
790
906
|
// A board-only reading (neither `expected` nor `most`) has no room at all: a negative total (a
|
|
791
907
|
// stack of its own that shrank into the fog) must not make room for a capture's surplus.
|
|
792
908
|
let room = bound === null && context.most === undefined ? 0 : Math.max(0, (bound ?? Math.max(0, context.most)) - total);
|
|
909
|
+
// #293: under Local Deployment, the territories a bonus pool could have paid into on the turn read
|
|
910
|
+
// (the bonuses it could hold on the earlier board); growth beside the fog elsewhere draws on `freeLeft`.
|
|
911
|
+
const local = rates.localDeployments === true && bound !== null && context.localFree !== undefined;
|
|
912
|
+
const pooledOn = new Set();
|
|
913
|
+
if (local)
|
|
914
|
+
for (const b of g.map.bonuses) {
|
|
915
|
+
if (b.value <= 0)
|
|
916
|
+
continue;
|
|
917
|
+
const ts = bonusTerritories(g, b.id);
|
|
918
|
+
const possible = ts.every((t) => {
|
|
919
|
+
const o = ownerShown(before.get(t))?.owner;
|
|
920
|
+
return o === undefined || (o.kind === 'player' && o.playerId === playerId);
|
|
921
|
+
});
|
|
922
|
+
if (possible)
|
|
923
|
+
for (const t of ts)
|
|
924
|
+
pooledOn.add(t);
|
|
925
|
+
}
|
|
926
|
+
let freeLeft = Math.max(0, context.localFree ?? 0);
|
|
927
|
+
const localCut = [];
|
|
928
|
+
// #293 review: a walled growth's walk draws on the shrink the captures left (`shrinkLeft`, after
|
|
929
|
+
// the capture loop), less what the other grown stacks' splits took (their growth already nets it),
|
|
930
|
+
// in ascending ids: one claim pass, so one neighbour's shrink never offsets a capture and a walk both.
|
|
931
|
+
const walled = (x) => local && x.kind === 'growth' && !pooledOn.has(x.id);
|
|
932
|
+
const walkLeft = new Map(shrinkLeft);
|
|
933
|
+
if (local) {
|
|
934
|
+
const walledIds = new Set(ambiguous.filter(walled).map((x) => x.id));
|
|
935
|
+
for (const st of stacks)
|
|
936
|
+
if (!walledIds.has(st.territoryId))
|
|
937
|
+
for (const m of st.moved)
|
|
938
|
+
walkLeft.set(m.from, Math.max(0, (walkLeft.get(m.from) ?? 0) - m.armies));
|
|
939
|
+
}
|
|
793
940
|
for (const x of [...ambiguous].sort((a, b) => a.id - b.id)) {
|
|
794
941
|
if (bound === null && x.kind === 'growth') {
|
|
795
942
|
lowExtra -= x.armies;
|
|
796
943
|
continue;
|
|
797
944
|
}
|
|
798
|
-
|
|
945
|
+
// #293: a walk from a neighbour in view (the growth split) nets its shrink; the rest is deploy only
|
|
946
|
+
// as far as the free income still reaches.
|
|
947
|
+
const isWalled = walled(x);
|
|
948
|
+
let walk = 0;
|
|
949
|
+
if (isWalled)
|
|
950
|
+
for (const n of [...neighborsOf(g, x.id)].sort(byNum)) {
|
|
951
|
+
const can = walkLeft.get(n);
|
|
952
|
+
if (!can || walk >= x.armies)
|
|
953
|
+
continue;
|
|
954
|
+
const take = Math.min(can, x.armies - walk);
|
|
955
|
+
walkLeft.set(n, can - take);
|
|
956
|
+
walk += take;
|
|
957
|
+
}
|
|
958
|
+
total += walk;
|
|
959
|
+
room = Math.max(0, room - walk);
|
|
960
|
+
const deployed = Math.min(x.armies - walk, room, isWalled ? freeLeft : Infinity);
|
|
961
|
+
if (isWalled)
|
|
962
|
+
freeLeft -= deployed;
|
|
799
963
|
room -= deployed;
|
|
800
964
|
total += deployed;
|
|
801
965
|
lowExtra -= deployed;
|
|
802
|
-
const moved = x.armies - deployed;
|
|
966
|
+
const moved = x.armies - walk - deployed;
|
|
967
|
+
if (isWalled && moved > 0)
|
|
968
|
+
localCut.push(x.id);
|
|
803
969
|
highExtra += moved;
|
|
804
970
|
if (x.kind === 'capture') {
|
|
805
971
|
if (deployed > 0)
|
|
@@ -824,6 +990,7 @@ export function observeSigned(g, board, previous, playerId, rates = {}, context
|
|
|
824
990
|
: { territories: [], floor: 0 };
|
|
825
991
|
const floor = repelled.floor;
|
|
826
992
|
return {
|
|
993
|
+
stacks,
|
|
827
994
|
deploy: Math.max(0, total, floor),
|
|
828
995
|
signed: total,
|
|
829
996
|
counted,
|
|
@@ -834,6 +1001,7 @@ export function observeSigned(g, board, previous, playerId, rates = {}, context
|
|
|
834
1001
|
reinforced,
|
|
835
1002
|
grewFromFog,
|
|
836
1003
|
fogGrowth,
|
|
1004
|
+
...(localCut.length ? { localCut: { free: Math.max(0, context.localFree ?? 0), territories: localCut } } : {}),
|
|
837
1005
|
expected: context.expected ?? null,
|
|
838
1006
|
attacked: [...kills.keys()].sort(byNum),
|
|
839
1007
|
attackKills: [...kills.values()].reduce((n, k) => n + k, 0),
|
|
@@ -1016,6 +1184,11 @@ export function enemyDeployEstimates(g, board, me, settings = {}, previous, trac
|
|
|
1016
1184
|
guard: (settings.oneArmyStandsGuard ?? true) ? 1 : 0,
|
|
1017
1185
|
expected: Math.max(visible, trackBound ?? tracked ?? priorFigure ?? 0),
|
|
1018
1186
|
most: couldEarn,
|
|
1187
|
+
// #293: under Local Deployment, growth beside the fog outside every bonus it could hold is
|
|
1188
|
+
// deploy only up to its free income.
|
|
1189
|
+
...(settings.localDeployments
|
|
1190
|
+
? { localFree: localFreeOn(base, MIN_ENEMY_DEPLOY, when.reinforcement ?? settings.opponentReinforcement, when.turn == null ? null : when.turn - 1) }
|
|
1191
|
+
: {}),
|
|
1019
1192
|
...(when.previousOrders ? { myOrders: when.previousOrders } : {}),
|
|
1020
1193
|
// #271 review: the turn read is the one before the turn planned.
|
|
1021
1194
|
...(bombPossibleOn(settings, when.turn == null ? null : when.turn - 1) ? { bomb: true } : {}),
|
|
@@ -1061,8 +1234,12 @@ export function enemyDeployEstimates(g, board, me, settings = {}, previous, trac
|
|
|
1061
1234
|
for (const n of neighborsOf(g, t))
|
|
1062
1235
|
if (!theirs.has(n))
|
|
1063
1236
|
edge.add(n);
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1237
|
+
const edgeShare = edge.size ? [...edge].filter((n) => ownerShown(seenNow.get(n)) !== undefined).length / edge.size : 0;
|
|
1238
|
+
// #294: each turn of the run weighs what it read of its frontier (this board's edge for a turn
|
|
1239
|
+
// that carries no coverage).
|
|
1240
|
+
const evidence = run.slice(run.length - turns).reduce((n, x) => n + (x.coverage?.share ?? edgeShare), 0);
|
|
1241
|
+
const share = turns ? evidence / turns : edgeShare;
|
|
1242
|
+
const weight = PRIOR_EVIDENCE_TURNS / (PRIOR_EVIDENCE_TURNS + evidence);
|
|
1066
1243
|
const figure = toward + Math.ceil(weight * (priorFigure - toward) - 1e-9);
|
|
1067
1244
|
priorBlend = { prior: priorFigure, toward, turns, share, weight, figure };
|
|
1068
1245
|
}
|
|
@@ -1072,7 +1249,15 @@ export function enemyDeployEstimates(g, board, me, settings = {}, previous, trac
|
|
|
1072
1249
|
// a card (or armies the board misread), never income.
|
|
1073
1250
|
const exact = ownersAll && !opening ? Math.max(0, base + bonusIncome) : null;
|
|
1074
1251
|
const source = exact !== null ? 'exact' : priorUsed !== null && priorUsed > seen ? 'prior' : seenSource;
|
|
1075
|
-
|
|
1252
|
+
// #294: what its tracked figure was read from; while that is little, the estimate never falls below
|
|
1253
|
+
// the tracked figure × LOW_COVERAGE_FACTOR (the fog hid most of where it deploys).
|
|
1254
|
+
const coverage = usable ? trackCoverage(usable.turns.filter((x) => usable.incomeTurns.includes(x.from))) : null;
|
|
1255
|
+
const chosen = source === 'exact' ? exact : source === 'prior' ? priorUsed : seen;
|
|
1256
|
+
const lowFloor = source !== 'exact' && tracked !== null && tracked > visible && coverage !== null && coverage.share < LOW_COVERAGE
|
|
1257
|
+
? Math.min(couldEarn, Math.ceil(tracked * LOW_COVERAGE_FACTOR - 1e-9))
|
|
1258
|
+
: null;
|
|
1259
|
+
const coverageFloor = lowFloor !== null && lowFloor > chosen ? { tracked: tracked, share: coverage.share, factor: LOW_COVERAGE_FACTOR, figure: lowFloor } : null;
|
|
1260
|
+
const income = coverageFloor ? coverageFloor.figure : chosen;
|
|
1076
1261
|
// #164: a Reinforcement card, from the turn the clock says one can be in hand, until a deployment
|
|
1077
1262
|
// above its income is seen; the next card is due a card's capturing turns after the last one
|
|
1078
1263
|
// (pieces carry over while a card is held), never before the turn after the play.
|
|
@@ -1133,6 +1318,8 @@ export function enemyDeployEstimates(g, board, me, settings = {}, previous, trac
|
|
|
1133
1318
|
trackedTurns: usable ? usable.incomeTurns : [],
|
|
1134
1319
|
prior: priorFigure,
|
|
1135
1320
|
priorBlend,
|
|
1321
|
+
coverage,
|
|
1322
|
+
coverageFloor,
|
|
1136
1323
|
priorCap,
|
|
1137
1324
|
fogBeside,
|
|
1138
1325
|
source,
|
|
@@ -7,9 +7,9 @@ import { carriesTeam } from '../../teams.js';
|
|
|
7
7
|
import { searchChains } from '../chains.js';
|
|
8
8
|
import { guaranteedKills } from '../combat.js';
|
|
9
9
|
import { bfsDistances, neighborsOf } from '../graph.js';
|
|
10
|
-
import { enemyDeployReaching,
|
|
10
|
+
import { couldHoldBonusPools, enemyDeployReaching, freeIncome } from '../local-deploy.js';
|
|
11
11
|
import { incomeBasis, LOST_STACK_TURNS } from '../opponents.js';
|
|
12
|
-
import { HIDDEN_POOL_INCOMES, MAX_NAMED_REVEALS, MIN_ENEMY_DEPLOY, openingArmies, ownerShown, visibleState, } from './shared.js';
|
|
12
|
+
import { HIDDEN_POOL_INCOMES, MAX_NAMED_REVEALS, coverageText, LOW_COVERAGE, MIN_ENEMY_DEPLOY, openingArmies, ownerShown, visibleState, } from './shared.js';
|
|
13
13
|
import { territoryIncome } from '../player.js';
|
|
14
14
|
import { simTerritories } from '../turn-sim.js';
|
|
15
15
|
import { byNum } from './util.js';
|
|
@@ -126,29 +126,46 @@ export function threatSources(pc, ps, input) {
|
|
|
126
126
|
if (carriesTeam(p.team) && foe(p.id))
|
|
127
127
|
teamOf.set(p.id, p.team);
|
|
128
128
|
/**
|
|
129
|
-
* Local Deployment (#128): each opponent's bonuses it
|
|
130
|
-
* land only on their own territories. Empty without
|
|
129
|
+
* Local Deployment (#128, #293): each opponent's bonuses it could hold (none of their territories
|
|
130
|
+
* shown with another owner), as deploy pools that land only on their own territories. Empty without
|
|
131
|
+
* Local Deployment or under the override.
|
|
131
132
|
*/
|
|
132
133
|
const enemyPools = new Map();
|
|
133
134
|
// #199: the one Local Deployment bound (local-deploy.ts), shared with check_plan's stress test.
|
|
134
135
|
// A what-if `enemyDeploy` is taken as it stands: no pool bounds it.
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
// #293 review: with per-territory income, income no pool carries (territories the fog hides) may land
|
|
137
|
+
// anywhere, so what an estimate holds beyond every bonus it could hold counts as free; without it, a
|
|
138
|
+
// border faces only the free income and the pools there.
|
|
139
|
+
const perTerritory = (s.bonusArmyPer ?? 0) > 0;
|
|
140
|
+
if (s.localDeployments && !custom) {
|
|
141
|
+
const foes = [...new Set([...state.values()].flatMap((t) => (t.owner.kind === 'player' && foe(t.owner.playerId) ? [t.owner.playerId] : [])))].sort(byNum);
|
|
142
|
+
for (const [p, pools] of couldHoldBonusPools(g, foes, (t) => {
|
|
137
143
|
const o = ownerShown(state.get(t))?.owner;
|
|
138
|
-
return o
|
|
139
|
-
}))
|
|
140
|
-
|
|
141
|
-
|
|
144
|
+
return o === undefined ? undefined : o.kind === 'player' ? o.playerId : null;
|
|
145
|
+
})) {
|
|
146
|
+
enemyPools.set(p, pools);
|
|
147
|
+
const e = estimates.get(p);
|
|
148
|
+
const free = freeIncome(e?.base ?? 0, MIN_ENEMY_DEPLOY, e?.card?.armies ?? 0);
|
|
149
|
+
const pooled = pools.reduce((n, q) => n + q.value, 0);
|
|
150
|
+
const figure = deployOf(p);
|
|
151
|
+
if (perTerritory && figure - pooled > free)
|
|
152
|
+
warnings.push(`Local Deployment with per-territory income: player ${p}'s estimate of ~${figure} is more than its free income +${free} and the +${pooled} of bonuses it could hold, so the ${figure - pooled - free} beyond them is taken as per-territory income the fog hides, which may be deployed anywhere: every border faces it.`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
142
155
|
/**
|
|
143
|
-
* What `player` may deploy on any of `on` (#128): its whole estimate, except under Local
|
|
144
|
-
* Deployment, where a bonus it
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* it holds above its free floor — max({@link MIN_ENEMY_DEPLOY}, base income) — is taken as
|
|
149
|
-
* pooled: the free base always lands anywhere.
|
|
156
|
+
* What `player` may deploy on any of `on` (#128, #293): its whole estimate, except under Local
|
|
157
|
+
* Deployment, where a bonus it could hold pays only into that bonus's territories: its free income
|
|
158
|
+
* (base, never below {@link MIN_ENEMY_DEPLOY}, plus a Reinforcement card) plus the pools that contain
|
|
159
|
+
* one of `on`, never above the estimate ({@link enemyDeployReaching}). A tracked total or a prior above
|
|
160
|
+
* that never lands on one border. `figure` replaces the estimate (an untrusted opponent's, #275).
|
|
150
161
|
*/
|
|
151
|
-
const deployReaching = (player, on
|
|
162
|
+
const deployReaching = (player, on, figure = deployOf(player)) => {
|
|
163
|
+
const pools = enemyPools.get(player);
|
|
164
|
+
if (!pools)
|
|
165
|
+
return figure;
|
|
166
|
+
const e = estimates.get(player);
|
|
167
|
+
return enemyDeployReaching(figure, freeIncome(e?.base ?? 0, MIN_ENEMY_DEPLOY, e?.card?.armies ?? 0), pools, on, perTerritory);
|
|
168
|
+
};
|
|
152
169
|
/**
|
|
153
170
|
* #120: what the owner of enemy territory `t` may add there before my attack lands — its deploy
|
|
154
171
|
* estimate (under Local Deployment, what reaches `t`), or its growth there per turn when larger
|
|
@@ -331,6 +348,8 @@ export function threatForces(pc, ps, src) {
|
|
|
331
348
|
* {@link nextTurnAt} (the frontier and a completion's defensibility) counts its stacks.
|
|
332
349
|
*/
|
|
333
350
|
const returning = pc.truce.lookAheadFoes;
|
|
351
|
+
/** #293: under Local Deployment a next-turn judgement counts the visible stacks one step behind a front. */
|
|
352
|
+
const behindNext = s.localDeployments === true && !pc.custom;
|
|
334
353
|
const foeNext = (p) => foe(p) || returning.has(p);
|
|
335
354
|
const { growthOf, teamOf, deployReaching, holdArmies, bombSized, takesAlone, killsOf, hiddenFoe, hiddenMovable, lostAt, } = src;
|
|
336
355
|
/**
|
|
@@ -399,7 +418,7 @@ export function threatForces(pc, ps, src) {
|
|
|
399
418
|
* ({@link lostAt}), the pool's carrier keeping what they leave of it. With `trend`, its fastest
|
|
400
419
|
* growth there. Shared by {@link forceAt} and the floor tier's armies already next to a border.
|
|
401
420
|
*/
|
|
402
|
-
const stacksAt = (t, gone, trend, nextTurn = false) => {
|
|
421
|
+
const stacksAt = (t, gone, trend, nextTurn = false, behind = false) => {
|
|
403
422
|
const isFoe = nextTurn ? foeNext : foe;
|
|
404
423
|
const byPlayer = new Map();
|
|
405
424
|
// #164: a player's unaccounted armies are one pool, in one place at most: its first hidden stack
|
|
@@ -457,6 +476,29 @@ export function threatForces(pc, ps, src) {
|
|
|
457
476
|
const pool = hiddenMovable(player);
|
|
458
477
|
c.movable = Math.max(viaCarrier, pool - lostElsewhere.reduce((n, l) => n + l.movable, 0));
|
|
459
478
|
}
|
|
479
|
+
// #293: for a next-turn judgement under Local Deployment, its visible stacks one step behind its
|
|
480
|
+
// front (beside one of its stacks next to `t`, not next to `t` themselves) can walk up this turn
|
|
481
|
+
// and attack next turn: each joins the front stack it borders (the lowest id), once.
|
|
482
|
+
if (behind)
|
|
483
|
+
for (const [player, p] of byPlayer) {
|
|
484
|
+
const front = p.stacks.filter((x) => visibleState(state.get(x.id)) !== undefined).map((x) => x.id);
|
|
485
|
+
const seen = new Set([t, ...p.stacks.map((x) => x.id)]);
|
|
486
|
+
const ids = [];
|
|
487
|
+
for (const f of [...front].sort(byNum))
|
|
488
|
+
for (const m of [...neighborsOf(g, f)].sort(byNum)) {
|
|
489
|
+
const st = visibleState(state.get(m));
|
|
490
|
+
if (seen.has(m) || gone(m) || st?.owner.kind !== 'player' || st.owner.playerId !== player || neighborsOf(g, m).includes(t))
|
|
491
|
+
continue;
|
|
492
|
+
seen.add(m);
|
|
493
|
+
const walk = Math.max(0, st.armies - guard) + unitsAt(m);
|
|
494
|
+
if (walk <= 0)
|
|
495
|
+
continue;
|
|
496
|
+
p.stacks.find((x) => x.id === f).movable += walk;
|
|
497
|
+
ids.push(m);
|
|
498
|
+
}
|
|
499
|
+
if (ids.length)
|
|
500
|
+
p.behind = ids.sort(byNum);
|
|
501
|
+
}
|
|
460
502
|
return byPlayer;
|
|
461
503
|
};
|
|
462
504
|
/**
|
|
@@ -472,7 +514,7 @@ export function threatForces(pc, ps, src) {
|
|
|
472
514
|
chain,
|
|
473
515
|
});
|
|
474
516
|
const forceAt = (t, gone, o) => {
|
|
475
|
-
const byPlayer = stacksAt(t, gone, o.trend, o.nextTurn === true);
|
|
517
|
+
const byPlayer = stacksAt(t, gone, o.trend, o.nextTurn === true, o.behind === true);
|
|
476
518
|
// B2 (T2, plan/relations.ts): on a truce hold the partner attacks with its stacks alone — no
|
|
477
519
|
// deploy, no trend, its Multi-Attack chains from the armies standing; `full` asks for the hold
|
|
478
520
|
// the truce relaxed.
|
|
@@ -485,8 +527,11 @@ export function threatForces(pc, ps, src) {
|
|
|
485
527
|
const each = [...byPlayer]
|
|
486
528
|
.sort((a, b) => a[0] - b[0])
|
|
487
529
|
.map(([player, p]) => {
|
|
488
|
-
// #275 (b): a held bonus's border is sized for an untrusted estimate's figure, never below the estimate
|
|
489
|
-
|
|
530
|
+
// #275 (b): a held bonus's border is sized for an untrusted estimate's figure, never below the estimate
|
|
531
|
+
// (#293: under Local Deployment, what of that figure can reach these stacks).
|
|
532
|
+
const deploy = truced === player
|
|
533
|
+
? 0
|
|
534
|
+
: deployReaching(player, [...p.stacks.map((x) => x.id), ...(p.behind ?? [])], Math.max(pc.deployOf(player), untrustedAt(player, t)));
|
|
490
535
|
const growth = truced === player ? 0 : p.growth;
|
|
491
536
|
const movable = p.stacks.reduce((n, x) => n + x.movable, 0);
|
|
492
537
|
const add = Math.max(deploy, growth);
|
|
@@ -568,9 +613,9 @@ export function threatForces(pc, ps, src) {
|
|
|
568
613
|
* from only this turn counted again ({@link foeNext}). The same as threatAt when there is none.
|
|
569
614
|
*/
|
|
570
615
|
const nextTurnAt = (t, gone) => {
|
|
571
|
-
if (!returning.size)
|
|
616
|
+
if (!returning.size && !behindNext)
|
|
572
617
|
return threatAt(t, gone);
|
|
573
|
-
const f = forceAt(t, gone, { trend: true, allPlayers: true, solo: ps.soloHeld.has(t), nextTurn: true });
|
|
618
|
+
const f = forceAt(t, gone, { trend: true, allPlayers: true, solo: ps.soloHeld.has(t), nextTurn: true, behind: behindNext });
|
|
574
619
|
return f ? { player: f.player, threat: f.threat } : null;
|
|
575
620
|
};
|
|
576
621
|
/**
|
|
@@ -795,14 +840,38 @@ export function borderThreats(pc, ps, input, src, forces) {
|
|
|
795
840
|
if (perTerritory && revealed > e.estimate - (e.card?.armies ?? 0))
|
|
796
841
|
warnings.push(`Player ${p}: ${revealed} armies came into view on ${o.reveals.length} ${o.reveals.length === 1 ? 'territory' : 'territories'} (fog reveals, not income); with income per territory, stacks that size say it holds more territories than the ${e.held} in view, so its ~${e.estimate - (e.card?.armies ?? 0)} estimate may be far too low.`);
|
|
797
842
|
rationale.push(`Observed deploy for player ${p}, ${turns}: +${e.observedRaw}/turn over ${o.counted.length} territories visible on both boards (${o.captured.length} captured${o.captured.length ? `, ${o.fromFog.length} from the fog` : ''}); ${o.reveals.length} skipped as fog reveals${o.reveals.length ? ` (${shown}${more}): not shown with an owner and armies last turn (fogged, armies hidden, or not yet picked), so what they hold is not income` : ''}.`);
|
|
843
|
+
// #294: each grown stack's growth split three ways, so the arithmetic can be checked on the board.
|
|
844
|
+
if (o.stacks.length) {
|
|
845
|
+
const grown = [...o.stacks].sort((a, b) => b.growth - a.growth || a.territoryId - b.territoryId);
|
|
846
|
+
const parts = grown.slice(0, MAX_NAMED_REVEALS).map((x) => {
|
|
847
|
+
const why = [
|
|
848
|
+
...x.moved.map((m) => `${m.armies} could be a move from ${label(m.from)} in view`),
|
|
849
|
+
...(x.fog ? [`${x.fog} could have come out of the fog`] : []),
|
|
850
|
+
...(x.deploy ? [`${x.deploy} can only be deploy`] : []),
|
|
851
|
+
];
|
|
852
|
+
return `${label(x.territoryId)} +${x.growth} (${why.join(', ')})`;
|
|
853
|
+
});
|
|
854
|
+
const rest = grown.length > MAX_NAMED_REVEALS ? ` and ${grown.length - MAX_NAMED_REVEALS} more` : '';
|
|
855
|
+
rationale.push(`Player ${p}'s growth by stack, ${turns}: ${parts.join('; ')}${rest}.`);
|
|
856
|
+
}
|
|
798
857
|
// A stack that arrived from the fog by a capture is a threat, never income (#86).
|
|
799
858
|
for (const id of o.fromFog) {
|
|
800
859
|
const where = neighborsOf(g, id).some((n) => mineSet.has(n)) ? 'stack next to you' : 'stack';
|
|
801
860
|
rationale.push(`Player ${p}'s ${where}: ${armiesOf(id)} on ${label(id)} (threat), arrived from the fog by a capture: a move, not income.`);
|
|
802
861
|
}
|
|
803
|
-
// #123: the ambiguous readings, each named with the other way it could read.
|
|
862
|
+
// #123: the ambiguous readings, each named with the other way it could read. #293: under Local
|
|
863
|
+
// Deployment growth outside every bonus it could hold is cut at its free income instead.
|
|
864
|
+
const fogReason = (x) => {
|
|
865
|
+
const twice = `beyond twice the ~${x.expected} it was expected to deploy`;
|
|
866
|
+
const cut = x.localCut;
|
|
867
|
+
if (!cut)
|
|
868
|
+
return twice;
|
|
869
|
+
const local = `in no bonus it could hold: under Local Deployment only its free income +${cut.free} could be deployed there`;
|
|
870
|
+
const all = x.grewFromFog.every((id) => cut.territories.includes(id));
|
|
871
|
+
return all ? local : `${cut.territories.map(label).join(', ')} ${local}; elsewhere ${twice}`;
|
|
872
|
+
};
|
|
804
873
|
if (o.grewFromFog.length) {
|
|
805
|
-
rationale.push(`Player ${p}: ${o.fogGrowth} of its growth on ${o.grewFromFog.map(label).join(', ')} (
|
|
874
|
+
rationale.push(`Player ${p}: ${o.fogGrowth} of its growth on ${o.grewFromFog.map(label).join(', ')} (${fogReason(o)}) is next to the fog: read as a move out of the fog, not income — though it may be income the fog hides (observed +${o.low}–${o.high} either way).`);
|
|
806
875
|
}
|
|
807
876
|
if (o.reinforced.length)
|
|
808
877
|
rationale.push(`Player ${p} took ${o.reinforced.map(label).join(', ')} with more than its visible stack next to ${o.reinforced.length === 1 ? 'it' : 'them'} sent: read as armies deployed on that stack before it attacked (deploy-then-capture), though a stack out of the fog may have joined (observed +${o.low}–${o.high} either way).`);
|
|
@@ -827,7 +896,12 @@ export function borderThreats(pc, ps, input, src, forces) {
|
|
|
827
896
|
if (e.tracked !== null) {
|
|
828
897
|
const track = input.tracks.find((t) => t.playerId === p);
|
|
829
898
|
const used = track.turns.filter((x) => e.trackedTurns.includes(x.from));
|
|
830
|
-
rationale.push(`Tracked income for player ${p}: ~${e.tracked}/turn (${incomeBasis(track)}): ${used.map((x) => `turn ${x.from} +${x.observed}`).join(', ')}, each observed deploy a lower bound under fog; at least its visible base + bonuses ${track.visibleIncome}; used in place of the single-turn observed figure (warapp_track_opponents has the details).`);
|
|
899
|
+
rationale.push(`Tracked income for player ${p}: ~${e.tracked}/turn (${incomeBasis(track)}): ${used.map((x) => `turn ${x.from} +${x.observed}`).join(', ')}, each observed deploy a lower bound under fog${e.coverage ? `, read from ${coverageText(e.coverage)}` : ''}; at least its visible base + bonuses ${track.visibleIncome}; used in place of the single-turn observed figure (warapp_track_opponents has the details).`);
|
|
900
|
+
}
|
|
901
|
+
// #294: a tracked figure read from little of its frontier keeps a floor above it.
|
|
902
|
+
if (e.coverageFloor) {
|
|
903
|
+
const f = e.coverageFloor;
|
|
904
|
+
warnings.push(`Player ${p}'s tracked ~${f.tracked} was read from ${coverageText({ ...e.coverage, hiddenBonuses: 0 }).replace(/\)$/, `, under ${Math.round(LOW_COVERAGE * 100)}%)`)}: the estimate is at least ~${f.tracked} × ${f.factor} = ${f.figure} (the factor is unmeasured), since the fog hid most of where it deploys.`);
|
|
831
905
|
}
|
|
832
906
|
// #164: a Reinforcement card the clock says it may hold, on top of its income.
|
|
833
907
|
if (e.card)
|
|
@@ -862,12 +936,12 @@ export function borderThreats(pc, ps, input, src, forces) {
|
|
|
862
936
|
: `in ${incomePrior.format === 'ffa' ? 'a free-for-all that started even (no teams, every player still in)' : 'a 1v1 that started even'}, an opponent bordering the fog is assumed to earn at least my own income ${incomePrior.myIncome}`}, ${e.priorCap !== null
|
|
863
937
|
? `capped at an even share (1 of ${incomePrior.opponents} opponents) of what the board hides, ${e.priorCap} (all of it would be ${e.couldEarn})`
|
|
864
938
|
: `capped at the most it could earn on this board, ${e.couldEarn}`}${e.priorBlend
|
|
865
|
-
? ` — shrunk toward its ${e.priorBlend.toward === e.tracked ? `tracked ~${e.tracked}` : `visible ${e.priorBlend.toward}`} by the evidence: ${e.priorBlend.turns} observed ${e.priorBlend.turns === 1 ? 'turn' : 'turns'} with ${Math.round(e.priorBlend.share * 100)}% of its edge in view keep ${Math.round(e.priorBlend.weight * 100)}% of the gap from ${e.priorBlend.prior}`
|
|
939
|
+
? ` — shrunk toward its ${e.priorBlend.toward === e.tracked ? `tracked ~${e.tracked}` : `visible ${e.priorBlend.toward}`} by the evidence: ${e.priorBlend.turns} observed ${e.priorBlend.turns === 1 ? 'turn' : 'turns'} with ${Math.round(e.priorBlend.share * 100)}% of its ${e.coverage ? 'frontier read' : 'edge in view'} keep ${Math.round(e.priorBlend.weight * 100)}% of the gap from ${e.priorBlend.prior}`
|
|
866
940
|
: ''}; ${visible}${e.tracked !== null ? `, tracked ~${e.tracked}` : e.observed !== null ? `, observed +${e.observed}/turn` : ''})${withCard}; observed deploys are lower bounds under fog, and it could deploy more.`);
|
|
867
941
|
continue;
|
|
868
942
|
}
|
|
869
943
|
if (e.source === 'tracked') {
|
|
870
|
-
warnings.push(`Enemy deploy estimate for player ${p}: ~${income} (tracked over ${e.trackedTurns.length} observed turns, more than ${visible})${withCard}; it holds income the fog hides, and could deploy more.`);
|
|
944
|
+
warnings.push(`Enemy deploy estimate for player ${p}: ~${income} (tracked over ${e.trackedTurns.length} observed turns, ${e.coverage ? `read from ${coverageText(e.coverage)}; ` : ''}more than ${visible})${withCard}; it holds income the fog hides, and could deploy more.`);
|
|
871
945
|
continue;
|
|
872
946
|
}
|
|
873
947
|
if (e.source === 'observed') {
|
package/dist/analysis/planner.js
CHANGED
|
@@ -235,9 +235,11 @@
|
|
|
235
235
|
// without that bonus — the judgement it gets with no bonus. A rationale line says so ("… as FFA players attack alone (#235)") when the plan
|
|
236
236
|
// keeps it (live: a 23-stack that held against each neighbour alone, even at a 40 deploy, was
|
|
237
237
|
// conceded on the two together and withdrawn as the first order). Teammates (the game's team list) are never a threat, an
|
|
238
|
-
// estimate or a target. Under Local Deployment an opponent
|
|
239
|
-
//
|
|
240
|
-
// plus the pools that contain one of its stacks next to T
|
|
238
|
+
// estimate or a target. Under Local Deployment a bonus an opponent could hold pays only
|
|
239
|
+
// into its own territories (#293, `enemyDeployReaching`): what reaches T is its free income
|
|
240
|
+
// plus the pools that contain one of its stacks next to T, never above its estimate (with
|
|
241
|
+
// per-territory income, plus what the estimate holds beyond every such pool, with a
|
|
242
|
+
// warning). An enemy commander counts in
|
|
241
243
|
// the expected attack too (rule 1h's near miss, kept garrisons).
|
|
242
244
|
// enemyDeploy is estimated per opponent (`enemyDeployEstimates`): base
|
|
243
245
|
// income (the larger of MinimumArmyBonus and, with BonusArmyPer on, its
|
|
@@ -331,9 +333,12 @@
|
|
|
331
333
|
// free-for-all with no teams that gets no prior says why (`game.unevenStart`, a player out — never
|
|
332
334
|
// listed among the opponents beside the fog). The
|
|
333
335
|
// prior shrinks with evidence: with a usable track it keeps PRIOR_EVIDENCE_TURNS / (PRIOR_EVIDENCE_TURNS
|
|
334
|
-
// +
|
|
335
|
-
//
|
|
336
|
+
// + the sum of each turn's frontier coverage (#294, `frontierCoverage`) over its consecutive observed
|
|
337
|
+
// turns up to the newest board, none when the run stopped earlier) of its lead over the larger of
|
|
336
338
|
// its tracked income and its visible income (`priorBlend`), and the warning names both.
|
|
339
|
+
// #294: while the tracked figure, above its visible income, was read from under LOW_COVERAGE (0.5)
|
|
340
|
+
// of its frontier, the estimate is at least tracked × LOW_COVERAGE_FACTOR (1.5), at most what it
|
|
341
|
+
// could earn (`coverageFloor`); the warning says what it was read from. Both unmeasured.
|
|
337
342
|
// In a 1v1 too, so it trades #119's prior back toward tracked figures #119 found 2-3x low:
|
|
338
343
|
// PRIOR_EVIDENCE_TURNS (4) is unmeasured against a finished 1v1.
|
|
339
344
|
// #164, exact income: under a fog setting that shows every owner (`OWNERS_SHOWN_FOG`: No, Light
|
package/dist/analysis/stress.js
CHANGED
|
@@ -46,8 +46,10 @@
|
|
|
46
46
|
// is known; runs that end the same are reported once.
|
|
47
47
|
//
|
|
48
48
|
// Local Deployment (#180, `localDeployments`): every reply's deploy is bounded as the planner
|
|
49
|
-
// bounds it (#128; local-deploy.ts `enemyDeployReaching`): the opponent's free income plus the
|
|
50
|
-
// pools of the bonuses it
|
|
49
|
+
// bounds it (#128, #293; local-deploy.ts `enemyDeployReaching`): the opponent's free income plus the
|
|
50
|
+
// pools of the bonuses it could hold (no member shown with another owner) that contain the territory
|
|
51
|
+
// deployed on; a deploy figure above that never lands on one territory, except with per-territory
|
|
52
|
+
// income (`perTerritoryIncome`), where what no bonus it could hold carries may land anywhere.
|
|
51
53
|
//
|
|
52
54
|
// One turn ahead (`exposedNextTurn`, computed by lookahead.ts, which the planner shares): a territory of mine that no enemy stack touches today can
|
|
53
55
|
// be a border tomorrow. For each stack, each territory beside it that it can take this turn (mine
|
|
@@ -73,9 +75,10 @@ import { bonusTerritories } from './bonuses.js';
|
|
|
73
75
|
import { breaksLuckFree, searchChains } from './chains.js';
|
|
74
76
|
import { COMMANDER_STRENGTH, DEFAULT_DEFENSIVE_KILL_RATE, DEFAULT_OFFENSIVE_KILL_RATE, straightKills } from './combat.js';
|
|
75
77
|
import { neighborsOf } from './graph.js';
|
|
76
|
-
import { enemyDeployReaching,
|
|
78
|
+
import { couldHoldBonusPools, enemyDeployReaching, freeIncome } from './local-deploy.js';
|
|
77
79
|
import { twoStepReaches } from './lookahead.js';
|
|
78
80
|
import { DEFAULT_BASE_INCOME } from './player.js';
|
|
81
|
+
import { ownerShown } from './plan/shared.js';
|
|
79
82
|
import { simTerritories, simulateTurn, } from './turn-sim.js';
|
|
80
83
|
const DEFAULT_MAX_REPLIES = 8;
|
|
81
84
|
/** The chain search's caps (#180), shared with the planner (chains.ts, #199). */
|
|
@@ -122,12 +125,16 @@ export function stressPlan(input) {
|
|
|
122
125
|
const armiesOf = (r, test) => [...r.territories.values()].reduce((n, t) => n + (test(t.owner) ? t.armies : 0), 0);
|
|
123
126
|
const holdsAny = (r, player) => [...r.territories.values()].some((t) => t.owner === player);
|
|
124
127
|
const blindBorders = [...mineEither].filter((id) => neighborsOf(graph, id).some((n) => start.get(n)?.owner === 'unknown')).sort(byNum);
|
|
125
|
-
// Local Deployment (#180): each opponent's
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
+
// Local Deployment (#180, #293): each opponent's bonuses it could hold pay only into their own territories.
|
|
129
|
+
const onBoard = new Map(board.territories.map((t) => [t.territoryId, t]));
|
|
130
|
+
const shownOwner = (t) => {
|
|
131
|
+
const o = ownerShown(onBoard.get(t))?.owner;
|
|
132
|
+
return o === undefined ? undefined : o.kind === 'player' ? o.playerId : null;
|
|
133
|
+
};
|
|
134
|
+
const pools = input.localDeployments ? couldHoldBonusPools(graph, input.opponents.map((o) => o.id), shownOwner) : undefined;
|
|
128
135
|
const deployOn = (opp, on) => {
|
|
129
136
|
const all = Math.max(0, Math.floor(opp.deploy));
|
|
130
|
-
return pools ? enemyDeployReaching(all, opp.base ?? 0, DEFAULT_BASE_INCOME, pools.get(opp.id) ?? [], [on]) : all;
|
|
137
|
+
return pools ? enemyDeployReaching(all, freeIncome(opp.base ?? 0, DEFAULT_BASE_INCOME, opp.card ?? 0), pools.get(opp.id) ?? [], [on], input.perTerritoryIncome === true) : all;
|
|
131
138
|
};
|
|
132
139
|
/** Luck-free: `sent` armies (and a commander, when it goes along) take `t` as it stands. */
|
|
133
140
|
const breaks = (sent, withCommander, t) => breaksLuckFree(sent, withCommander, t, { offensiveKillRate: off, defensiveKillRate: def });
|
|
@@ -1091,6 +1091,9 @@ function baseAssumptions(input, w) {
|
|
|
1091
1091
|
out.push('No start candidates are known (no pickable territories were kept, and no statistics are in use), so no start is guessed: the rest works from what was seen.');
|
|
1092
1092
|
else if (c.source === 'pickable')
|
|
1093
1093
|
out.push(`Start candidates: the ${n} ${plural(n, 'territory', 'territories')} the live board showed as pickable during distribution.`);
|
|
1094
|
+
else if (c.source === 'distribution-mode')
|
|
1095
|
+
out.push(`Start candidates: the ${n} ${plural(n, 'territory', 'territories')} of the map's distribution mode${c.mode !== undefined ? ` ${c.mode}` : ''}, ` +
|
|
1096
|
+
"which dealt the starts automatically among them (read from war.app's map details); the ones nobody was dealt stay neutral.");
|
|
1094
1097
|
else
|
|
1095
1098
|
out.push(`Start candidates: the ${n} ${plural(n, 'territory', 'territories')} players started on in the finished games cached for this map; a start nobody used there is missed.`);
|
|
1096
1099
|
if (c) {
|