@chrischall/warapp-mcp 0.5.0 → 0.7.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 +133 -8
- package/dist/analysis/accept-surrender.js +20 -2
- package/dist/analysis/calibrate.js +1 -0
- package/dist/analysis/card-support.js +177 -17
- package/dist/analysis/card-threats.js +126 -14
- package/dist/analysis/chat-advice.js +182 -0
- package/dist/analysis/chat-blocks.js +106 -0
- package/dist/analysis/chat-intent.js +559 -0
- package/dist/analysis/chat-read.js +159 -0
- package/dist/analysis/decision-replay.js +279 -0
- package/dist/analysis/decision-truth.js +146 -0
- package/dist/analysis/finished-game.js +62 -3
- package/dist/analysis/game-lessons.js +15 -10
- package/dist/analysis/hold-diff.js +3 -1
- package/dist/analysis/income-trend.js +38 -0
- package/dist/analysis/intel.js +75 -0
- package/dist/analysis/opens.js +64 -0
- package/dist/analysis/opponent-profile.js +121 -10
- package/dist/analysis/opponents.js +246 -20
- package/dist/analysis/outlook.js +360 -15
- package/dist/analysis/picks.js +91 -12
- package/dist/analysis/plan/after-leftover.js +4 -1
- package/dist/analysis/plan/bonus-attempts.js +105 -0
- package/dist/analysis/plan/capture-instead.js +116 -0
- package/dist/analysis/plan/captures.js +49 -7
- package/dist/analysis/plan/conceded-out.js +13 -2
- package/dist/analysis/plan/estimates.js +203 -30
- package/dist/analysis/plan/guard-off.js +2 -1
- package/dist/analysis/plan/holds.js +110 -9
- package/dist/analysis/plan/jabs.js +113 -0
- package/dist/analysis/plan/leftover.js +393 -8
- package/dist/analysis/plan/orders.js +76 -4
- package/dist/analysis/plan/relations.js +135 -2
- package/dist/analysis/plan/report.js +69 -3
- package/dist/analysis/plan/second-sizing.js +133 -0
- package/dist/analysis/plan/shared.js +279 -27
- package/dist/analysis/plan/siege.js +303 -0
- package/dist/analysis/plan/stand-still.js +9 -5
- package/dist/analysis/plan/state.js +8 -0
- package/dist/analysis/plan/stockpile.js +104 -0
- package/dist/analysis/plan/strike.js +39 -7
- package/dist/analysis/plan/targets.js +256 -110
- package/dist/analysis/plan/threats.js +148 -10
- package/dist/analysis/plan/transfers.js +57 -6
- package/dist/analysis/plan/two-move.js +70 -0
- package/dist/analysis/plan/vacated.js +124 -2
- package/dist/analysis/planner.js +527 -49
- package/dist/analysis/profile.js +13 -2
- package/dist/analysis/since-last.js +18 -5
- package/dist/analysis/stress.js +8 -2
- package/dist/board.js +36 -2
- package/dist/bonus-attempt-store.js +55 -0
- package/dist/build-id.js +106 -0
- package/dist/bundle.js +54138 -41059
- package/dist/cards.js +7 -5
- package/dist/chat-automation.js +22 -0
- package/dist/chat.js +35 -1
- package/dist/client.js +14 -0
- package/dist/commerce.js +111 -0
- package/dist/decision-log.js +1093 -0
- package/dist/finished-store.js +5 -1
- package/dist/index.js +9 -1
- package/dist/lessons-store.js +322 -21
- package/dist/live.js +43 -0
- package/dist/move-order.js +64 -3
- package/dist/normalize.js +17 -0
- package/dist/open-games.js +36 -16
- package/dist/outlook-log.js +42 -1
- package/dist/profile-store.js +12 -2
- package/dist/protocol/methods.js +62 -5
- package/dist/protocol/rpc.js +8 -0
- package/dist/relations-store.js +38 -4
- package/dist/review-export.js +198 -0
- package/dist/siege-store.js +49 -0
- package/dist/state-bundle.js +584 -0
- package/dist/state-cli.js +71 -0
- package/dist/strategy/notes.js +56 -0
- package/dist/team-cards.js +25 -0
- package/dist/tools/accept-surrender.js +23 -9
- package/dist/tools/award.js +20 -2
- package/dist/tools/card-advice.js +93 -28
- package/dist/tools/card-plays.js +2 -2
- package/dist/tools/card-support-advice.js +37 -7
- package/dist/tools/chat-advice.js +330 -0
- package/dist/tools/chat-inbox.js +19 -4
- package/dist/tools/chat.js +106 -17
- package/dist/tools/check-plan.js +68 -12
- package/dist/tools/commerce-deploy.js +33 -0
- package/dist/tools/common.js +31 -0
- package/dist/tools/decision-capture.js +459 -0
- package/dist/tools/end-of-game.js +151 -21
- package/dist/tools/game-kind.js +92 -0
- package/dist/tools/how-lost.js +7 -2
- package/dist/tools/index.js +10 -0
- package/dist/tools/join-game.js +10 -4
- package/dist/tools/live-context.js +6 -0
- package/dist/tools/live.js +10 -1
- package/dist/tools/map-curves.js +73 -0
- package/dist/tools/notifications.js +4 -3
- package/dist/tools/opponents.js +2 -0
- package/dist/tools/past-games.js +74 -8
- package/dist/tools/picks.js +61 -10
- package/dist/tools/profile-hook.js +62 -3
- package/dist/tools/profile-opponents.js +4 -0
- package/dist/tools/push.js +2 -2
- package/dist/tools/relations.js +139 -0
- package/dist/tools/scout.js +16 -2
- package/dist/tools/state.js +232 -0
- package/dist/tools/strategy.js +3 -3
- package/dist/tools/stress-opponents.js +7 -2
- package/dist/tools/surrender-pending.js +10 -1
- package/dist/tools/surrender.js +18 -3
- package/dist/tools/survival.js +11 -3
- package/dist/tools/team-brief.js +2 -2
- package/dist/tools/team.js +12 -3
- package/dist/tools/turn.js +643 -76
- package/dist/tools/where.js +3 -1
- package/dist/version.js +1 -1
- package/manifest.json +32 -3
- package/mint.yaml +37 -4
- package/package.json +4 -4
- package/server.json +20 -2
- package/skills/warapp-mcp/SKILL.md +73 -17
package/dist/analysis/planner.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
// 5. the leftover deploy, 3b's short borders (#121) ........... plan/leftover.ts
|
|
19
19
|
// 5b. a neutral the leftover pays for (#218) ................. plan/after-leftover.ts
|
|
20
20
|
// 6. transfers, #125 staging ................................. plan/transfers.ts
|
|
21
|
+
// #277: a held bonus funded from a second sure sizing ......... plan/second-sizing.ts
|
|
21
22
|
// 7. move order, rule 1s's Order Priority ..................... plan/move-order.ts
|
|
22
23
|
// 1w. my commander walks, its transit hold (#274) ............. plan/commander.ts
|
|
23
24
|
// 7r. reports, the offence report, 1i (#109), the final plan .. plan/report.ts
|
|
@@ -61,7 +62,8 @@
|
|
|
61
62
|
// returned as `profile`: format (1v1 / ffa / teams), phase (opening / expansion /
|
|
62
63
|
// contact / late; in an FFA, contact only when an enemy stack as it stands can take a
|
|
63
64
|
// territory of mine or most of my borders face enemies, #132), standing (my income against the strongest opponent's estimate:
|
|
64
|
-
// ahead ≥ AHEAD_RATIO×, behind ≤ BEHIND_RATIO
|
|
65
|
+
// ahead ≥ AHEAD_RATIO×, behind ≤ BEHIND_RATIO× (#287: in a 1v1 also when the opponent's armies in
|
|
66
|
+
// view are ≥ OUTNUMBERED_RATIO× mine), unknown when fog hides most of the
|
|
65
67
|
// board) and the settings that shape strategy. #276: with One Army Must Stand Guard off it
|
|
66
68
|
// names that case first (`guard`, `guardCase`: what it means for interior defence) and its note
|
|
67
69
|
// leads `notes`; with the guard on it is absent, so a guard-on plan is unchanged
|
|
@@ -74,6 +76,10 @@
|
|
|
74
76
|
// more than CONCEDE_FACTOR × its worth, so the captures go first) is held whole before the
|
|
75
77
|
// first advance when what is left covers it (best worth per army first, never weighed
|
|
76
78
|
// against spreading: `settleContested(true)`); the rest stays contested as before.
|
|
79
|
+
// #417, the race for vacated land: while a static seat's land is untaken, its captures
|
|
80
|
+
// costing at most VACATED_MAX_COST (`raceTargets`, the 2-defender price of its fogged land
|
|
81
|
+
// included) rank ahead of that rule — after the held-bonus units and my commander's hold,
|
|
82
|
+
// before every other candidate (`raceTier`); the contested units are settled before the first.
|
|
77
83
|
// 2. FFA with two or more opponents left: no second front — a break (also from a held
|
|
78
84
|
// border, rule 4a) against a player that can take no member of a bonus I hold next
|
|
79
85
|
// turn and loses nothing to this turn's strike / finishing off is skipped when a
|
|
@@ -197,6 +203,20 @@
|
|
|
197
203
|
// income every turn, breaks the opponent's biggest stack beside it soonest (its owner
|
|
198
204
|
// deploying there every turn), when that is not the border holding the most armies and
|
|
199
205
|
// breaks sooner than it ("Strike stack on … (#201): no border can strike this turn; …").
|
|
206
|
+
// #421: outside a 1v1 (not a siege, not No-Split, not `defend`), a stockpile on a flat income —
|
|
207
|
+
// my armies in view at least STOCKPILE_TURNS turns of my income while `incomeTrend` is flat —
|
|
208
|
+
// builds the same stack facing the opponent beside me whose visible armies mine outnumber
|
|
209
|
+
// STOCKPILE_LEAD× (fewest first, then id; never an income estimate), never on my commander's
|
|
210
|
+
// territory, and spends it as above ("Stockpile (#421): …").
|
|
211
|
+
// #421, the strike share: in contact on a flat income (a stack built as above), STRIKE_SHARE
|
|
212
|
+
// of the income is held out of captures for the stack (holds keep their exact need first),
|
|
213
|
+
// unless that lowers next income (`planShare`) ("Strike share (#421): …").
|
|
214
|
+
// #421, the break spend: on the pile (`pc.pile`), rule 4a runs the break of the strongest
|
|
215
|
+
// opponent's cheapest visible bonus before every other capture, never skipped as a second
|
|
216
|
+
// front ("Stockpile spend (#421): …").
|
|
217
|
+
// #421, the all-in completion: on the pile, each contested bonus is planned all-in through
|
|
218
|
+
// #298's push (`planPushed`, `PlanInput.stockpileAllIn`), kept only when taken whole
|
|
219
|
+
// ("Stockpile all-in (#421): …").
|
|
200
220
|
// 3d. Decided (#201): given `options.outlook` (#178) reporting winning or losing, the game is
|
|
201
221
|
// decided, and every payback test (PAYBACK_TURNS everywhere it appears in these rules)
|
|
202
222
|
// counts the turns it has left instead: the loser's strength over the winner's income a
|
|
@@ -241,6 +261,16 @@
|
|
|
241
261
|
// per-territory income, plus what the estimate holds beyond every such pool, with a
|
|
242
262
|
// warning). An enemy commander counts in
|
|
243
263
|
// the expected attack too (rule 1h's near miss, kept garrisons).
|
|
264
|
+
// #420 (owner decision of 2026-11-20, "One opponent's deploy"): an opponent deploys its income in
|
|
265
|
+
// one place, so its full deploy sizes only its single most valuable border of mine (by protected
|
|
266
|
+
// value, then its movable armies beside it, then id); its other borders of mine are sized at its
|
|
267
|
+
// stacks beside them plus its largest top-up seen (`OpponentTrack.topUp`: the most one of its
|
|
268
|
+
// stacks beside my land grew in one turn on the tracker's live boards), never above the full deploy
|
|
269
|
+
// (`oneBorder` in plan/threats.ts, read by `forceAt`), with a "deploys its ~D in one place (#420)"
|
|
270
|
+
// line. Not with no top-up seen (no track), under `enemyDeploy`, on my commander's territory, for an
|
|
271
|
+
// untrusted estimate (#275) there, or for an opponent facing a single border of mine.
|
|
272
|
+
// A quiet neighbour (`PlanInput.quiet`, #420's P1 amendment: 10+ contact turns at an attack rate of
|
|
273
|
+
// 0.1 or less, no attack on me since) has every border so sized, its most valuable included.
|
|
244
274
|
// enemyDeploy is estimated per opponent (`enemyDeployEstimates`): base
|
|
245
275
|
// income (the larger of MinimumArmyBonus and, with BonusArmyPer on, its
|
|
246
276
|
// visible territories / BonusArmyPer) plus the bonuses that player
|
|
@@ -290,7 +320,14 @@
|
|
|
290
320
|
// guard or beside no other player), never a hold an order `moves` does not carry touched (a
|
|
291
321
|
// Transfer Only, Attack Only or percentage order in `sent`, a card play in `cards`; orders cached
|
|
292
322
|
// before those were kept read nothing), and on a turn an opponent may have played a Bomb
|
|
293
|
-
// (`bombPossibleOn`, `PlannerSettings.bombFrom`) after taking out half the hold, rounded up.
|
|
323
|
+
// (`bombPossibleOn`, `PlannerSettings.bombFrom`) after taking out half the hold, rounded up. #418
|
|
324
|
+
// (owner decision of 2026-11-20: proof may always raise an estimate): a capture with every source
|
|
325
|
+
// army in view (`captureFloor`) bounds it from below too — what stands on the target plus the
|
|
326
|
+
// attacker its last defender surely killed, and at least the fewest armies that kill every defender
|
|
327
|
+
// however the attack was split, beyond what its stacks beside the target could send (less the
|
|
328
|
+
// guard) — counted when the target was a neutral or mine, every neighbour showed its owner and its
|
|
329
|
+
// own their armies, no other player borders it, Multi-Attack is off, and (beside or out of my land)
|
|
330
|
+
// my orders are known in full and none touches it; a Bomb it may have played halves the defenders. A
|
|
294
331
|
// capture of a neutral in view beside the fog that needed more attackers (`fewestAttackersToTake`)
|
|
295
332
|
// than its stacks in view sent (`unseenAttackers`) reads what stands there beyond those as deploy
|
|
296
333
|
// within #123's bound, the rest a move out of the fog. Its stacks in view beside a capture, hidden
|
|
@@ -336,9 +373,15 @@
|
|
|
336
373
|
// + the sum of each turn's frontier coverage (#294, `frontierCoverage`) over its consecutive observed
|
|
337
374
|
// turns up to the newest board, none when the run stopped earlier) of its lead over the larger of
|
|
338
375
|
// its tracked income and its visible income (`priorBlend`), and the warning names both.
|
|
339
|
-
// #
|
|
340
|
-
// of its frontier, the estimate is
|
|
341
|
-
//
|
|
376
|
+
// #368 (owner decision of 2026-11-19, replacing #294's floor of tracked × 1.5): while the tracked
|
|
377
|
+
// figure was read from under LOW_COVERAGE (0.5) of its frontier, the estimate is the midpoint between
|
|
378
|
+
// its lower bound (visible, tracked, a rising trend's next step) and its upper bound (the fog prior,
|
|
379
|
+
// else what it could earn), moved toward the lower bound as the coverage nears LOW_COVERAGE
|
|
380
|
+
// (`thinEvidence`); the warning names both bounds. Unmeasured.
|
|
381
|
+
// #419 (owner decision of 2026-11-20): with the fog prior on, that upper bound is the larger of the
|
|
382
|
+
// prior and the pace past winners set at this turn (`PlanGameContext.mapPace`, `FogPace`: this map's
|
|
383
|
+
// median winner over 3+ games of the format and settings, else my income × the format's median winner ÷
|
|
384
|
+
// mine), capped and scaled as the prior; the warning names the basis (`thinEvidence.pace`).
|
|
342
385
|
// In a 1v1 too, so it trades #119's prior back toward tracked figures #119 found 2-3x low:
|
|
343
386
|
// PRIOR_EVIDENCE_TURNS (4) is unmeasured against a finished 1v1.
|
|
344
387
|
// #164, exact income: under a fog setting that shows every owner (`OWNERS_SHOWN_FOG`: No, Light
|
|
@@ -461,12 +504,26 @@
|
|
|
461
504
|
// (fully visible, fewer territories than mine, deploy below my income) that
|
|
462
505
|
// threatens it now is never conceded economically (the rationale says so once its
|
|
463
506
|
// hold is deployed); under `balanced` its hold goes first.
|
|
507
|
+
// #420 (owner decision of 2026-11-20, "Total hold cap", `holdCapOf` in plan/holds.ts): plain holds
|
|
508
|
+
// take at most HOLD_CAP_EVEN (50%) of my income when even or ahead and HOLD_CAP_BEHIND (70%) when
|
|
509
|
+
// the profile reads me behind (rounded down). A held bonus's own gate (rule 1h's units) and my
|
|
510
|
+
// commander's hold (rule 1k) are funded first, outside it, and count nothing toward it. A plain hold
|
|
511
|
+
// past it — rule 1a's `defend` triage, rule 4a's greedy hold, a unit member judged alone, a deferred
|
|
512
|
+
// hold — is conceded with a "cannot be held within the hold cap (#420 …)" line (its armies may still
|
|
513
|
+
// attack out); a hold that breaks its one threat (rule 4a's hold-and-break) runs first, as a capture,
|
|
514
|
+
// and counts. The leftover's revival may still hold a capped border after all. Off under a `defend`
|
|
515
|
+
// goal the caller gave, and with `options.holdCap: false` (tests of earlier hold rules use it).
|
|
464
516
|
// 1a. Triage (every goal). Each threatened border's protected value is the sum
|
|
465
517
|
// of my complete bonuses containing it, plus incomplete bonuses containing it
|
|
466
518
|
// that I would lose all access to without it, plus (#122) its share of every other
|
|
467
519
|
// incomplete bonus containing it that I am building — value × the members I hold ÷ its
|
|
468
520
|
// size, one decimal, when every missing member is a visible neutral and finishing it passes
|
|
469
|
-
// rule 4's economy tests (PAYBACK_TURNS, WASTELAND_FACTOR)
|
|
521
|
+
// rule 4's economy tests (PAYBACK_TURNS, WASTELAND_FACTOR); #298: or when the missing members
|
|
522
|
+
// are visible neutrals and visible foe territories, one of them a foe's movable stack beside the
|
|
523
|
+
// border that arrived since `previousBoard` (taken from me, or grown there, read only where that
|
|
524
|
+
// board showed it): an enemy stack roaming inside the bonus that can reach the border. On the
|
|
525
|
+
// same economy tests over what
|
|
526
|
+
// stands there now, so the members it can reach are garrisoned — plus the per-territory
|
|
470
527
|
// income it carries (each bonus counted once). Its worth adds the armies a
|
|
471
528
|
// hold saves, in income terms (armies / PAYBACK_TURNS): a top-up that keeps a
|
|
472
529
|
// big stack is worth paying even for a small bonus (live, a 60-army border
|
|
@@ -484,7 +541,13 @@
|
|
|
484
541
|
// fog, that no other front reaches within two steps, and that are hollow (none of mine beside
|
|
485
542
|
// them, themselves included, holds the largest visible foe stack beside the border plus its
|
|
486
543
|
// owner's deploy), plus their per-territory income; what #235 cuts off is not counted twice. A
|
|
487
|
-
// rationale line names it ("… alone shields … (#275)").
|
|
544
|
+
// rationale line names it ("… alone shields … (#275)"). #291, guard on or off: a gate — a border
|
|
545
|
+
// every route from an enemy or the fog takes to reach territories of mine behind it
|
|
546
|
+
// (src/analysis/opens.ts `opensBehind`) — also protects OPENS_WEIGHT (0.5) of the held bonuses its
|
|
547
|
+
// loss opens (none containing it, none its cut or breach counts), with a line ("… is the only way in
|
|
548
|
+
// to …"); and a territory whose loss opens held bonuses guards against a stack two steps away
|
|
549
|
+
// (#172) like a bonus member, so the gate behind a conceded border keeps a hold — save when a stack
|
|
550
|
+
// steps into that conceded border and makes it hold (#257), which cuts the reach. Its hold cost is the fewest
|
|
488
551
|
// deploys making `armiesToTake(armies + d) > threat`. Every border facing one
|
|
489
552
|
// opponent is sized for that opponent's whole deploy (#69): it picks where to land
|
|
490
553
|
// after I commit, so that is each border's worst case, and a sure hold of several
|
|
@@ -556,7 +619,12 @@
|
|
|
556
619
|
// better use. It is floored (below) and waits for the captures; once they are planned
|
|
557
620
|
// (before rule 1c, and under `defend` after passes 1–2), it is held whole if what is left
|
|
558
621
|
// covers it (rationale "… (more than …), and nothing else this turn uses those armies"),
|
|
559
|
-
// else spread (below) when floored, else conceded whole as before.
|
|
622
|
+
// else spread (below) when floored, else conceded whole as before. #285 (plan/capture-instead.ts): just before
|
|
623
|
+
// that, an enemy territory whose fall leaves contested members bordering no enemy, fog or hidden territory
|
|
624
|
+
// is captured from the one of them needing the least deploy, sized for its owner's deploy there (the
|
|
625
|
+
// estimate the holds use, #368's middle figure; #120), when that deploy is at most HOLD_CREDIT_TURNS (3)
|
|
626
|
+
// × the hold costs it saves (owner decisions of 2026-11-19); those members are then held ("Take …
|
|
627
|
+
// rather than hold …"). Under Local Deployment (#103) those tests (and its score)
|
|
560
628
|
// use the cost net of the bonus's own pool, max(0, cost − pool): the pool can be
|
|
561
629
|
// deployed nowhere else. A unit that pays is funded before any capture that
|
|
562
630
|
// completes no bonus (advances, breaks, other expansion, unless focused): under `defend` with the
|
|
@@ -730,7 +798,10 @@
|
|
|
730
798
|
// while one capture makes another complete. R3 does not refuse it (the armies would otherwise
|
|
731
799
|
// leave a border the plan gives up), and a completed bonus keeps the border (rule 1c). Live, the
|
|
732
800
|
// last empty members of a bonus stood beside a conceded border: one was taken, the other refused
|
|
733
|
-
// ("a conceded border never attacks out for a capture that only costs nothing").
|
|
801
|
+
// ("a conceded border never attacks out for a capture that only costs nothing"). #286: a border
|
|
802
|
+
// rule 1c will keep (a positive bonus containing it already completed by this turn's captures)
|
|
803
|
+
// is no source: its armies would not withdraw (live, a kept +2 member sent 3 into an uneconomic
|
|
804
|
+
// bonus and ended 1 army short of its hold).
|
|
734
805
|
// 1i. Income at risk (#109). `expected.nextIncome` is next turn's income if every territory
|
|
735
806
|
// the plan keeps and captures is held — the borders it concedes included, withdrawn from
|
|
736
807
|
// or not. A conceded border is not kept, so the plan also reports
|
|
@@ -806,6 +877,17 @@
|
|
|
806
877
|
// without it would (`repulsedSurplus`: the sure size's surplus over the plain one still on the
|
|
807
878
|
// source; one that would fall without it stays short), and the leftover put there is not kept
|
|
808
879
|
// from the #226 margin; the strike stack reports such an attack as sized for the deploy.
|
|
880
|
+
// #298, all-in or drop (plan/bonus-attempts.ts; owner defaults of 2026-11-20): with
|
|
881
|
+
// `input.bonusAttempts` (the attempt memory, src/bonus-attempt-store.ts) a contested bonus whose
|
|
882
|
+
// expected completion failed on FAILED_ATTEMPTS (2) consecutive turns is pushed all-in once
|
|
883
|
+
// (`planPushed`: focused, every missing member in view and beside mine, each one a player holds
|
|
884
|
+
// sized for its defenders plus its owner's deploy, #368's middle figure, taken at that size or not
|
|
885
|
+
// at all, as #240's sure size; the whole at most ALL_IN_VALUE_TURNS (2) × its value and my income)
|
|
886
|
+
// when that plan takes every missing member; otherwise it is planned again with the bonus dropped
|
|
887
|
+
// for DROP_TURNS (3) turns, this one included, as it is after an all-in that failed: no bonus
|
|
888
|
+
// scoring, and rule 4e's contact fallback, #203's lead steps and #272's attack out of a conceded
|
|
889
|
+
// border never go into its missing members. `bonusPush` and a rationale line say which. No memory,
|
|
890
|
+
// or no verdict: the plan is byte-identical.
|
|
809
891
|
// #226, a margin: once the transfers (rule 6) have moved what they move, an attack on a
|
|
810
892
|
// player's territory whose owner may deploy there (not a combined capture; not under No-Split,
|
|
811
893
|
// which sends the whole stack already) takes the armies still on its source beyond what holds
|
|
@@ -898,7 +980,10 @@
|
|
|
898
980
|
// income may lose at most PLAIN_EXPANSION_LOSS (a rationale line "Do not expand into …"
|
|
899
981
|
// names an affordable one refused). The leftover's expansion stack (rule 5) is a capture's
|
|
900
982
|
// finisher, never a combined capture's softener.
|
|
901
|
-
// 4a. Balanced (the default goal
|
|
983
|
+
// 4a. Balanced (the default goal; `siege` too, #382: the siege target's breaks weigh
|
|
984
|
+
// SIEGE_BREAK_WEIGHT × a 1v1 break and are never a second front, its other territories are
|
|
985
|
+
// no target until the trigger fires, and rule 0p.3c's strike stack faces it — plan/siege.ts).
|
|
986
|
+
// Instead of passes 1–2, every candidate is
|
|
902
987
|
// scored as income per army and taken greedily (focus first, then score, then
|
|
903
988
|
// cheaper, fewer bonus borders, id): a hold (protected value / hold cost),
|
|
904
989
|
// completing or advancing a bonus (value / remaining cost), breaking an enemy
|
|
@@ -952,7 +1037,7 @@
|
|
|
952
1037
|
// would then exceed the next income and the start-of-turn hold cost (in rule 4e's
|
|
953
1038
|
// contact/late fallback it is a cost instead, #114); a warning ("Frontier grows faster than
|
|
954
1039
|
// income") names it, and also fires when the plan's frontier ends so. #281: never a territory a
|
|
955
|
-
// static seat left (rule 0s) that costs at most VACATED_MAX_COST and borders a live opponent's
|
|
1040
|
+
// static seat left (rule 0s) that costs at most VACATED_MAX_COST (3, #417: what 2 defenders cost) and borders a live opponent's
|
|
956
1041
|
// stack able to take it with what stands there (`denialOf`): that border comes either way, so
|
|
957
1042
|
// it is let through, a line ("Take … though it faces player …") says so, and pass 3 ranks it by
|
|
958
1043
|
// capture cost plus the frontier without its own hold need, less the denial (1 + PAYBACK_TURNS ×
|
|
@@ -961,6 +1046,10 @@
|
|
|
961
1046
|
// may fall to 0 or below; a plain capture's never goes below one army), and a member of an
|
|
962
1047
|
// uneconomic bonus of mine is still eligible for it. Each denial is judged once per plan
|
|
963
1048
|
// (`denialsOf`, `Targets.denials`). It spends only what stands above its source's hold (#121).
|
|
1049
|
+
// #417, the breach force: land a static seat left whose armies the fog hides is a target at
|
|
1050
|
+
// VACATED_FOG_ARMIES defenders (`fogVacated`, read by `defenceAt`), pass 3 takes vacated land outside
|
|
1051
|
+
// a negative bonus even in an uneconomic bonus, and rule 6 keeps the idle armies beside such land still
|
|
1052
|
+
// untaken and cheap (`breachOf`) until it is taken.
|
|
964
1053
|
// #281, the owner's extension (2026-11-16; guard off, not under No-Split, `balanced`/`defend`):
|
|
965
1054
|
// a live opponent's own territory beside mine in view at 0 (no special unit) whose owner holds
|
|
966
1055
|
// no positive bonus it is in (#165 breaks those) and that was not mine on `previousBoard` (#276
|
|
@@ -980,6 +1069,13 @@
|
|
|
980
1069
|
// territory my commander walks from — all that stands there is its transit hold (rule 1w,
|
|
981
1070
|
// `commanderTransit` sizes it on the whole stack); a commander that stays keeps its worst-case
|
|
982
1071
|
// hold through `keepOf`, as from any capture.
|
|
1072
|
+
// #297, a 1v1 only: every border of mine facing the opponent is a gate, each sized for its stack plus the
|
|
1073
|
+
// opponent's whole deploy, since that one deploy floats to whichever it picks. A capture that adds a gate is
|
|
1074
|
+
// stopped when the frontier would then need more next turn than the next income and more than without it
|
|
1075
|
+
// (`gateStop`, src/analysis/plan/captures.ts) — rule 4d's start-of-turn escape does not apply in a 1v1, and
|
|
1076
|
+
// rule 4e's contact fallback, where 4d is only a cost (#114), runs it too. The plan reports `gates` (each gate's
|
|
1077
|
+
// need and armies, conceded ones marked, the summed need, what stands on them, the per-gate deficit, the next
|
|
1078
|
+
// income and the shortfall) and warns when its own captures open a gate the income cannot hold.
|
|
983
1079
|
// 4e. Never stand still (#104, #107; every goal but `complete-bonus`, after pass 3). A plan that
|
|
984
1080
|
// makes no capture at all (no expansion, break, finishing off or strike) in the opening or
|
|
985
1081
|
// expansion phase takes one neutral capture toward a positive bonus (net > 0, never a negative
|
|
@@ -1098,12 +1194,20 @@
|
|
|
1098
1194
|
// this income (armies to finish, counting the members I hold, over the income — and never
|
|
1099
1195
|
// fewer than its depth, #125: the farthest missing member's distance from what I hold, since
|
|
1100
1196
|
// a capture's armies attack no further this turn; "N turns (N layers deep)"), so a farther
|
|
1101
|
-
// bonus gets only armies the closer ones cannot use; bonuses as close as each other
|
|
1102
|
-
//
|
|
1103
|
-
//
|
|
1104
|
-
//
|
|
1105
|
-
//
|
|
1106
|
-
//
|
|
1197
|
+
// bonus gets only armies the closer ones cannot use; bonuses as close as each other go by the
|
|
1198
|
+
// income per army of every bonus their capture completes (#438: each bonus whose missing members
|
|
1199
|
+
// are all among its own, net values summed, over the score's cost; a "complete together" line
|
|
1200
|
+
// names it when another as close competes), then — given `previousBoard` — a bonus advanced last
|
|
1201
|
+
// turn (a member captured since), then the score order; the rationale lists the order and says
|
|
1202
|
+
// which advanced bonus kept or gave way. Armies to finish count every missing member: a fogged one
|
|
1203
|
+
// a static seat left at its #417 price (below); else (#428) at its last sighting on my boards
|
|
1204
|
+
// (`options.lastSeen`, unless the fog shows another owner now), else its picking-board size
|
|
1205
|
+
// (#201), else — its owner hidden too — the game's neutral size (`settings.neutralArmies`), else at
|
|
1206
|
+
// its bonus's costliest visible missing member (counted as free before, the figure jumped when it
|
|
1207
|
+
// came into view), named in every "N armies to finish". #439 (plan/two-move.ts): a single-territory bonus of
|
|
1208
|
+
// at least TWO_MOVE_MIN_VALUE two moves away through a visible neutral is a two-turn completion
|
|
1209
|
+
// (cost: that neutral plus the territory); the neutral in between is a `stage` candidate under
|
|
1210
|
+
// `balanced` (net over both costs, ranked as an advance), else taken before the advances.
|
|
1107
1211
|
// 3b. One surplus per territory (#121). A border that holds at the start of the turn (its armies
|
|
1108
1212
|
// beat its visible threat, rule 1) and is not conceded keeps what holds it, as my commander's
|
|
1109
1213
|
// territory does (rule 1k): a capture from it spends only its armies above that, plus deploys
|
|
@@ -1141,7 +1245,10 @@
|
|
|
1141
1245
|
// first, only that one lands before the opponent's first; when I am known to move first, the
|
|
1142
1246
|
// warning is "holds only if my first order is …"). The warning names why the leftover made no
|
|
1143
1247
|
// deploy there (too little left, Local Deployment, No-Split sending the stack with its order)
|
|
1144
|
-
// only when that was the reason.
|
|
1248
|
+
// only when that was the reason. #440: before the margins below, the territory with the most
|
|
1249
|
+
// protected value that carries a single-territory bonus of at least DETERRENT_MIN_VALUE
|
|
1250
|
+
// (DETERRENT_VALUE_RATIO × the borders' most, an opponent within two steps) gets a deterrent guard: taking it needs more than
|
|
1251
|
+
// COMFORT_MARGIN × that opponent's deploy (plan/leftover.ts `deterrentGuard`). Then it goes to the held
|
|
1145
1252
|
// border with the highest protected value still short of COMFORT_MARGIN × its threat (counting
|
|
1146
1253
|
// armies withdrawn into it) — but first (#121), when it would go to such margins (no strike stack;
|
|
1147
1254
|
// #215 review: judged and run before the worse-order deploys above), a conceded border the leftover can make hold is held after all, from what is left once
|
|
@@ -1183,8 +1290,24 @@
|
|
|
1183
1290
|
// territory central to what I hold (open, issuing no order; my largest connected holding,
|
|
1184
1291
|
// then the fewest hops through my land to its farthest border, then the least sum, then id),
|
|
1185
1292
|
// the leftover stays on that centre ("no front to go to: it stays central …"; rule 6 moves
|
|
1186
|
-
// the armies already there, never the leftover)
|
|
1293
|
+
// the armies already there, never the leftover); #288: when that source faces no threat, holds
|
|
1294
|
+
// no commander of mine and has nothing left to attack once this turn's captures land (every
|
|
1295
|
+
// neighbour mine or captured), the leftover goes with its attacks on neutrals whose targets have
|
|
1296
|
+
// a step onward (most steps onward first; not under No-Split, not a combined capture: "and send
|
|
1297
|
+
// it with the attack on …"): each attack first gets what the next step from its target (its
|
|
1298
|
+
// cheapest visible neutral onward) needs beyond the armies that land movable, when the leftover
|
|
1299
|
+
// covers that whole; the rest is offered to another capture this turn (a neutral beside another
|
|
1300
|
+
// open territory of mine that issues no order, holds no commander and attacks no player, short
|
|
1301
|
+
// of its cost by no more than the rest: "for another capture this turn"), which rule 5b takes or
|
|
1302
|
+
// planPass sends back with the attacks (`revert`); what is left rides them in equal shares — else the
|
|
1187
1303
|
// border with the most fogged neighbours, else my biggest stack.
|
|
1304
|
+
// #303 (plan/leftover.ts `flatSave`): when my income is flat (`PlanInput.incomeHistory` → `PlanCtx.incomeTrend`,
|
|
1305
|
+
// #312's rule: the last FLAT_TURNS + 1 turns consecutive and within FLAT_TOLERANCE of the first) and the step
|
|
1306
|
+
// the leftover would save toward is in a positive bonus whose every member not mine is a visible neutral or
|
|
1307
|
+
// held by an opponent earning less than I do, the leftover saves toward it before any comfort margin: the
|
|
1308
|
+
// holds keep their exact armies, and the idle stacks stage toward the step rather than the front (rule 6).
|
|
1309
|
+
// Only where the leftover can land on the step's source (Local Deployment); otherwise unchanged. The plan
|
|
1310
|
+
// reports `incomeTrend` (the last five turns, a least-squares slope, `flat`).
|
|
1188
1311
|
// 5b. A neutral the leftover pays for (#218; live: a capture ruled out because its source "stays
|
|
1189
1312
|
// to hold its border", then the leftover put 8 on that source as its comfortable margin, and
|
|
1190
1313
|
// nothing took the 1-army neutral beside it). After the leftover, the strike stack's orders and
|
|
@@ -1230,7 +1353,14 @@
|
|
|
1230
1353
|
// into it from Y, Z make it hold together …"), never left reported conceded. Only a stack
|
|
1231
1354
|
// no enemy can be reached from heads for the nearest territory
|
|
1232
1355
|
// not mine (neutral or fog; never a teammate's, PLAN-TEAMS C3) instead (#121: idle armies walked toward a worthless neutral
|
|
1233
|
-
// while the enemy front was short, and a stack beside one never moved).
|
|
1356
|
+
// while the enemy front was short, and a stack beside one never moved). Heading for an enemy
|
|
1357
|
+
// front (not by a #260 step, not to a neutral edge), a step must also bring the stack strictly
|
|
1358
|
+
// nearer the enemy front measured through every territory held, conceded borders included (#367):
|
|
1359
|
+
// a conceded border falls to the stack beside it and the front is then right there, so a stack
|
|
1360
|
+
// behind one waits ("Keep the N idle armies on X: the enemy front nearest them, Y, lies past Z, a
|
|
1361
|
+
// border the plan concedes (#367) …"). Measured only around it, the front jumped to a farther
|
|
1362
|
+
// one; live, a 649 stack walked away from a conceded border and straight back the next turn, once
|
|
1363
|
+
// it had fallen. Judged on the one board, no memory of last turn. This turn's
|
|
1234
1364
|
// captures count as mine only when they land for sure — a neutral, or an attack on a player
|
|
1235
1365
|
// sized for its owner's whole deploy (rule 1e, 1s, or rule 3's #120 sizing): an exact-sized attack on a player fails
|
|
1236
1366
|
// if the owner reinforces, and the garrison beside it is not idle. Even a sure one may fail
|
|
@@ -1301,13 +1431,17 @@
|
|
|
1301
1431
|
// warning ("Breaking player … without eliminating it invites retaliation"): what it has left is
|
|
1302
1432
|
// likeliest aimed at whoever broke it. In a 1v1 it attacks me anyway, so no warning there.
|
|
1303
1433
|
// Wastelands (#167, `settings.wastelands`): a fogged missing member of a bonus is costed at the
|
|
1304
|
-
// costliest visible missing member plus the expected surcharge of being a wasteland
|
|
1434
|
+
// neutral size or costliest visible missing member (#428) plus the expected surcharge of being a wasteland
|
|
1305
1435
|
// (ceil(count ÷ the map's territories × (a wasteland's capture cost − that))), with a rationale line.
|
|
1306
1436
|
// #201: given `options.rememberedNeutrals` (the picking board's neutrals, which warapp_plan_picks
|
|
1307
1437
|
// and warapp_submit_picks' preview keep per game), a fogged missing member the picking board showed
|
|
1308
1438
|
// as a neutral (and whose owner the fog does not show as a player now) is costed at that size
|
|
1309
1439
|
// instead, never attacked, with a rationale line ("… fogged now, was a neutral of N on the picking
|
|
1310
|
-
// board (#201)").
|
|
1440
|
+
// board (#201)"). #417: a fogged member a static seat left (`BoardCtx.vacated`: shown owner-only as
|
|
1441
|
+
// its, or fogged now and the seat's when last seen — `foggedLastSeen`, the newest earlier board that
|
|
1442
|
+
// showed it, else `previousBoard`) is costed at VACATED_FOG_ARMIES (2) defenders, never above the costliest member in view (its border stack says nothing about the
|
|
1443
|
+
// land behind it), with a "… was player N's (out, no AI) … (#417)" line; it raises no other fogged
|
|
1444
|
+
// member's figure and gets no wasteland surcharge.
|
|
1311
1445
|
// 7. Move order (#127; every goal, last). Orders zigzag — the first mover's 1st, the other's
|
|
1312
1446
|
// 1st and 2nd, the first mover's 2nd and 3rd, … — so `moves` is scheduled
|
|
1313
1447
|
// (`scheduleMoves`, src/analysis/schedule.ts), earliest first: the one order Order Priority
|
|
@@ -1503,33 +1637,41 @@ import { guaranteedKills, nextBreakpoint, straightKills, } from './combat.js';
|
|
|
1503
1637
|
import { neighborsOf } from './graph.js';
|
|
1504
1638
|
import { forecastBorder, mainFront } from './exchange.js';
|
|
1505
1639
|
import { byNum, pct } from './plan/util.js';
|
|
1640
|
+
import { SIEGE_BREAK_WEIGHT } from './plan/siege.js';
|
|
1641
|
+
import { ALL_IN_VALUE_TURNS, bonusVerdicts, DROP_TURNS, judgeAttempts } from './plan/bonus-attempts.js';
|
|
1642
|
+
import { planJabs } from './plan/jabs.js';
|
|
1506
1643
|
import { BREAK_WEIGHT, MIN_EXPANSION_SHARE, PLAIN_EXPANSION_LOSS, SECOND_FRONT_LEAD, SECOND_FRONT_SIMILAR, captureCost, } from './plan/shared.js';
|
|
1507
1644
|
import { emptyPlan, noteEstimates, planContext } from './plan/estimates.js';
|
|
1508
1645
|
import { neutralizeSeats, seatTerritories, staticSeats } from './static-seats.js';
|
|
1509
1646
|
import { deployBook } from './plan/orders.js';
|
|
1510
|
-
import { holdsPhase } from './plan/holds.js';
|
|
1647
|
+
import { holdsPhase, priorOnlyHold } from './plan/holds.js';
|
|
1511
1648
|
import { threatsPhase } from './plan/threats.js';
|
|
1512
1649
|
import { targetsPhase } from './plan/targets.js';
|
|
1513
1650
|
import { capturesPhase } from './plan/captures.js';
|
|
1514
1651
|
import { completedMembers } from './plan/completed.js';
|
|
1515
1652
|
import { chooseStrikeStack, leadStrikes, spendStrikeStack, strikesPhase } from './plan/strike.js';
|
|
1653
|
+
import { contestedBonuses } from './plan/stockpile.js';
|
|
1516
1654
|
import { afterLeftoverCaptures, plainEconomy, plainEligible } from './plan/after-leftover.js';
|
|
1655
|
+
import { fundFromSecondSizing } from './plan/second-sizing.js';
|
|
1517
1656
|
import { leftoverDeploy } from './plan/leftover.js';
|
|
1518
1657
|
import { fillSecondLine, guardOffRaids } from './plan/guard-off.js';
|
|
1519
1658
|
import { neverStandStill } from './plan/stand-still.js';
|
|
1520
|
-
import {
|
|
1659
|
+
import { stageTwoMove, twoMoveStages } from './plan/two-move.js';
|
|
1660
|
+
import { addEmptyEnemyTargets, dropEmptyEnemyTargets, foggedLastSeen, plainOrderCosts, raceLine, raceTargets, tryEmptyEnemy, withoutTransit } from './plan/vacated.js';
|
|
1521
1661
|
import { spendUnderCap } from './plan/cap-spend.js';
|
|
1522
1662
|
import { attackOutOfConceded } from './plan/conceded-out.js';
|
|
1663
|
+
import { captureInsteadOfHold } from './plan/capture-instead.js';
|
|
1523
1664
|
import { transfers } from './plan/transfers.js';
|
|
1524
1665
|
import { scheduleOrders, strikeOrderPriority } from './plan/move-order.js';
|
|
1525
1666
|
import { commanderMoveWarning, placeCommanderMove, reserveCommanderMove } from './plan/commander.js';
|
|
1526
1667
|
import { finishPlan, reportExpected, reportOffence } from './plan/report.js';
|
|
1527
1668
|
import { newPlanState } from './plan/state.js';
|
|
1528
1669
|
import { teamFocusLine, teamReport } from './plan/team.js';
|
|
1529
|
-
import { applyBorderCaps, armiesFreed, partnerFronts, reportBreakLosses, reportTruce, trucePass } from './plan/relations.js';
|
|
1670
|
+
import { applyBorderCaps, armiesFreed, partnerFronts, reportBreakLosses, reportTruce, trucePass, warnTruceNeutrals } from './plan/relations.js';
|
|
1530
1671
|
export * from './plan/shared.js';
|
|
1531
1672
|
export { alliesOf, planEnemyEstimates } from './plan/estimates.js';
|
|
1532
1673
|
export { TRUCE_RELAX_VALUE } from './plan/relations.js';
|
|
1674
|
+
export { SPREAD_INCOME_SLACK, SPREAD_LAST_TURN, SPREAD_TERRITORIES } from './plan/targets.js';
|
|
1533
1675
|
/** Passes that refine the cut set (#172) before falling back to the plan that cuts nothing. */
|
|
1534
1676
|
const TWO_STEP_PASSES = 3;
|
|
1535
1677
|
/** Passes that learn which territories in between end held (#172) before none is counted held. */
|
|
@@ -1567,7 +1709,7 @@ export function planTurn(input) {
|
|
|
1567
1709
|
// territories are planned as neutrals (static armies), and it is no opponent anywhere below.
|
|
1568
1710
|
const seats = staticSeats(input.game?.players, input.game?.endRules, input.me);
|
|
1569
1711
|
const held = seatTerritories(input.board, seats);
|
|
1570
|
-
const plan =
|
|
1712
|
+
const plan = planPushed(withoutStaticSeats(input, seats));
|
|
1571
1713
|
for (const [p, n] of [...held].sort((a, b) => a[0] - b[0]))
|
|
1572
1714
|
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).`);
|
|
1573
1715
|
return plan;
|
|
@@ -1589,6 +1731,12 @@ function withoutStaticSeats(input, seats) {
|
|
|
1589
1731
|
for (const t of input.board.territories)
|
|
1590
1732
|
if (t.owner.kind === 'player' && seats.has(t.owner.playerId))
|
|
1591
1733
|
vacated.set(t.territoryId, t.owner.playerId);
|
|
1734
|
+
// #417: and the fogged ones last seen held by a seat — on the newest earlier board that showed them
|
|
1735
|
+
// (`foggedLastSeen`), not only the previous board, so the pricing outlasts the turn vision was lost.
|
|
1736
|
+
const lastSeen = input.foggedLastSeen ?? foggedLastSeen(input.board, input.previousBoard ? [{ turn: 0, board: input.previousBoard }] : []);
|
|
1737
|
+
for (const [t, p] of lastSeen)
|
|
1738
|
+
if (seats.has(p))
|
|
1739
|
+
vacated.set(t, p);
|
|
1592
1740
|
return {
|
|
1593
1741
|
...input,
|
|
1594
1742
|
...(vacated.size ? { vacated } : {}),
|
|
@@ -1600,6 +1748,170 @@ function withoutStaticSeats(input, seats) {
|
|
|
1600
1748
|
...(input.game && opening ? { game: { ...input.game, opening: new Map([...opening].filter(([p]) => !seats.has(p))) } } : {}),
|
|
1601
1749
|
};
|
|
1602
1750
|
}
|
|
1751
|
+
/** #298: per plan, the all-in pushes its pass sized (plan/targets.ts), by bonus id. */
|
|
1752
|
+
const allInOutcome = new WeakMap();
|
|
1753
|
+
/**
|
|
1754
|
+
* #298's attempt memory ({@link planAttempts}), then #421's stockpile all-in completions: on a pile, the
|
|
1755
|
+
* contested bonuses a push could complete are planned all-in, those it does not take whole left out.
|
|
1756
|
+
*/
|
|
1757
|
+
function planPushed(input) {
|
|
1758
|
+
const plan = planAttempts(input);
|
|
1759
|
+
const candidates = pileAllInOutcome.get(plan);
|
|
1760
|
+
if (!candidates?.length)
|
|
1761
|
+
return plan;
|
|
1762
|
+
// #421 (owner decision, 2026-11-20): on a stockpile, every contested bonus whose missing members can all be
|
|
1763
|
+
// taken this turn — each an opponent holds sized for its owner's deploy, the push within the payback horizon ×
|
|
1764
|
+
// its value — is completed all-in. One the plan does not take whole is left out (no drop: it is no failed
|
|
1765
|
+
// attempt), and a push that would cost a #298 verdict its plan is not made.
|
|
1766
|
+
const missingOf = (id) => {
|
|
1767
|
+
const at = new Map(input.board.territories.map((t) => [t.territoryId, t.owner]));
|
|
1768
|
+
return bonusTerritories(input.graph, id).filter((t) => {
|
|
1769
|
+
const o = at.get(t);
|
|
1770
|
+
return !(o?.kind === 'player' && o.playerId === input.me);
|
|
1771
|
+
});
|
|
1772
|
+
};
|
|
1773
|
+
const pushed = new Set(candidates);
|
|
1774
|
+
for (;;) {
|
|
1775
|
+
const next = planAttempts({ ...input, stockpileAllIn: new Set(pushed) });
|
|
1776
|
+
const tries = allInOutcome.get(next);
|
|
1777
|
+
const taken = new Set(next.expected.captures);
|
|
1778
|
+
const failing = [...pushed].filter((id) => !tries?.get(id)?.feasible || missingOf(id).some((t) => !taken.has(t)));
|
|
1779
|
+
if (!failing.length) {
|
|
1780
|
+
if (JSON.stringify(next.bonusPush ?? []) !== JSON.stringify(plan.bonusPush ?? []))
|
|
1781
|
+
return plan;
|
|
1782
|
+
const name = (id) => `${input.graph.bonusById.get(id).name} (#${id})`;
|
|
1783
|
+
for (const id of [...pushed].sort((a, b) => a - b)) {
|
|
1784
|
+
const t = tries.get(id);
|
|
1785
|
+
next.rationale.push(`Stockpile all-in (#421): bonus ${name(id)} is contested and my armies stand idle on a flat income, so every missing member is taken this turn, each one another player holds sized for its owner's deploy: ${t.cost} armies, within the cap of ${t.cap} (the payback horizon × its value).`);
|
|
1786
|
+
}
|
|
1787
|
+
return next;
|
|
1788
|
+
}
|
|
1789
|
+
for (const id of failing)
|
|
1790
|
+
pushed.delete(id);
|
|
1791
|
+
if (!pushed.size)
|
|
1792
|
+
return plan;
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
/** #421: per plan, the contested bonuses a stockpile could push all-in (only on a plan made without such a push). */
|
|
1796
|
+
const pileAllInOutcome = new WeakMap();
|
|
1797
|
+
/** Merge the #421 stockpile pushes (`input.stockpileAllIn`) into #298's push and focus. */
|
|
1798
|
+
function withPush(input, allIn, dropped) {
|
|
1799
|
+
const ids = new Set([...allIn, ...(input.stockpileAllIn ?? [])]);
|
|
1800
|
+
const focus = [...new Set([...(input.options?.focusBonusIds ?? []), ...ids])];
|
|
1801
|
+
return {
|
|
1802
|
+
...input,
|
|
1803
|
+
bonusPush: { allIn: ids, dropped },
|
|
1804
|
+
options: { ...input.options, ...(ids.size ? { focusBonusIds: focus } : {}) },
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
/**
|
|
1808
|
+
* #298: the plan with the attempt memory's verdicts (plan/bonus-attempts.ts). A bonus whose completion
|
|
1809
|
+
* failed on two consecutive turns is pushed all-in (focused, every missing member sized for its owner's
|
|
1810
|
+
* deploy or not taken); when the push does not fit the cap, or the plan does not take every missing
|
|
1811
|
+
* member, it is planned again with that bonus dropped for DROP_TURNS turns. With no verdict, the plan
|
|
1812
|
+
* is exactly what it was without the memory.
|
|
1813
|
+
*/
|
|
1814
|
+
function planAttempts(input) {
|
|
1815
|
+
const turn = input.turn;
|
|
1816
|
+
const none = new Set();
|
|
1817
|
+
if (!input.bonusAttempts || turn === undefined)
|
|
1818
|
+
return planShare(input.stockpileAllIn?.size ? withPush(input, none, none) : input);
|
|
1819
|
+
const judged = judgeAttempts(input.bonusAttempts, turn, input.graph, input.board, input.me);
|
|
1820
|
+
const verdicts = bonusVerdicts(judged, turn).filter((v) => input.graph.bonusById.has(v.bonusId));
|
|
1821
|
+
if (!verdicts.length)
|
|
1822
|
+
return planShare(input.stockpileAllIn?.size ? withPush(input, none, none) : input);
|
|
1823
|
+
const entries = new Map();
|
|
1824
|
+
for (const v of verdicts)
|
|
1825
|
+
if (v.kind === 'dropped')
|
|
1826
|
+
entries.set(v.bonusId, { ...v });
|
|
1827
|
+
let allIn = verdicts.filter((v) => v.kind === 'all-in');
|
|
1828
|
+
const missingOf = (bonusId) => {
|
|
1829
|
+
const at = new Map(input.board.territories.map((t) => [t.territoryId, t]));
|
|
1830
|
+
return bonusTerritories(input.graph, bonusId).filter((t) => {
|
|
1831
|
+
const o = at.get(t)?.owner;
|
|
1832
|
+
return !(o?.kind === 'player' && o.playerId === input.me);
|
|
1833
|
+
});
|
|
1834
|
+
};
|
|
1835
|
+
// A bonus already complete, or no longer contested, needs no push (#406): an all-in verdict needs a
|
|
1836
|
+
// missing member another player still holds; with only neutrals left it is planned as any other bonus,
|
|
1837
|
+
// neither pushed nor dropped.
|
|
1838
|
+
const owners = new Map(input.board.territories.map((t) => [t.territoryId, t.owner]));
|
|
1839
|
+
const contested = (bonusId) => missingOf(bonusId).some((t) => {
|
|
1840
|
+
const o = owners.get(t);
|
|
1841
|
+
return o?.kind === 'player' && o.playerId !== input.me;
|
|
1842
|
+
});
|
|
1843
|
+
allIn = allIn.filter((v) => missingOf(v.bonusId).length > 0 && contested(v.bonusId));
|
|
1844
|
+
let plan;
|
|
1845
|
+
for (;;) {
|
|
1846
|
+
const ids = new Set(allIn.map((v) => v.bonusId));
|
|
1847
|
+
plan = planShare(withPush(input, ids, new Set([...entries.keys()])));
|
|
1848
|
+
const tries = allInOutcome.get(plan);
|
|
1849
|
+
const taken = new Set(plan.expected.captures);
|
|
1850
|
+
const failing = allIn.flatMap((v) => {
|
|
1851
|
+
const t = tries?.get(v.bonusId);
|
|
1852
|
+
if (!t)
|
|
1853
|
+
return [{ v, detail: 'it could not be sized' }];
|
|
1854
|
+
if (!t.feasible)
|
|
1855
|
+
return [{ v, detail: t.detail ?? 'it could not be sized', cost: t.cost, cap: t.cap }];
|
|
1856
|
+
const left = missingOf(v.bonusId).filter((x) => !taken.has(x));
|
|
1857
|
+
return left.length ? [{ v, detail: `this turn's plan cannot take ${left.map((x) => `#${x}`).join(', ')} at that size` }] : [];
|
|
1858
|
+
});
|
|
1859
|
+
if (!failing.length) {
|
|
1860
|
+
for (const v of allIn) {
|
|
1861
|
+
const t = tries.get(v.bonusId);
|
|
1862
|
+
entries.set(v.bonusId, { bonusId: v.bonusId, kind: 'all-in', failedTurns: v.failedTurns, cost: t.cost, cap: t.cap });
|
|
1863
|
+
}
|
|
1864
|
+
break;
|
|
1865
|
+
}
|
|
1866
|
+
for (const f of failing)
|
|
1867
|
+
entries.set(f.v.bonusId, {
|
|
1868
|
+
bonusId: f.v.bonusId,
|
|
1869
|
+
kind: 'dropped',
|
|
1870
|
+
why: 'no-all-in',
|
|
1871
|
+
from: turn,
|
|
1872
|
+
until: turn + DROP_TURNS - 1,
|
|
1873
|
+
failedTurns: f.v.failedTurns,
|
|
1874
|
+
detail: f.detail,
|
|
1875
|
+
});
|
|
1876
|
+
const out = new Set(failing.map((f) => f.v.bonusId));
|
|
1877
|
+
allIn = allIn.filter((v) => !out.has(v.bonusId));
|
|
1878
|
+
}
|
|
1879
|
+
const name = (id) => `${input.graph.bonusById.get(id).name} (#${id})`;
|
|
1880
|
+
const turnsText = (ts) => (ts.length > 1 ? `${ts.slice(0, -1).join(', ')} and ${ts[ts.length - 1]}` : `${ts[0]}`);
|
|
1881
|
+
const push = [...entries.values()].sort((a, b) => a.bonusId - b.bonusId);
|
|
1882
|
+
for (const e of push) {
|
|
1883
|
+
if (e.kind === 'all-in')
|
|
1884
|
+
plan.rationale.push(`Bonus ${name(e.bonusId)}: my attempts to complete it failed on turns ${turnsText(e.failedTurns)}: all-in this turn, every missing member taken, each one another player holds sized for its owner's deploy (#368's middle figure): ${e.cost} armies, within the cap of ${e.cap} (${ALL_IN_VALUE_TURNS} turns of its value, at most my income) (#298).`);
|
|
1885
|
+
else {
|
|
1886
|
+
const why = e.why === 'still-dropped'
|
|
1887
|
+
? `dropped on turn ${e.from} after repeated failed attempts`
|
|
1888
|
+
: e.why === 'all-in-failed'
|
|
1889
|
+
? `my attempts to complete it failed on turns ${turnsText(e.failedTurns)}, the last of them all-in`
|
|
1890
|
+
: `my attempts to complete it failed on turns ${turnsText(e.failedTurns)}, and no single all-in push this turn completes it: ${e.detail}`;
|
|
1891
|
+
plan.rationale.push(`Bonus ${name(e.bonusId)} is dropped as a target on turns ${e.from} to ${e.until} (#298): ${why}. No armies go into it piecemeal.`);
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
plan.bonusPush = push;
|
|
1895
|
+
return plan;
|
|
1896
|
+
}
|
|
1897
|
+
/** #421: per plan, the strike share its pass held out of captures (absent when none). */
|
|
1898
|
+
const shareOutcome = new WeakMap();
|
|
1899
|
+
/**
|
|
1900
|
+
* #421 (owner decision, 2026-11-20): the strike share is held out of captures, ahead of comfort margins,
|
|
1901
|
+
* but never at the cost of next income — when the plan without it earns more next turn (a completion the
|
|
1902
|
+
* share starves), that plan stands and says why.
|
|
1903
|
+
*/
|
|
1904
|
+
function planShare(input) {
|
|
1905
|
+
const plan = planSettled(input);
|
|
1906
|
+
const share = shareOutcome.get(plan);
|
|
1907
|
+
if (!share)
|
|
1908
|
+
return plan;
|
|
1909
|
+
const without = planSettled({ ...input, options: { ...input.options, strikeShare: false } });
|
|
1910
|
+
if (without.expected.nextIncome <= plan.expected.nextIncome)
|
|
1911
|
+
return plan;
|
|
1912
|
+
without.rationale.push(`Strike share (#421) not held this turn: holding ${share} of the income out of captures for the strike stack would lower next income from ${without.expected.nextIncome} to ${plan.expected.nextIncome} (a capture it starves completes a bonus).`);
|
|
1913
|
+
return without;
|
|
1914
|
+
}
|
|
1603
1915
|
function planSettled(input) {
|
|
1604
1916
|
const plan = planRun(input, false);
|
|
1605
1917
|
const bare = runOutcome.get(plan);
|
|
@@ -1668,7 +1980,7 @@ function planPass(input, pass) {
|
|
|
1668
1980
|
return empty;
|
|
1669
1981
|
}
|
|
1670
1982
|
// ---- the deploy book (plan/orders.ts): budget, guard, deploys, pools, protected value ----
|
|
1671
|
-
const book = deployBook(pc, ps);
|
|
1983
|
+
const book = deployBook(pc, ps, input.previousBoard);
|
|
1672
1984
|
// #274: under No-Split my commander's walk is its territory's one order, entered before any pass plans.
|
|
1673
1985
|
reserveCommanderMove(pc, ps);
|
|
1674
1986
|
const { guardAt, coverOf, heldNow, gainWith, orderOf, deploy, pools, roomAt, spareAt, } = book;
|
|
@@ -1677,11 +1989,11 @@ function planPass(input, pass) {
|
|
|
1677
1989
|
// As the deploy book reads it, restated here so TypeScript narrows `pools` wherever it is tested.
|
|
1678
1990
|
const local = pools !== null && pools.bonuses.length > 0;
|
|
1679
1991
|
// ---- 1t. threat trend, 1. defence (plan/threats.ts) ----
|
|
1680
|
-
const threats = threatsPhase(pc, ps, input);
|
|
1992
|
+
const threats = threatsPhase(pc, ps, input, book.valueOf);
|
|
1681
1993
|
const { growthOf, reinforcementAt, borders, facing, borderAt } = threats;
|
|
1682
1994
|
// ---- 1. holds, #172, 1h, 1b, 1c, #122 garrisons (plan/holds.ts) ----
|
|
1683
1995
|
const hd = holdsPhase(pc, ps, book, threats, pass);
|
|
1684
|
-
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, } = hd;
|
|
1996
|
+
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;
|
|
1685
1997
|
// ---- 2. targets, 4d. frontier cost, bonus scoring, #101 (plan/targets.ts) ----
|
|
1686
1998
|
const tgt = targetsPhase(pc, ps, input, threats, hd);
|
|
1687
1999
|
const { breakable, counterAt, targets, leadSteps, landScoreCost, offence, skipOffence, plans, ratio, committing, byCloseness, retakeChecks, retakeWarning, } = tgt;
|
|
@@ -1693,6 +2005,8 @@ function planPass(input, pass) {
|
|
|
1693
2005
|
// ---- R3, No-Split, capture helper, 3a. combined, passes 1 and 2 (plan/captures.ts) ----
|
|
1694
2006
|
const caps = capturesPhase(pc, ps, pass, book, threats, hd, tgt);
|
|
1695
2007
|
const { strikes, worstCase, defendersAt, tryCapture, snapshot, complete, tryExpand, advance } = caps;
|
|
2008
|
+
/** #439: single-territory bonuses two moves away, each with its neutral in between. */
|
|
2009
|
+
const stages = twoMoveStages(pc, tgt);
|
|
1696
2010
|
// ---- 1e. finish off an opponent, 1s. strike an enemy commander, #165 guard-off breaks (plan/strike.ts) ----
|
|
1697
2011
|
const { struck } = strikesPhase(pc, ps, book, threats, hd, tgt, caps);
|
|
1698
2012
|
// ---- #276: guard off — free retakes and raids one step deeper (plan/guard-off.ts) ----
|
|
@@ -1745,7 +2059,10 @@ function planPass(input, pass) {
|
|
|
1745
2059
|
const secondFrontSaid = new Set();
|
|
1746
2060
|
/** #167: the neutral's share of a break's score that skips it, scaled by my army lead (at least 1×). */
|
|
1747
2061
|
const similar = SECOND_FRONT_SIMILAR * Math.max(1, Math.min(SECOND_FRONT_LEAD, armyLead.ratio));
|
|
2062
|
+
/** #382: a break of the siege target's bonus (scored {@link SIEGE_BREAK_WEIGHT} × a 1v1 break, never a second front). */
|
|
2063
|
+
const besieged = (b) => pc.siege?.target === b.player;
|
|
1748
2064
|
const opensSecondFront = (b, score) => ffa &&
|
|
2065
|
+
!besieged(b) &&
|
|
1749
2066
|
!leadLever &&
|
|
1750
2067
|
b.player !== clearLeader &&
|
|
1751
2068
|
!threatensMyBonus(b.player) &&
|
|
@@ -1776,7 +2093,9 @@ function planPass(input, pass) {
|
|
|
1776
2093
|
return enemyDeploy;
|
|
1777
2094
|
return Math.max(...[...byPlayer].map(([p, movable]) => movable + deployOf(p)));
|
|
1778
2095
|
};
|
|
1779
|
-
const rank = { unit: 0, hold: 0, complete: 1, advance: 2, break: 3, counter: 3 };
|
|
2096
|
+
const rank = { unit: 0, hold: 0, complete: 1, advance: 2, stage: 2, race: 2, break: 3, counter: 3 };
|
|
2097
|
+
/** A capture that completes no bonus this turn: an advance, a two-move stage (#439), a 1v1 race (#417), a break or a counter. */
|
|
2098
|
+
const completesNothing = (c) => c.kind === 'advance' || c.kind === 'stage' || c.kind === 'race' || c.kind === 'break' || c.kind === 'counter';
|
|
1780
2099
|
const candidates = [];
|
|
1781
2100
|
const deferred = [];
|
|
1782
2101
|
/** #215: pending holds this step conceded and unlocked, whose armies may still attack out. */
|
|
@@ -1796,8 +2115,12 @@ function planPass(input, pass) {
|
|
|
1796
2115
|
* this turn's captures may complete stays locked until they are known: rule 1c keeps it for a
|
|
1797
2116
|
* completed bonus, and an attack out would have emptied it first.
|
|
1798
2117
|
*/
|
|
1799
|
-
const concedePending = (t, room) => {
|
|
1800
|
-
|
|
2118
|
+
const concedePending = (t, room, capped = false) => {
|
|
2119
|
+
// #420: past the hold cap, said as such.
|
|
2120
|
+
if (capped)
|
|
2121
|
+
concedeCapped(t);
|
|
2122
|
+
else
|
|
2123
|
+
concedeUnaffordable(t, room);
|
|
1801
2124
|
if (heldBorders.has(t.id))
|
|
1802
2125
|
return;
|
|
1803
2126
|
if (mayComplete(t.id))
|
|
@@ -1825,6 +2148,31 @@ function planPass(input, pass) {
|
|
|
1825
2148
|
candidates.push({ kind: 'complete', score, cost: p.cost, id: p.bonusId, value: p.net, focus: p.focus, borders: p.borders, run: spend(() => complete(p)) });
|
|
1826
2149
|
candidates.push({ kind: 'advance', score, cost: p.cost, id: p.bonusId, value: p.net, focus: p.focus, borders: p.borders, run: spend(() => advance(p)) });
|
|
1827
2150
|
}
|
|
2151
|
+
// #439: a single-territory bonus two moves away is a two-turn completion: its neutral in between
|
|
2152
|
+
// competes as an advance does, on the income per army of both captures.
|
|
2153
|
+
for (const st of stages)
|
|
2154
|
+
candidates.push({ kind: 'stage', score: st.net / st.cost, cost: st.cost, id: st.bonusId, value: st.net, focus: false, borders: 0, target: st.via, run: spend(() => stageTwoMove(pc, ps, st, gainWith, tryExpand)) });
|
|
2155
|
+
// #417, the 1v1 race: while a static seat's land is still untaken, its cheap captures rank ahead of
|
|
2156
|
+
// rule 0p.1's "expansion last" (`ahead` below); held-bonus gates and my commander's hold go first.
|
|
2157
|
+
const races = oneVsOne ? raceTargets(pc, targets, captured) : [];
|
|
2158
|
+
if (races.length)
|
|
2159
|
+
rationale.push(raceLine(pc, races));
|
|
2160
|
+
for (const r of races)
|
|
2161
|
+
candidates.push({
|
|
2162
|
+
kind: 'race',
|
|
2163
|
+
score: 0,
|
|
2164
|
+
cost: r.cost,
|
|
2165
|
+
id: r.t,
|
|
2166
|
+
value: 0,
|
|
2167
|
+
focus: false,
|
|
2168
|
+
borders: 0,
|
|
2169
|
+
target: r.t,
|
|
2170
|
+
run: spend(() => {
|
|
2171
|
+
if (captured.has(r.t))
|
|
2172
|
+
return;
|
|
2173
|
+
withoutTransit(pc, tgt, r.t, () => tryExpand(r.t, `races for land player ${pc.vacated.get(r.t)} left (out, no AI), ahead of the 1v1 "expansion last" rule (#417)`));
|
|
2174
|
+
}),
|
|
2175
|
+
});
|
|
1828
2176
|
// Capturing a member of a breakable bonus: what survives it, and whether that holds next turn.
|
|
1829
2177
|
// A break is sized to land (#72): its score leaves out what holding it would need.
|
|
1830
2178
|
const breakOption = (t) => {
|
|
@@ -1893,6 +2241,7 @@ function planPass(input, pass) {
|
|
|
1893
2241
|
const before = ps.budget;
|
|
1894
2242
|
noteRecent(t);
|
|
1895
2243
|
deploy(t.id, t.holdCost);
|
|
2244
|
+
chargeCap(t.holdCost);
|
|
1896
2245
|
if (!tryCapture(n, breakReason(b), { from: t.id, keep: avail.get(t.id) })) {
|
|
1897
2246
|
// Refused (R3: it would complete a bonus I cannot hold next turn): just hold.
|
|
1898
2247
|
rationale.push(`Deploy ${t.holdCost} to ${label(t.id)} so it holds (protects +${t.value}): ${heldStack(t)} need ${toTake(t.have + t.units + t.holdCost)} to take, above the ~${t.threat} threat.`);
|
|
@@ -1916,6 +2265,32 @@ function planPass(input, pass) {
|
|
|
1916
2265
|
});
|
|
1917
2266
|
return true;
|
|
1918
2267
|
};
|
|
2268
|
+
/** The member a break of `b` takes: its cheapest visible member (#72: a break only has to land), then the least frontier, then id. */
|
|
2269
|
+
const breakOptionOf = (b) => bonusTerritories(g, b.bonusId)
|
|
2270
|
+
.filter((t) => targets.has(t))
|
|
2271
|
+
.map(breakOption)
|
|
2272
|
+
.sort((a, b) => a.cost - b.cost || a.scoreCost - b.scoreCost || a.t - b.t)[0];
|
|
2273
|
+
// #421 (owner decision, 2026-11-20): on a stockpile (`pc.pile`) the turn spends by breaking the strongest
|
|
2274
|
+
// opponent's cheapest visible bonus (every member in view: never a probable one) — ahead of every other
|
|
2275
|
+
// capture, never skipped as a second front. The strongest is the highest income estimate, then id.
|
|
2276
|
+
const pileBreak = (() => {
|
|
2277
|
+
if (!pc.pile)
|
|
2278
|
+
return undefined;
|
|
2279
|
+
const strongest = pc.estimateList
|
|
2280
|
+
.filter((e) => foe(e.playerId))
|
|
2281
|
+
.sort((a, b) => incomeOfPlayer(b.playerId) - incomeOfPlayer(a.playerId) || a.playerId - b.playerId)[0]?.playerId;
|
|
2282
|
+
if (strongest === undefined)
|
|
2283
|
+
return undefined;
|
|
2284
|
+
return breakable
|
|
2285
|
+
.filter((b) => b.player === strongest && !b.probable)
|
|
2286
|
+
.flatMap((b) => {
|
|
2287
|
+
const o = breakOptionOf(b);
|
|
2288
|
+
return o ? [{ b, o }] : [];
|
|
2289
|
+
})
|
|
2290
|
+
.sort((x, y) => x.o.cost - y.o.cost || y.b.value - x.b.value || x.b.bonusId - y.b.bonusId)[0];
|
|
2291
|
+
})();
|
|
2292
|
+
if (pileBreak)
|
|
2293
|
+
rationale.push(`Stockpile spend (#421): ${pc.pile.my} armies of mine stand on the board, ${pc.pile.turns} turns of my flat ${income} income, so the turn tries first to break the strongest opponent's cheapest visible bonus, player ${pileBreak.b.player}'s ${bonusName(pileBreak.b.bonusId)} (+${pileBreak.b.value}) through ${label(pileBreak.o.t)} (${pileBreak.o.cost} armies), before any other capture.`);
|
|
1919
2294
|
for (const b of breakable) {
|
|
1920
2295
|
// Its cheapest visible member (#72: a break only has to land), then the least frontier, then id.
|
|
1921
2296
|
const options = bonusTerritories(g, b.bonusId)
|
|
@@ -1925,7 +2300,7 @@ function planPass(input, pass) {
|
|
|
1925
2300
|
const o = options[0];
|
|
1926
2301
|
if (!o)
|
|
1927
2302
|
continue;
|
|
1928
|
-
const worth = strikeWorth(b.value, o);
|
|
2303
|
+
const worth = besieged(b) ? (strikeWorth(b.value, o) * SIEGE_BREAK_WEIGHT) / weight : strikeWorth(b.value, o);
|
|
1929
2304
|
const score = worth / Math.max(1, o.scoreCost);
|
|
1930
2305
|
offence.set(`break:${b.bonusId}`, {
|
|
1931
2306
|
bonusId: b.bonusId,
|
|
@@ -1936,18 +2311,24 @@ function planPass(input, pass) {
|
|
|
1936
2311
|
taken: false,
|
|
1937
2312
|
why: breakReason(b),
|
|
1938
2313
|
});
|
|
2314
|
+
const spendIt = pileBreak?.b === b;
|
|
1939
2315
|
// An FFA skips a second-front break, but only one the plan could pay for is named as
|
|
1940
|
-
// skipped: an unaffordable one is dropped quietly (it could not run either way).
|
|
1941
|
-
if (
|
|
2316
|
+
// skipped: an unaffordable one is dropped quietly (it could not run either way). #421: never the stockpile's.
|
|
2317
|
+
if (spendIt) {
|
|
2318
|
+
// #421: the stockpile's break runs whatever its front.
|
|
2319
|
+
}
|
|
2320
|
+
else if (opensSecondFront(b, score) && !affordable(o.t)) {
|
|
1942
2321
|
skipOffence(o.t, 'not affordable this turn');
|
|
1943
2322
|
continue;
|
|
1944
2323
|
}
|
|
1945
|
-
if (secondFront(b, score)) {
|
|
2324
|
+
if (!spendIt && secondFront(b, score)) {
|
|
1946
2325
|
skipOffence(o.t, `no second front in an FFA: player ${b.player} threatens no bonus of mine`);
|
|
1947
2326
|
continue;
|
|
1948
2327
|
}
|
|
2328
|
+
const reasonOf = (r) => (spendIt ? `${r} — the stockpile's spend on the strongest opponent (#421)` : r);
|
|
1949
2329
|
candidates.push({
|
|
1950
2330
|
kind: 'break',
|
|
2331
|
+
...(spendIt ? { spend: true } : {}),
|
|
1951
2332
|
score,
|
|
1952
2333
|
cost: o.cost,
|
|
1953
2334
|
id: b.bonusId,
|
|
@@ -1965,7 +2346,7 @@ function planPass(input, pass) {
|
|
|
1965
2346
|
const was = worstCase.get(o.t);
|
|
1966
2347
|
targets.set(o.t, { ...tg, cost: o.cost });
|
|
1967
2348
|
worstCase.set(o.t, defenceAt(o.t) + reinforcementAt(o.t));
|
|
1968
|
-
if (!tryCapture(o.t, `${breakReason(b)}, sized to land against player ${b.player}'s ~${reinforcementAt(o.t)} deploy (#201: I lead this free-for-all)`)) {
|
|
2349
|
+
if (!tryCapture(o.t, reasonOf(`${breakReason(b)}, sized to land against player ${b.player}'s ~${reinforcementAt(o.t)} deploy (#201: I lead this free-for-all)`))) {
|
|
1969
2350
|
targets.set(o.t, tg);
|
|
1970
2351
|
if (was === undefined)
|
|
1971
2352
|
worstCase.delete(o.t);
|
|
@@ -1974,7 +2355,7 @@ function planPass(input, pass) {
|
|
|
1974
2355
|
return;
|
|
1975
2356
|
}
|
|
1976
2357
|
}
|
|
1977
|
-
else if (!tryCapture(o.t, breakReason(b)))
|
|
2358
|
+
else if (!tryCapture(o.t, reasonOf(breakReason(b))))
|
|
1978
2359
|
return;
|
|
1979
2360
|
ps.anchor ??= moves[moves.length - 1].from;
|
|
1980
2361
|
warnRetake(b, o);
|
|
@@ -2012,7 +2393,7 @@ function planPass(input, pass) {
|
|
|
2012
2393
|
}
|
|
2013
2394
|
expansionLeft = candidates.length;
|
|
2014
2395
|
// Under rule 0p.1 an advance never outranks a hold, so it never defers one either.
|
|
2015
|
-
topValue = Math.max(0, ...candidates.filter((c) => !(oneVsOne && c.kind === 'advance')).map((c) => c.value));
|
|
2396
|
+
topValue = Math.max(0, ...candidates.filter((c) => c.kind !== 'stage' && !(oneVsOne && c.kind === 'advance')).map((c) => c.value));
|
|
2016
2397
|
let floor = expansionLeft ? Math.ceil(MIN_EXPANSION_SHARE * income) : 0;
|
|
2017
2398
|
// #167: a multi-turn view of the main front. Adapting in contact, the expansion share stands only
|
|
2018
2399
|
// when the front is no worse than a stand-off without those armies: my biggest stack facing the
|
|
@@ -2068,9 +2449,13 @@ function planPass(input, pass) {
|
|
|
2068
2449
|
rationale.push(`Front outlook (#167): ${pair}, ${f.outcome === 'breaks' ? `my stack breaks it on turn ${f.turn}` : 'it is a stand-off'} even with ${share} of income going to expansion (${f.pinnedHolds ? `the border pins ${f.pinned}` : `not even my whole ${every} keeps the border`}): the expansion share stands.${wholeText}`);
|
|
2069
2450
|
}
|
|
2070
2451
|
}
|
|
2071
|
-
for (const t of holds)
|
|
2452
|
+
for (const t of holds) {
|
|
2453
|
+
const b = borders.get(t.id);
|
|
2454
|
+
const prior = t.recentFrom === undefined && !t.critical && b ? priorOnlyHold(pc, b, t) : null;
|
|
2072
2455
|
candidates.push({
|
|
2073
2456
|
kind: 'hold',
|
|
2457
|
+
...(prior !== null ? { prior } : {}),
|
|
2458
|
+
...(t.critical ? { critical: true } : {}),
|
|
2074
2459
|
// A border just taken from a weak opponent is held first: conceding it hands it back.
|
|
2075
2460
|
score: t.recentFrom !== undefined ? Infinity : t.worth / t.holdCost,
|
|
2076
2461
|
cost: t.holdCost,
|
|
@@ -2082,8 +2467,12 @@ function planPass(input, pass) {
|
|
|
2082
2467
|
// Already garrisoned for a bonus this turn completed (#122).
|
|
2083
2468
|
if (heldBorders.has(t.id))
|
|
2084
2469
|
return;
|
|
2470
|
+
// #420: a hold that breaks its one threat is a capture first (its hold still counts toward the cap);
|
|
2471
|
+
// any other plain hold past the total hold cap is conceded (its armies may still attack out).
|
|
2085
2472
|
if (holdAndBreak(t))
|
|
2086
2473
|
return;
|
|
2474
|
+
if (overCap(t))
|
|
2475
|
+
return concedePending(t, roomAt(t.id), true);
|
|
2087
2476
|
const pending = expansionLeft > 0 && t.worth < topValue && t.recentFrom === undefined ? Math.max(0, floor - expansionSpent) : 0;
|
|
2088
2477
|
const room = roomAt(t.id);
|
|
2089
2478
|
// #215: conceded, its armies may attack out (rule 1a) in the passes still to run.
|
|
@@ -2097,6 +2486,7 @@ function planPass(input, pass) {
|
|
|
2097
2486
|
hold(t);
|
|
2098
2487
|
},
|
|
2099
2488
|
});
|
|
2489
|
+
}
|
|
2100
2490
|
// A conceded unit's members, judged on their own now (rule 1a, against what is left).
|
|
2101
2491
|
const singleNow = (t, quiet) => {
|
|
2102
2492
|
if (t.critical)
|
|
@@ -2115,6 +2505,8 @@ function planPass(input, pass) {
|
|
|
2115
2505
|
concedeUnaffordable(t, room);
|
|
2116
2506
|
return;
|
|
2117
2507
|
}
|
|
2508
|
+
if (overCap(t))
|
|
2509
|
+
return concedeCapped(t, quiet);
|
|
2118
2510
|
hold(t);
|
|
2119
2511
|
heldBorders.add(t.id);
|
|
2120
2512
|
};
|
|
@@ -2160,13 +2552,28 @@ function planPass(input, pass) {
|
|
|
2160
2552
|
}
|
|
2161
2553
|
// PLAN-TEAMS C3.4: a capture of a player my teammate attacks this turn ranks above an equal one.
|
|
2162
2554
|
const teamFocused = (c) => Number(c.owner !== undefined && pc.teamFocus.has(c.owner));
|
|
2555
|
+
/** #417: the 1v1 race's tier: 0 a held bonus's gate or my commander's hold, 1 a race, 2 any other. */
|
|
2556
|
+
const raceTier = (c) => (c.kind === 'unit' || (c.kind === 'hold' && c.critical) ? 0 : c.kind === 'race' ? 1 : 2);
|
|
2163
2557
|
const ahead = (a, b) => Number(b.focus) - Number(a.focus) ||
|
|
2558
|
+
// #420: a hold sized only on the fog prior ranks after every capture.
|
|
2559
|
+
Number(a.prior !== undefined) - Number(b.prior !== undefined) ||
|
|
2560
|
+
// #417, the 1v1 race: held-bonus gates and my commander's hold, then the races, then everything else.
|
|
2561
|
+
(races.length ? raceTier(a) - raceTier(b) : 0) ||
|
|
2164
2562
|
// #201: ahead, every held bonus is held for the worst case before any capture (said below).
|
|
2165
2563
|
(holdPasses === 'worst' ? Number(b.kind === 'unit') - Number(a.kind === 'unit') : 0) ||
|
|
2166
|
-
(oneVsOne ? Number(a.kind === 'advance') - Number(b.kind === 'advance') : 0) ||
|
|
2564
|
+
(oneVsOne ? Number(a.kind === 'advance' || a.kind === 'stage') - Number(b.kind === 'advance' || b.kind === 'stage') : 0) ||
|
|
2167
2565
|
b.score - a.score;
|
|
2168
2566
|
const after = (a, b) => a.cost - b.cost || a.borders - b.borders || rank[a.kind] - rank[b.kind] || a.id - b.id;
|
|
2169
2567
|
candidates.sort((a, b) => ahead(a, b) || teamFocused(b) - teamFocused(a) || after(a, b));
|
|
2568
|
+
for (const c of candidates) {
|
|
2569
|
+
if (c.prior === undefined)
|
|
2570
|
+
continue;
|
|
2571
|
+
const passed = candidates.filter((d) => d.kind !== 'hold' && d.kind !== 'unit' && d.score < c.score);
|
|
2572
|
+
if (!passed.length)
|
|
2573
|
+
continue;
|
|
2574
|
+
const b = borders.get(c.id);
|
|
2575
|
+
rationale.push(`Hold ${label(c.id)} after the captures (#420): it needs ${c.cost} only against player ${b.player}'s ~${b.deploy}, the fog prior; against the stacks beside it plus the ~${c.prior} the evidence gives, it holds as it stands.`);
|
|
2576
|
+
}
|
|
2170
2577
|
if (pc.teamFocus.size)
|
|
2171
2578
|
for (const [i, c] of candidates.entries()) {
|
|
2172
2579
|
if (!teamFocused(c))
|
|
@@ -2187,6 +2594,13 @@ function planPass(input, pass) {
|
|
|
2187
2594
|
slots.forEach((i, k) => (candidates[i] = sorted[k]));
|
|
2188
2595
|
}
|
|
2189
2596
|
}
|
|
2597
|
+
// #421: a stockpile spend runs before every other capture; the holds keep their places.
|
|
2598
|
+
if (candidates.some((c) => c.spend)) {
|
|
2599
|
+
const spends = candidates.filter((c) => c.spend);
|
|
2600
|
+
const rest = candidates.filter((c) => !c.spend);
|
|
2601
|
+
const at = rest.findIndex((c) => c.kind !== 'hold' && c.kind !== 'unit');
|
|
2602
|
+
candidates.splice(0, candidates.length, ...(at < 0 ? [...rest, ...spends] : [...rest.slice(0, at), ...spends, ...rest.slice(at)]));
|
|
2603
|
+
}
|
|
2190
2604
|
// A held-bonus unit that pays for itself is funded before any capture that completes
|
|
2191
2605
|
// no bonus (an advance or a break, unless focused): at the first such capture, every
|
|
2192
2606
|
// unit still pending runs first, with the completions that outscore the weakest of them.
|
|
@@ -2262,11 +2676,11 @@ function planPass(input, pass) {
|
|
|
2262
2676
|
// #215, rule 0p.1: an advance ranks below every hold, a contested held bonus's included
|
|
2263
2677
|
// (#118 lets the captures go first, but in a 1v1 in contact not one that completes nothing):
|
|
2264
2678
|
// live, a +4 bonus's one border was left to fall while 15 went to a bonus 47 armies from done.
|
|
2265
|
-
if (oneVsOne && c.kind === 'advance' && !c.focus && !contestedDue) {
|
|
2679
|
+
if (oneVsOne && (c.kind === 'advance' || c.kind === 'stage' || c.kind === 'race') && !c.focus && !contestedDue) {
|
|
2266
2680
|
contestedDue = true;
|
|
2267
2681
|
settleContested(true);
|
|
2268
2682
|
}
|
|
2269
|
-
if ((c
|
|
2683
|
+
if (completesNothing(c) && !c.focus && !unitsDue) {
|
|
2270
2684
|
unitsDue = true;
|
|
2271
2685
|
// Those waiting for the expansion share outscore everything still to run.
|
|
2272
2686
|
for (const u of waiting.splice(0))
|
|
@@ -2285,7 +2699,7 @@ function planPass(input, pass) {
|
|
|
2285
2699
|
// completes nothing: when this one leaves too little for a hold still waiting, it is undone,
|
|
2286
2700
|
// the waiting holds are funded first, and it runs again on what is left (if it still fits).
|
|
2287
2701
|
const owed = deferred.filter((t) => !heldBorders.has(t.id) && !conceded.has(t.id));
|
|
2288
|
-
if ((c
|
|
2702
|
+
if (completesNothing(c) && !c.focus && owed.length) {
|
|
2289
2703
|
const restore = snapshot();
|
|
2290
2704
|
const spent = expansionSpent;
|
|
2291
2705
|
const left = expansionLeft;
|
|
@@ -2298,7 +2712,7 @@ function planPass(input, pass) {
|
|
|
2298
2712
|
expansionSpent = spent;
|
|
2299
2713
|
expansionLeft = left;
|
|
2300
2714
|
for (const t of owed)
|
|
2301
|
-
if (t.holdCost <= roomAt(t.id)) {
|
|
2715
|
+
if (t.holdCost <= roomAt(t.id) && !overCap(t)) {
|
|
2302
2716
|
rationale.push(`Hold ${label(t.id)} now after all: the capture that would have gone first completes no bonus and would leave too little to hold it later.`);
|
|
2303
2717
|
hold(t);
|
|
2304
2718
|
heldBorders.add(t.id);
|
|
@@ -2316,8 +2730,8 @@ function planPass(input, pass) {
|
|
|
2316
2730
|
if (heldBorders.has(t.id))
|
|
2317
2731
|
continue;
|
|
2318
2732
|
const room = roomAt(t.id);
|
|
2319
|
-
if (t.holdCost > room)
|
|
2320
|
-
concedePending(t, room);
|
|
2733
|
+
if (t.holdCost > room || overCap(t))
|
|
2734
|
+
concedePending(t, room, t.holdCost <= room);
|
|
2321
2735
|
else
|
|
2322
2736
|
hold(t);
|
|
2323
2737
|
}
|
|
@@ -2341,6 +2755,8 @@ function planPass(input, pass) {
|
|
|
2341
2755
|
for (const c of candidates)
|
|
2342
2756
|
if (c.target !== undefined && !captured.has(c.target) && targets.get(c.target)?.sources.some((x) => unlocked.has(x)))
|
|
2343
2757
|
c.run();
|
|
2758
|
+
// #285: a contested held bonus's borders facing one enemy stack take it when that costs less.
|
|
2759
|
+
captureInsteadOfHold(pc, ps, book, threats, hd, tgt, caps);
|
|
2344
2760
|
settleContested();
|
|
2345
2761
|
// #272: a conceded border attacks out for a free step into a bonus before it withdraws (and
|
|
2346
2762
|
// before rule 1c re-values the borders, so one whose bonus this completes is kept).
|
|
@@ -2355,10 +2771,18 @@ function planPass(input, pass) {
|
|
|
2355
2771
|
complete(p);
|
|
2356
2772
|
garrisonCompleted();
|
|
2357
2773
|
}
|
|
2774
|
+
// #439: the neutral in between toward a single-territory bonus two moves away, before any advance.
|
|
2775
|
+
if (goal !== 'complete-bonus')
|
|
2776
|
+
for (const st of stages) {
|
|
2777
|
+
stageTwoMove(pc, ps, st, gainWith, tryExpand);
|
|
2778
|
+
garrisonCompleted();
|
|
2779
|
+
}
|
|
2358
2780
|
for (const p of byCloseness) {
|
|
2359
2781
|
advance(p);
|
|
2360
2782
|
garrisonCompleted();
|
|
2361
2783
|
}
|
|
2784
|
+
// #285: as under `balanced`.
|
|
2785
|
+
captureInsteadOfHold(pc, ps, book, threats, hd, tgt, caps);
|
|
2362
2786
|
settleContested();
|
|
2363
2787
|
// #272: a conceded border attacks out for a free step into a bonus before it withdraws (and
|
|
2364
2788
|
// before rule 1c re-values the borders, so one whose bonus this completes is kept).
|
|
@@ -2528,7 +2952,7 @@ function planPass(input, pass) {
|
|
|
2528
2952
|
const beforeLeftover = new Map(ps.deployed);
|
|
2529
2953
|
const leftover = leftoverDeploy(pc, ps, book, threats, hd, tgt, saveStep, stack, open, stays);
|
|
2530
2954
|
let { strikeStack } = leftover;
|
|
2531
|
-
const { poolDeployed, staging } = leftover;
|
|
2955
|
+
const { poolDeployed, staging, offered } = leftover;
|
|
2532
2956
|
// #235: the Standing-still warning names the source the leftover actually stages on.
|
|
2533
2957
|
// Found by its text: earlier warnings may have been spliced out since (a revival, a dropped capture).
|
|
2534
2958
|
if (staging && standStill && staging.t === standStill.t && staging.from !== standStill.named) {
|
|
@@ -2597,7 +3021,11 @@ function planPass(input, pass) {
|
|
|
2597
3021
|
// ---- 5b. a neutral the leftover pays for (#218) (plan/after-leftover.ts) ----
|
|
2598
3022
|
// The strike stack concentrates for its strike, and a step's source saves toward it: neither spends.
|
|
2599
3023
|
const keepWhole = new Set([...(strikeStack ? [strikeStack.id] : []), ...(staging ? [staging.from] : [])]);
|
|
2600
|
-
afterLeftoverCaptures(pc, ps, book, threats, hd, tgt, caps, beforeLeftover, keepWhole, poolDeployed);
|
|
3024
|
+
const takenAfter = afterLeftoverCaptures(pc, ps, book, threats, hd, tgt, caps, beforeLeftover, keepWhole, poolDeployed);
|
|
3025
|
+
// #288: the rest of the leftover offered to another capture rides the expansion stack's attacks
|
|
3026
|
+
// after all when rule 5b took nothing from where it was offered.
|
|
3027
|
+
if (offered && !moves.some((m) => m.kind === 'attack' && m.from === offered.at && takenAfter.includes(m.to)))
|
|
3028
|
+
offered.revert();
|
|
2601
3029
|
// ---- efficient sizes (S2) ----
|
|
2602
3030
|
// An attack below its next kill breakpoint is topped up to it from armies that would sit
|
|
2603
3031
|
// idle on its source — never from a hold, a conceded border, my commander's territory, or
|
|
@@ -2848,6 +3276,8 @@ function planPass(input, pass) {
|
|
|
2848
3276
|
warnings.splice(i, 1);
|
|
2849
3277
|
rationale.push(`Drop the attack on ${label(t)}: it could send only ${sent} by the end of the turn, short of the ${rep.cost} that take it ${rep.sure ? `even if player ${rep.player} deploys its ~${rep.extra} there first` : `against the ~${rep.extra} player ${rep.player} put there on those turns`}, and my attacks on it failed before, its owner reinforcing it (#240); its armies stay where they are.`);
|
|
2850
3278
|
}
|
|
3279
|
+
// ---- #277: a held bonus funded before a second attack sized for the same deploy (plan/second-sizing.ts) ----
|
|
3280
|
+
fundFromSecondSizing(pc, ps, book, threats, hd, caps);
|
|
2851
3281
|
// #120: an attack on a player's territory still sized below its owner's deploy says what it
|
|
2852
3282
|
// faces if that deploy lands there first.
|
|
2853
3283
|
for (const m of moves) {
|
|
@@ -2865,6 +3295,35 @@ function planPass(input, pass) {
|
|
|
2865
3295
|
const aim = chanceAt(m.to);
|
|
2866
3296
|
warnings[w] = `Attack on enemy ${label(m.to)} assumes its owner does not reinforce it first: 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)}`}` : ''}.`;
|
|
2867
3297
|
}
|
|
3298
|
+
// ---- #361: single-army jabs from the armies still idle beyond each hold (plan/jabs.ts) ----
|
|
3299
|
+
const jabsOn = pc.opts.jabs ?? pc.siege !== undefined;
|
|
3300
|
+
// A jab never brings on #128's or #314's warning: a border that holds against two opponents
|
|
3301
|
+
// attacking it together keeps what holds it so, and one whose hold leaves enough that the attack's
|
|
3302
|
+
// survivors cannot take it next turn keeps that too (report.ts's #314 test).
|
|
3303
|
+
const thin = (x, have) => {
|
|
3304
|
+
const b = borders.get(x);
|
|
3305
|
+
if (!b || conceded.has(x) || b.movable <= 0)
|
|
3306
|
+
return false;
|
|
3307
|
+
const take = toTake(have);
|
|
3308
|
+
if (take === null || take <= b.threat)
|
|
3309
|
+
return false;
|
|
3310
|
+
const mineAfter = Math.max(0, have - straightKills(b.threat, rates.offensiveKillRate));
|
|
3311
|
+
const hisAfter = Math.max(0, b.threat - straightKills(have, rates.defensiveKillRate));
|
|
3312
|
+
const next = toTake(mineAfter);
|
|
3313
|
+
return next !== null && next <= hisAfter;
|
|
3314
|
+
};
|
|
3315
|
+
const jabSpare = (x) => {
|
|
3316
|
+
let spare = spareBeyondHold(x);
|
|
3317
|
+
const now = hd.stayAt(x) + unitsAt(x);
|
|
3318
|
+
if (!thin(x, now))
|
|
3319
|
+
while (spare > 0 && thin(x, now - spare))
|
|
3320
|
+
spare--;
|
|
3321
|
+
const pile = threats.forceAt(x, (n) => captured.has(n), { trend: true, allPlayers: true, pileOn: true });
|
|
3322
|
+
if (!pile?.split || pile.split.players.length < 2)
|
|
3323
|
+
return spare;
|
|
3324
|
+
return now > pile.split.takes ? Math.min(spare, now - pile.split.takes - 1) : spare;
|
|
3325
|
+
};
|
|
3326
|
+
const jabs = jabsOn ? planJabs(pc, ps, jabSpare, keepWhole, (t) => tgt.repulsed.has(t), pc.siege ? strikeStack?.id : undefined) : [];
|
|
2868
3327
|
// ---- Order Priority for a strike (rule 1s) (plan/move-order.ts) ----
|
|
2869
3328
|
const { strikeCard, strikeWho } = strikeOrderPriority(pc, ps, threats, hd, struck);
|
|
2870
3329
|
// #274: my commander's step toward safety, once every other order is planned (plan/commander.ts).
|
|
@@ -2882,10 +3341,17 @@ function planPass(input, pass) {
|
|
|
2882
3341
|
// #218: the main front's forecast at my whole income, for the game outlook to share.
|
|
2883
3342
|
if (ps.front)
|
|
2884
3343
|
plan.front = ps.front;
|
|
3344
|
+
if (jabs.length)
|
|
3345
|
+
plan.jabs = jabs;
|
|
3346
|
+
// #303: my income over the last turns, as rule 5's flat-income saving (plan/leftover.ts) read it.
|
|
3347
|
+
if (pc.incomeTrend)
|
|
3348
|
+
plan.incomeTrend = pc.incomeTrend;
|
|
2885
3349
|
// PLAN-TEAMS C3.3: the bonuses I share with a teammate (plan/team.ts).
|
|
2886
3350
|
const team = teamReport(pc, { ps, threats, hd, deploys: plan.deploys });
|
|
2887
3351
|
if (team)
|
|
2888
3352
|
plan.team = team;
|
|
3353
|
+
// #457: a neutral taken beside a truce partner may read as a breach to it (plan/relations.ts).
|
|
3354
|
+
warnTruceNeutrals(pc, plan);
|
|
2889
3355
|
if (truceReport) {
|
|
2890
3356
|
// T6: what a break would cost, against the plan's final orders (plan/relations.ts).
|
|
2891
3357
|
reportBreakLosses(pc, truceReport.relations, plan);
|
|
@@ -2920,6 +3386,18 @@ function planPass(input, pass) {
|
|
|
2920
3386
|
if (!heldBorders.has(m.id))
|
|
2921
3387
|
unheld.add(m.id);
|
|
2922
3388
|
runOutcome.set(plan, { bareSteps: [...caps.bareTaken].filter(gone).sort(byNum), held, unheld });
|
|
3389
|
+
if (tgt.allInTries.size)
|
|
3390
|
+
allInOutcome.set(plan, tgt.allInTries);
|
|
3391
|
+
if (pc.strikeShare > 0)
|
|
3392
|
+
shareOutcome.set(plan, pc.strikeShare);
|
|
3393
|
+
// #421: on a stockpile, the contested bonuses this plan does not complete that an all-in push could (planPushed).
|
|
3394
|
+
if (pc.pile && !input.stockpileAllIn) {
|
|
3395
|
+
const done = new Set(plan.expected.bonusesCompleted);
|
|
3396
|
+
const pushed = new Set([...(input.bonusPush?.allIn ?? []), ...(input.bonusPush?.dropped ?? [])]);
|
|
3397
|
+
const ids = contestedBonuses(g, state, mineSet, foe).filter((id) => !done.has(id) && !pushed.has(id));
|
|
3398
|
+
if (ids.length)
|
|
3399
|
+
pileAllInOutcome.set(plan, ids);
|
|
3400
|
+
}
|
|
2923
3401
|
// #274: a plan that walks my commander says so first.
|
|
2924
3402
|
if (pc.commanderAt?.retreat)
|
|
2925
3403
|
plan.warnings.unshift(commanderMoveWarning(pc.commanderAt.retreat, label));
|