@chrischall/warapp-mcp 0.17.0 → 0.19.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/dist/analysis/income-calibration.js +57 -1
- package/dist/analysis/plan/captures.js +26 -3
- package/dist/analysis/plan/dead-advance.js +77 -0
- package/dist/analysis/plan/deploy-estimates.js +38 -2
- package/dist/analysis/plan/estimates.js +1 -0
- package/dist/analysis/plan/fogged-break.js +86 -0
- package/dist/analysis/plan/holds.js +28 -9
- package/dist/analysis/plan/orders.js +39 -2
- package/dist/analysis/plan/report.js +3 -0
- package/dist/analysis/plan/shared.js +18 -0
- package/dist/analysis/plan/state.js +1 -0
- package/dist/analysis/plan/targets.js +14 -4
- package/dist/analysis/plan/threats.js +6 -1
- package/dist/analysis/plan/withdraw.js +2 -1
- package/dist/analysis/planner.js +174 -11
- package/dist/bundle.js +844 -192
- package/dist/my-games.js +50 -10
- package/dist/tools/calibration.js +5 -2
- package/dist/tools/check-plan.js +4 -1
- package/dist/tools/my-games.js +13 -5
- package/dist/tools/pace.js +25 -8
- package/dist/tools/push.js +15 -1
- package/dist/tools/stress-opponents.js +1 -0
- package/dist/tools/turn.js +5 -0
- package/dist/version.js +1 -1
- package/manifest.json +1 -1
- package/package.json +3 -3
- package/server.json +2 -2
|
@@ -8,6 +8,7 @@ import { byNum } from './util.js';
|
|
|
8
8
|
import { denialsOf, emptyEnemiesOf, fogVacated, VACATED_FOG_ARMIES } from './vacated.js';
|
|
9
9
|
import { breakableBonuses } from './siege.js';
|
|
10
10
|
import { ALL_IN_VALUE_TURNS } from './bonus-attempts.js';
|
|
11
|
+
import { foggedBreakables } from './fogged-break.js';
|
|
11
12
|
/** The targets, the frontier costs and the bonus plans, in the order planPass defined them. */
|
|
12
13
|
export function targetsPhase(pc, ps, input, threats, hd) {
|
|
13
14
|
const c0 = breakTargets(pc, input);
|
|
@@ -19,7 +20,9 @@ export function targetsPhase(pc, ps, input, threats, hd) {
|
|
|
19
20
|
// pass 3 may take, each judged once on the board as it stands.
|
|
20
21
|
const denials = denialsOf(pc);
|
|
21
22
|
const emptyEnemies = emptyEnemiesOf(pc, input.previousBoard, threats.reinforcementAt, (t) => c4.targets.has(t) || c4.repulsed.has(t) || pc.truce.noTarget(t));
|
|
22
|
-
|
|
23
|
+
// #593: the bonuses an earlier plan of this turn advanced while conceding another member of them.
|
|
24
|
+
const deadBonuses = input.deadAdvance ?? new Map();
|
|
25
|
+
return { ...c4, denials, emptyEnemies, deadBonuses };
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
28
|
* #430 (owner decision of 2026-11-22): a retake of a held bonus's lost members costs at most this many
|
|
@@ -38,6 +41,13 @@ export function breakTargets(pc, input) {
|
|
|
38
41
|
// is that opponent's or hidden. Such a break is "probable".
|
|
39
42
|
const breakable = balanced ? breakableBonuses(g, state, foe, input.tracks) : [];
|
|
40
43
|
const breakMember = new Set(breakable.flatMap((b) => bonusTerritories(g, b.bonusId)));
|
|
44
|
+
// #593: in a 1v1, the opponent's bonuses behind the fog (a member in view its and beside mine, no member
|
|
45
|
+
// shown with another owner), and on the opening turns the ones it is one neutral short of. Their members
|
|
46
|
+
// in view are break targets (`foggedMember`), scored and sized by rule 4a (plan/fogged-break.ts).
|
|
47
|
+
const foggedBreaks = balanced && pc.profile.format === '1v1'
|
|
48
|
+
? foggedBreakables(g, state, foe, mineSet, new Set(breakable.map((b) => b.bonusId)), pc.turnNow)
|
|
49
|
+
: [];
|
|
50
|
+
const foggedMember = new Set(foggedBreaks.flatMap((b) => b.members));
|
|
41
51
|
// ---- counter-attacks (under `balanced`, #72) ----
|
|
42
52
|
// An enemy stack next to me that shrank since the previous board by attacking me: visible on
|
|
43
53
|
// both boards under the same owner (F1, #69), every neighbour visible on both, one of them a
|
|
@@ -91,14 +101,14 @@ export function breakTargets(pc, input) {
|
|
|
91
101
|
counterAt.set(id, { player: p, from: was.armies, to: st.armies, costNow, costThen });
|
|
92
102
|
}
|
|
93
103
|
}
|
|
94
|
-
return { breakable, breakMember, counterAt };
|
|
104
|
+
return { breakable, breakMember, counterAt, foggedBreaks, foggedMember };
|
|
95
105
|
}
|
|
96
106
|
/** Rule 2: the targets next to mine, and the lead steps into a bonus on an army lead (#203). */
|
|
97
107
|
export function captureTargets(pc, ps, input, threats, prev) {
|
|
98
108
|
const { g, foe, profile, auto, goal, balanced, territories: state, label, mineSet, unitsAt, uncounted, uncountedKind, defenceAt, bonusTs, costAt, noSplit, leadLever, leadText, } = pc;
|
|
99
109
|
const { warnings, rationale } = ps;
|
|
100
110
|
const { reinforcementAt, hiddenFoe, hiddenMovable, hiddenPool } = threats;
|
|
101
|
-
const { breakMember, counterAt } = prev;
|
|
111
|
+
const { breakMember, counterAt, foggedMember } = prev;
|
|
102
112
|
// ---- 2. targets ----
|
|
103
113
|
const targets = new Map();
|
|
104
114
|
/**
|
|
@@ -332,7 +342,7 @@ export function captureTargets(pc, ps, input, threats, prev) {
|
|
|
332
342
|
continue;
|
|
333
343
|
}
|
|
334
344
|
const enemy = st.owner.kind === 'player';
|
|
335
|
-
if (enemy && goal !== 'complete-bonus' && !(balanced && (breakMember.has(t) || counterAt.has(t))) && !pileMembers.has(t) && !retakeMembers.has(t)) {
|
|
345
|
+
if (enemy && goal !== 'complete-bonus' && !(balanced && (breakMember.has(t) || counterAt.has(t) || foggedMember.has(t))) && !pileMembers.has(t) && !retakeMembers.has(t)) {
|
|
336
346
|
if (!leadStepsOn || unitsAt(t) > 0 || droppedMembers.has(t) || !g.map.bonuses.some((b) => b.value > 0 && bonusTs.get(b.id).includes(t)))
|
|
337
347
|
continue;
|
|
338
348
|
const defenders = defenceAt(t);
|
|
@@ -1060,7 +1060,12 @@ export function borderThreats(pc, ps, input, src, forces) {
|
|
|
1060
1060
|
if (e.tracked !== null) {
|
|
1061
1061
|
const track = input.tracks.find((t) => t.playerId === p);
|
|
1062
1062
|
const used = track.turns.filter((x) => e.trackedTurns.includes(x.from));
|
|
1063
|
-
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).`);
|
|
1063
|
+
rationale.push(`Tracked income for player ${p}: ~${e.trackCalibration ? e.trackCalibration.raw : 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).`);
|
|
1064
|
+
}
|
|
1065
|
+
// #568: the tracked figure raised by past games' calibration in its coverage band.
|
|
1066
|
+
if (e.trackCalibration) {
|
|
1067
|
+
const c = e.trackCalibration;
|
|
1068
|
+
warnings.push(`Player ${p}'s tracked income ~${c.raw} is raised to ~${c.figure} (#568, draft): past games' tracker read ${c.geoMean.toFixed(2)}× the true income at this frontier coverage (${c.band}, ${c.n} samples), divided by its square root (${c.factor.toFixed(2)}).`);
|
|
1064
1069
|
}
|
|
1065
1070
|
// #427: a card play the tracker read as income, taken out of its figure.
|
|
1066
1071
|
if (e.cardInTrack) {
|
|
@@ -193,7 +193,7 @@ export function withdrawals(pc, ps, book, threats, hb, prev) {
|
|
|
193
193
|
export function reconsiderAndGarrison(pc, ps, book, threats, hb, prev) {
|
|
194
194
|
const { g, guarded, reserve, paybackTurns, label, bonusName, mine, mineSet, unitsAt, toTake, myCommanders } = pc;
|
|
195
195
|
const { warnings, rationale, deployed, locked, captured, moves } = ps;
|
|
196
|
-
const { orderOf, deploy, pools, valueCache, cutCache, breachCache, opensCache, valueOf } = book;
|
|
196
|
+
const { orderOf, deploy, pools, valueCache, cutCache, breachCache, opensCache, hubCache, valueOf } = book;
|
|
197
197
|
const local = pools !== null && pools.bonuses.length > 0;
|
|
198
198
|
const { borders } = threats;
|
|
199
199
|
const { conceded, kept, garrisoned } = hb;
|
|
@@ -211,6 +211,7 @@ export function reconsiderAndGarrison(pc, ps, book, threats, hb, prev) {
|
|
|
211
211
|
cutCache.clear();
|
|
212
212
|
breachCache.clear();
|
|
213
213
|
opensCache.clear();
|
|
214
|
+
hubCache.clear();
|
|
214
215
|
if (!conceded.size)
|
|
215
216
|
return;
|
|
216
217
|
for (const t of [...conceded].sort(byNum)) {
|
package/dist/analysis/planner.js
CHANGED
|
@@ -549,7 +549,16 @@
|
|
|
549
549
|
// loss opens (none containing it, none its cut or breach counts), with a line ("… is the only way in
|
|
550
550
|
// to …"); and a territory whose loss opens held bonuses guards against a stack two steps away
|
|
551
551
|
// (#172) like a bonus member, so the gate behind a conceded border keeps a hold — save when a stack
|
|
552
|
-
// steps into that conceded border and makes it hold (#257), which cuts the reach.
|
|
552
|
+
// steps into that conceded border and makes it hold (#257), which cuts the reach. #593: a hub — a member of
|
|
553
|
+
// a positive bonus of HUB_MIN_MEMBERS (4)+ members I hold in full (a bonus completed this turn too, once rule
|
|
554
|
+
// 1c counts the captures) that borders HUB_DEGREE (0.75) or more of its other members — also protects
|
|
555
|
+
// HUB_WEIGHT (0.6) × that bonus's value (its fall takes the rest, which comes back only member by member),
|
|
556
|
+
// counted once per bonus in rule 1h's unit worth, with a line ("… borders N of bonus …'s M other members: its
|
|
557
|
+
// fall takes the rest … (#593)"); no cut, breach or opens counts its own bonus. A unit that pays only for its hub
|
|
558
|
+
// share is funded first like any other, even before a larger completion, and gets a contested unit's
|
|
559
|
+
// floor before the captures (#118), so it is floored, never conceded bare, when it cannot be held whole
|
|
560
|
+
// (owner, 2026-11-27).
|
|
561
|
+
// Its hold cost is the fewest
|
|
553
562
|
// deploys making `armiesToTake(armies + d) > threat`. Every border facing one
|
|
554
563
|
// opponent is sized for that opponent's whole deploy (#69): it picks where to land
|
|
555
564
|
// after I commit, so that is each border's worst case, and a sure hold of several
|
|
@@ -830,6 +839,11 @@
|
|
|
830
839
|
// absorbed by its own neighbours' growth) and is now cheaper to take than it
|
|
831
840
|
// was; never under `expand`/`defend`). Fogged or unknown neighbours are never attacked — they
|
|
832
841
|
// produce a warning.
|
|
842
|
+
// #593: in a 1v1 under `balanced`, a member in view of an opponent bonus behind the fog (no member
|
|
843
|
+
// shown with another owner, one fogged, that member its with armies and beside mine) is a probable
|
|
844
|
+
// break target, and on turns 2–4 so is one of a bonus it is one neutral short of (worth
|
|
845
|
+
// ONE_SHORT_WEIGHT × the bonus); rule 4a sizes either for its defenders plus `partialDeploy` (its
|
|
846
|
+
// deploy estimate split over its territories beside my land), the rest as a break (plan/fogged-break.ts).
|
|
833
847
|
// #430 (owner decision of 2026-11-22): under `balanced`, the opponents' territories that retake
|
|
834
848
|
// a bonus I held in full on `previousBoard` are bonus targets too, in every format, when the retake
|
|
835
849
|
// completes it this turn (every missing member in view, beside mine), costs at most RETAKE_VALUE_TURNS
|
|
@@ -1238,6 +1252,15 @@
|
|
|
1238
1252
|
// 2, the `balanced` advance slots, #439's stage), pass 3 and rule 5b; never the bonus's own members, a
|
|
1239
1253
|
// focused bonus, completions, holds, breaks, counters, the 1v1 race, strikes, rule 4e, 4g or 4h. What is
|
|
1240
1254
|
// bound may still attack with the armies on my other territories. A "#319 binds the deploys" line says so.
|
|
1255
|
+
// #593 (plan/dead-advance.ts): no expansion capture (`tryExpand`: pass 2, the `balanced` advance slots,
|
|
1256
|
+
// pass 3, #439's stage, rule 5b) advances only bonuses whose other member I hold this plan concedes,
|
|
1257
|
+
// unless it completes one, is focused, is no-loss (#426), is land a static seat left, is a step of a bonus
|
|
1258
|
+
// this turn's captures could complete, breaks the bonus for the foe attacking a conceded member (owner,
|
|
1259
|
+
// 2026-11-27: his own member, or the one he would still lack), or every attack on it leaves a conceded border with no deploy; its
|
|
1260
|
+
// armies stay for the next candidate, with a "(#593)" line. A concession made after the capture, or a
|
|
1261
|
+
// completable bonus the plan leaves incomplete, is caught on the finished plan: planTurn plans again with
|
|
1262
|
+
// those bonuses carried (`PlanInput.deadAdvance`, `planAlive`, at most DEAD_PASSES times). Rule 4e's
|
|
1263
|
+
// never-stand-still fallback is not bound.
|
|
1241
1264
|
// 3b. One surplus per territory (#121). A border that holds at the start of the turn (its armies
|
|
1242
1265
|
// beat its visible threat, rule 1) and is not conceded keeps what holds it, as my commander's
|
|
1243
1266
|
// territory does (rule 1k): a capture from it spends only its armies above that, plus deploys
|
|
@@ -1672,9 +1695,10 @@ import { neighborsOf } from './graph.js';
|
|
|
1672
1695
|
import { forecastBorder, mainFront } from './exchange.js';
|
|
1673
1696
|
import { byNum, pct } from './plan/util.js';
|
|
1674
1697
|
import { SIEGE_BREAK_WEIGHT } from './plan/siege.js';
|
|
1698
|
+
import { ONE_SHORT_WEIGHT, partialDeploy } from './plan/fogged-break.js';
|
|
1675
1699
|
import { ALL_IN_VALUE_TURNS, bonusVerdicts, DROP_TURNS, judgeAttempts } from './plan/bonus-attempts.js';
|
|
1676
1700
|
import { planJabs } from './plan/jabs.js';
|
|
1677
|
-
import { BREAK_WEIGHT, MIN_EXPANSION_SHARE, PLAIN_EXPANSION_LOSS, SECOND_FRONT_LEAD, SECOND_FRONT_SIMILAR, captureCost, } from './plan/shared.js';
|
|
1701
|
+
import { BREAK_WEIGHT, MIN_EXPANSION_SHARE, PLAIN_EXPANSION_LOSS, SECOND_FRONT_LEAD, SECOND_FRONT_SIMILAR, captureCost, visibleState, } from './plan/shared.js';
|
|
1678
1702
|
import { emptyPlan, noteEstimates, planContext } from './plan/estimates.js';
|
|
1679
1703
|
import { neutralizeSeats, seatTerritories, staticSeats } from './static-seats.js';
|
|
1680
1704
|
import { deployBook } from './plan/orders.js';
|
|
@@ -1688,7 +1712,8 @@ import { completedMembers } from './plan/completed.js';
|
|
|
1688
1712
|
import { chooseStrikeStack, leadStrikes, spendStrikeStack, strikesPhase } from './plan/strike.js';
|
|
1689
1713
|
import { contestedBonuses } from './plan/stockpile.js';
|
|
1690
1714
|
import { warnIdleBesideFree } from './plan/free-capture.js';
|
|
1691
|
-
import { afterLeftoverCaptures, onlyNoLoss, plainEconomy, plainEligible } from './plan/after-leftover.js';
|
|
1715
|
+
import { afterLeftoverCaptures, noLossNeutral, onlyNoLoss, plainEconomy, plainEligible } from './plan/after-leftover.js';
|
|
1716
|
+
import { deadAdvanceOf } from './plan/dead-advance.js';
|
|
1692
1717
|
import { fundFromSecondSizing } from './plan/second-sizing.js';
|
|
1693
1718
|
import { leftoverDeploy } from './plan/leftover.js';
|
|
1694
1719
|
import { fillSecondLine, guardOffRaids } from './plan/guard-off.js';
|
|
@@ -1749,7 +1774,7 @@ export function planTurn(input) {
|
|
|
1749
1774
|
// territories are planned as neutrals (static armies), and it is no opponent anywhere below.
|
|
1750
1775
|
const seats = staticSeats(input.game?.players, input.game?.endRules, input.me);
|
|
1751
1776
|
const held = seatTerritories(input.board, seats);
|
|
1752
|
-
const plan =
|
|
1777
|
+
const plan = planAlive(withoutStaticSeats(input, seats));
|
|
1753
1778
|
for (const [p, n] of [...held].sort((a, b) => a[0] - b[0]))
|
|
1754
1779
|
plan.rationale.push(`Player ${p} is out (${seats.get(p)}) and no AI plays its seat: it deploys and attacks nothing, so its ${n} territor${n === 1 ? 'y is' : 'ies are'} planned as neutrals — static armies to take, no hold needed beside them (#270).`);
|
|
1755
1780
|
return plan;
|
|
@@ -1788,6 +1813,38 @@ function withoutStaticSeats(input, seats) {
|
|
|
1788
1813
|
...(input.game && opening ? { game: { ...input.game, opening: new Map([...opening].filter(([p]) => !seats.has(p))) } } : {}),
|
|
1789
1814
|
};
|
|
1790
1815
|
}
|
|
1816
|
+
/** #593: per plan, the bonuses an expansion capture it kept advances though it concedes another member of them. */
|
|
1817
|
+
const deadOutcome = new WeakMap();
|
|
1818
|
+
/** #593: at most this many plans again, each carrying the dead bonuses the ones before found. */
|
|
1819
|
+
const DEAD_PASSES = 3;
|
|
1820
|
+
/**
|
|
1821
|
+
* #593: never advance a bonus whose other member the same plan concedes. The capture passes refuse such an
|
|
1822
|
+
* advance as they go (plan/dead-advance.ts), but a concession can come after the capture (the greedy concedes
|
|
1823
|
+
* pending holds as it runs): when the finished plan still advances one, it is planned again with that bonus
|
|
1824
|
+
* carried, so its armies go to the next candidate from the start, until no plan does (at most DEAD_PASSES times).
|
|
1825
|
+
*/
|
|
1826
|
+
function planAlive(input) {
|
|
1827
|
+
let plan = planPushed(input);
|
|
1828
|
+
const carried = new Map(input.deadAdvance ?? []);
|
|
1829
|
+
for (let i = 0; i < DEAD_PASSES; i++) {
|
|
1830
|
+
const found = deadOutcome.get(plan);
|
|
1831
|
+
if (!found?.size)
|
|
1832
|
+
return plan;
|
|
1833
|
+
let grew = false;
|
|
1834
|
+
for (const [id, ms] of found) {
|
|
1835
|
+
const was = carried.get(id) ?? [];
|
|
1836
|
+
const next = [...new Set([...was, ...ms])].sort(byNum);
|
|
1837
|
+
if (next.length > was.length) {
|
|
1838
|
+
carried.set(id, next);
|
|
1839
|
+
grew = true;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
if (!grew)
|
|
1843
|
+
return plan;
|
|
1844
|
+
plan = planPushed({ ...input, deadAdvance: new Map(carried) });
|
|
1845
|
+
}
|
|
1846
|
+
return plan;
|
|
1847
|
+
}
|
|
1791
1848
|
/** #298: per plan, the all-in pushes its pass sized (plan/targets.ts), by bonus id. */
|
|
1792
1849
|
const allInOutcome = new WeakMap();
|
|
1793
1850
|
/**
|
|
@@ -2044,7 +2101,7 @@ function planPass(input, pass) {
|
|
|
2044
2101
|
const { acting, conceded, concedeUnaffordable, floorOrConcede, fundNearMiss, fundUnit, garrisonCompleted, heldBorders, heldStack, hold, holds, keepFor, kept, keptShort, leftFor, mayComplete, mayHold, noteRecent, pendingLocks, reconsider, settleContested, twoStepBound, twoStepKeep, uneconomic, units, withdraw, overCap, chargeCap, concedeCapped, } = hd;
|
|
2045
2102
|
// ---- 2. targets, 4d. frontier cost, bonus scoring, #101 (plan/targets.ts) ----
|
|
2046
2103
|
const tgt = targetsPhase(pc, ps, input, threats, hd);
|
|
2047
|
-
const { breakable, counterAt, targets, leadSteps, landScoreCost, offence, skipOffence, plans, ratio, committing, byCloseness, retakeChecks, retakeWarning, } = tgt;
|
|
2104
|
+
const { breakable, counterAt, targets, leadSteps, landScoreCost, offence, skipOffence, plans, ratio, committing, byCloseness, retakeChecks, retakeWarning, foggedBreaks, } = tgt;
|
|
2048
2105
|
// #215 review: rule 1a's triage (run with the strikes, below) leaves pending a border in a bonus
|
|
2049
2106
|
// these plans may complete this turn.
|
|
2050
2107
|
for (const p of plans)
|
|
@@ -2053,6 +2110,8 @@ function planPass(input, pass) {
|
|
|
2053
2110
|
// ---- R3, No-Split, capture helper, 3a. combined, passes 1 and 2 (plan/captures.ts) ----
|
|
2054
2111
|
const caps = capturesPhase(pc, ps, pass, book, threats, hd, tgt);
|
|
2055
2112
|
const { strikes, worstCase, defendersAt, tryCapture, snapshot, complete, tryExpand, advance } = caps;
|
|
2113
|
+
/** #593: the fogged breaks taken this turn, by target, with the partial deploy each was sized for. */
|
|
2114
|
+
const partialSized = new Map();
|
|
2056
2115
|
/** #439: single-territory bonuses two moves away, each with its neutral in between. */
|
|
2057
2116
|
const stages = twoMoveStages(pc, tgt);
|
|
2058
2117
|
/** #416 part 4: while #319 fires, other advances and pass 3 wait for the nearest bonus's steps (plan/spread-bind.ts). */
|
|
@@ -2227,14 +2286,17 @@ function planPass(input, pass) {
|
|
|
2227
2286
|
});
|
|
2228
2287
|
// Capturing a member of a breakable bonus: what survives it, and whether that holds next turn.
|
|
2229
2288
|
// A break is sized to land (#72): its score leaves out what holding it would need.
|
|
2230
|
-
const breakOption = (t) => {
|
|
2289
|
+
const breakOption = (t, partial) => {
|
|
2231
2290
|
// #201: the FFA leader's break is sized to land for certain against its owner's one deploy.
|
|
2232
|
-
|
|
2291
|
+
// #593: a break behind the fog, against a partial deploy (its owner's estimate split over its fronts).
|
|
2292
|
+
const landing = ffaLeader ? defenceAt(t) + reinforcementAt(t) : partial !== undefined ? defenceAt(t) + partial : undefined;
|
|
2233
2293
|
const cost = (landing !== undefined ? captureCost(landing, s) : null) ?? targets.get(t).cost;
|
|
2234
2294
|
const survivors = cost - straightKills(defenceAt(t), rates.defensiveKillRate);
|
|
2235
2295
|
const counter = counterThreat(t);
|
|
2236
2296
|
const take = toTake(survivors);
|
|
2237
|
-
|
|
2297
|
+
// #593: a fogged break's score pays for the partial deploy it is sized for.
|
|
2298
|
+
const scoreCost = partial !== undefined ? Math.max(1, landScoreCost(t) + cost - targets.get(t).cost) : landScoreCost(t);
|
|
2299
|
+
return { t, cost, survivors, counter, take, survives: take === null || take > counter, scoreCost };
|
|
2238
2300
|
};
|
|
2239
2301
|
/**
|
|
2240
2302
|
* What a strike is worth (#72), in income terms like a hold's worth: the income the opponent
|
|
@@ -2320,7 +2382,7 @@ function planPass(input, pass) {
|
|
|
2320
2382
|
/** The member a break of `b` takes: its cheapest visible member (#72: a break only has to land), then the least frontier, then id. */
|
|
2321
2383
|
const breakOptionOf = (b) => bonusTerritories(g, b.bonusId)
|
|
2322
2384
|
.filter((t) => targets.has(t))
|
|
2323
|
-
.map(breakOption)
|
|
2385
|
+
.map((t) => breakOption(t))
|
|
2324
2386
|
.sort((a, b) => a.cost - b.cost || a.scoreCost - b.scoreCost || a.t - b.t)[0];
|
|
2325
2387
|
// #421 (owner decision, 2026-11-20): on a stockpile (`pc.pile`) the turn spends by breaking the strongest
|
|
2326
2388
|
// opponent's cheapest visible bonus (every member in view: never a probable one) — ahead of every other
|
|
@@ -2347,7 +2409,7 @@ function planPass(input, pass) {
|
|
|
2347
2409
|
// Its cheapest visible member (#72: a break only has to land), then the least frontier, then id.
|
|
2348
2410
|
const options = bonusTerritories(g, b.bonusId)
|
|
2349
2411
|
.filter((t) => targets.has(t))
|
|
2350
|
-
.map(breakOption)
|
|
2412
|
+
.map((t) => breakOption(t))
|
|
2351
2413
|
.sort((a, b) => a.cost - b.cost || a.scoreCost - b.scoreCost || a.t - b.t);
|
|
2352
2414
|
const o = options[0];
|
|
2353
2415
|
if (!o)
|
|
@@ -2414,6 +2476,90 @@ function planPass(input, pass) {
|
|
|
2414
2476
|
}),
|
|
2415
2477
|
});
|
|
2416
2478
|
}
|
|
2479
|
+
// #593 (items 2 and 5a): in a 1v1, a bonus behind the fog a member in view of which is the opponent's
|
|
2480
|
+
// (plan/fogged-break.ts), and on the opening turns one it is a neutral short of, scored as rule 4a scores
|
|
2481
|
+
// a break (a denial at ONE_SHORT_WEIGHT of the bonus) and sized for a partial deploy: the opponent's
|
|
2482
|
+
// estimate on the target split over its territories in view beside my land. #240's sure size still
|
|
2483
|
+
// applies (tryCapture); #298's dropped members are never tried.
|
|
2484
|
+
/** The opponent's territories in view beside my land (its fronts, #593). */
|
|
2485
|
+
const frontsOf = (p) => [...state].filter(([id, st]) => visibleState(st)?.owner.kind === 'player' && st.owner.playerId === p && neighborsOf(g, id).some((n) => mineSet.has(n))).length;
|
|
2486
|
+
for (const fb of foggedBreaks) {
|
|
2487
|
+
const fronts = frontsOf(fb.player);
|
|
2488
|
+
const sizing = (t) => {
|
|
2489
|
+
const estimate = reinforcementAt(t);
|
|
2490
|
+
return { estimate, partial: partialDeploy(estimate, fronts) };
|
|
2491
|
+
};
|
|
2492
|
+
const o = fb.members
|
|
2493
|
+
.filter((t) => targets.has(t) && !tgt.droppedMembers.has(t))
|
|
2494
|
+
.map((t) => breakOption(t, sizing(t).partial))
|
|
2495
|
+
.sort((a, b) => a.cost - b.cost || a.scoreCost - b.scoreCost || a.t - b.t)[0];
|
|
2496
|
+
if (!o)
|
|
2497
|
+
continue;
|
|
2498
|
+
const { estimate, partial } = sizing(o.t);
|
|
2499
|
+
const value = fb.shortOf !== undefined ? fb.value * ONE_SHORT_WEIGHT : fb.value;
|
|
2500
|
+
const worth = strikeWorth(value, o);
|
|
2501
|
+
const score = worth / Math.max(1, o.scoreCost);
|
|
2502
|
+
const split = fronts > 1 ? `split over the ${fronts} territories of its beside my land, #593` : `its only territory beside my land, so the whole of it, #593`;
|
|
2503
|
+
const sized = `sized to land if player ${fb.player} deploys up to ${partial} of its ~${estimate} there first (${split})`;
|
|
2504
|
+
const head = fb.shortOf !== undefined
|
|
2505
|
+
? `denies player ${fb.player} bonus ${bonusName(fb.bonusId)} (+${fb.value}), one territory short of complete (${label(fb.shortOf)} still neutral; opening strike, #593)`
|
|
2506
|
+
: `breaks probable enemy bonus ${bonusName(fb.bonusId)} (+${fb.value} from player ${fb.player}; ${fb.probable})`;
|
|
2507
|
+
const reason = `${head}, ${sized}`;
|
|
2508
|
+
rationale.push(fb.shortOf !== undefined
|
|
2509
|
+
? `Player ${fb.player} is one territory short of bonus ${bonusName(fb.bonusId)} (+${fb.value}): ${label(o.t)} in view is its, beside my land, and ${label(fb.shortOf)} is still neutral; on an opening turn a strike there denies it (worth ${ONE_SHORT_WEIGHT} × the bonus) (#593).`
|
|
2510
|
+
: `Player ${fb.player} probably holds bonus ${bonusName(fb.bonusId)} (+${fb.value}): ${label(o.t)} in view is its, beside my land, and its ${fb.fogged} fogged member${fb.fogged > 1 ? 's' : ''} could all be its (#593).`);
|
|
2511
|
+
offence.set(`break:${fb.bonusId}`, { bonusId: fb.bonusId, target: o.t, kind: 'break', cost: o.cost, value: round2(worth), taken: false, why: head });
|
|
2512
|
+
candidates.push({
|
|
2513
|
+
kind: 'break',
|
|
2514
|
+
score,
|
|
2515
|
+
cost: o.cost,
|
|
2516
|
+
id: fb.bonusId,
|
|
2517
|
+
value,
|
|
2518
|
+
focus: false,
|
|
2519
|
+
borders: analyzeBonus(g, fb.bonusId).borderTerritoryIds.length,
|
|
2520
|
+
target: o.t,
|
|
2521
|
+
owner: fb.player,
|
|
2522
|
+
run: spend(() => {
|
|
2523
|
+
if (captured.has(o.t) || bonusTerritories(g, fb.bonusId).some((x) => captured.has(x)))
|
|
2524
|
+
return;
|
|
2525
|
+
// Sized for its defenders plus the partial deploy, a combined capture included (its softeners
|
|
2526
|
+
// wear that many down); no worst case once taken: #120 may still size it for the whole deploy,
|
|
2527
|
+
// and its "assumes" warning gives the win chance against it.
|
|
2528
|
+
const tg = targets.get(o.t);
|
|
2529
|
+
const raised = o.cost > tg.cost;
|
|
2530
|
+
const was = worstCase.get(o.t);
|
|
2531
|
+
if (raised)
|
|
2532
|
+
targets.set(o.t, { ...tg, cost: o.cost });
|
|
2533
|
+
worstCase.set(o.t, Math.max(was ?? 0, defenceAt(o.t) + partial));
|
|
2534
|
+
const ok = tryCapture(o.t, reason);
|
|
2535
|
+
if (raised)
|
|
2536
|
+
targets.set(o.t, tg);
|
|
2537
|
+
if (!ok) {
|
|
2538
|
+
if (was === undefined)
|
|
2539
|
+
worstCase.delete(o.t);
|
|
2540
|
+
else
|
|
2541
|
+
worstCase.set(o.t, was);
|
|
2542
|
+
return;
|
|
2543
|
+
}
|
|
2544
|
+
// Sent enough for the whole deploy (one front, or #240's sure size): a worst case, no warning.
|
|
2545
|
+
const sent = moves.filter((m) => m.kind === 'attack' && m.to === o.t).reduce((n, m) => n + m.armies, 0);
|
|
2546
|
+
const whole = costAt(o.t, defenceAt(o.t) + estimate);
|
|
2547
|
+
if (whole !== null && sent >= whole && !combined.has(o.t))
|
|
2548
|
+
worstCase.set(o.t, Math.max(was ?? 0, defenceAt(o.t) + estimate));
|
|
2549
|
+
else {
|
|
2550
|
+
if (was === undefined)
|
|
2551
|
+
worstCase.delete(o.t);
|
|
2552
|
+
else
|
|
2553
|
+
worstCase.set(o.t, was);
|
|
2554
|
+
const assumes = `Attack on enemy ${label(o.t)} assumes its owner does not reinforce it first.`;
|
|
2555
|
+
if (was === undefined && !warnings.includes(assumes))
|
|
2556
|
+
warnings.push(assumes);
|
|
2557
|
+
}
|
|
2558
|
+
partialSized.set(o.t, partial);
|
|
2559
|
+
ps.anchor ??= moves[moves.length - 1].from;
|
|
2560
|
+
}),
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2417
2563
|
// Counter-attacks (#72): a stack that shrank fighting me, scored like a break that breaks no
|
|
2418
2564
|
// bonus (the armies its owner must spend to retake it). It is already fighting me (it
|
|
2419
2565
|
// attacked me, or held off my attack), so it is never a second front.
|
|
@@ -3359,7 +3505,10 @@ function planPass(input, pass) {
|
|
|
3359
3505
|
const d = defenceAt(m.to);
|
|
3360
3506
|
const full = costAt(m.to, d + extra);
|
|
3361
3507
|
const aim = chanceAt(m.to);
|
|
3362
|
-
|
|
3508
|
+
// #593: a fogged break sized for a partial deploy says so.
|
|
3509
|
+
const part = partialSized.get(m.to);
|
|
3510
|
+
const sizedFor = part !== undefined && part > 0 && part < extra ? ` (sized for a partial deploy of ${part} (#593))` : '';
|
|
3511
|
+
warnings[w] = `Attack on enemy ${label(m.to)} assumes its owner does not reinforce it first${sizedFor}: if player ${st.owner.playerId} deploys its ~${extra} there, ${m.armies} attack ${d + extra} (win chance ${pct(chanceOf(m.armies, d + extra))})${full !== null ? `; ${full} would ${aim >= 1 ? 'be sure' : `reach ${pct(aim)}`}` : ''}.`;
|
|
3363
3512
|
}
|
|
3364
3513
|
// ---- #361: single-army jabs from the armies still idle beyond each hold (plan/jabs.ts) ----
|
|
3365
3514
|
const jabsOn = pc.opts.jabs ?? pc.siege !== undefined;
|
|
@@ -3454,6 +3603,20 @@ function planPass(input, pass) {
|
|
|
3454
3603
|
if (!heldBorders.has(m.id))
|
|
3455
3604
|
unheld.add(m.id);
|
|
3456
3605
|
runOutcome.set(plan, { bareSteps: [...caps.bareTaken].filter(gone).sort(byNum), held, unheld });
|
|
3606
|
+
// #593: an expansion capture the finished plan keeps though it concedes another member of every bonus it
|
|
3607
|
+
// advances (conceded after the capture was made): planTurn plans again with those bonuses carried.
|
|
3608
|
+
{
|
|
3609
|
+
const dead = new Map();
|
|
3610
|
+
const after = book.heldNow();
|
|
3611
|
+
for (const t of [...ps.expanded].filter(gone).sort(byNum)) {
|
|
3612
|
+
if (caps.givenUp(t) || noLossNeutral(pc, tgt, t))
|
|
3613
|
+
continue;
|
|
3614
|
+
for (const d of deadAdvanceOf(pc, t, after, conceded, new Map()) ?? [])
|
|
3615
|
+
dead.set(d.bonusId, [...new Set([...(dead.get(d.bonusId) ?? []), ...d.members])].sort(byNum));
|
|
3616
|
+
}
|
|
3617
|
+
if (dead.size)
|
|
3618
|
+
deadOutcome.set(plan, dead);
|
|
3619
|
+
}
|
|
3457
3620
|
if (tgt.allInTries.size)
|
|
3458
3621
|
allInOutcome.set(plan, tgt.allInTries);
|
|
3459
3622
|
if (pc.strikeShare > 0)
|