@chrischall/warapp-mcp 0.6.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 +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +99 -6
- package/dist/analysis/accept-surrender.js +20 -2
- package/dist/analysis/calibrate.js +1 -0
- package/dist/analysis/card-support.js +175 -16
- package/dist/analysis/card-threats.js +68 -3
- 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 +12 -6
- package/dist/analysis/opponent-profile.js +46 -3
- package/dist/analysis/opponents.js +245 -19
- package/dist/analysis/outlook.js +323 -17
- package/dist/analysis/plan/after-leftover.js +4 -1
- package/dist/analysis/plan/captures.js +4 -3
- package/dist/analysis/plan/estimates.js +70 -6
- package/dist/analysis/plan/guard-off.js +2 -1
- package/dist/analysis/plan/holds.js +79 -6
- package/dist/analysis/plan/leftover.js +145 -5
- package/dist/analysis/plan/relations.js +115 -2
- package/dist/analysis/plan/shared.js +201 -11
- package/dist/analysis/plan/stand-still.js +2 -2
- package/dist/analysis/plan/stockpile.js +104 -0
- package/dist/analysis/plan/strike.js +34 -7
- package/dist/analysis/plan/targets.js +168 -53
- package/dist/analysis/plan/threats.js +108 -5
- package/dist/analysis/plan/transfers.js +11 -0
- package/dist/analysis/plan/two-move.js +70 -0
- package/dist/analysis/plan/vacated.js +124 -2
- package/dist/analysis/planner.js +302 -42
- package/dist/analysis/since-last.js +18 -5
- package/dist/board.js +36 -2
- package/dist/build-id.js +106 -0
- package/dist/bundle.js +14943 -10146
- package/dist/chat-automation.js +22 -0
- package/dist/client.js +14 -0
- package/dist/decision-log.js +1093 -0
- package/dist/finished-store.js +5 -1
- package/dist/lessons-store.js +322 -21
- package/dist/open-games.js +36 -16
- package/dist/outlook-log.js +42 -1
- package/dist/protocol/methods.js +4 -2
- package/dist/review-export.js +198 -0
- package/dist/state-bundle.js +62 -3
- package/dist/state-cli.js +5 -3
- package/dist/strategy/notes.js +56 -0
- package/dist/tools/accept-surrender.js +23 -9
- package/dist/tools/award.js +5 -1
- package/dist/tools/card-advice.js +77 -23
- package/dist/tools/card-support-advice.js +36 -7
- package/dist/tools/chat-advice.js +330 -0
- package/dist/tools/chat-inbox.js +15 -4
- package/dist/tools/chat.js +41 -11
- package/dist/tools/check-plan.js +14 -2
- package/dist/tools/decision-capture.js +459 -0
- package/dist/tools/end-of-game.js +146 -18
- package/dist/tools/game-kind.js +92 -0
- package/dist/tools/how-lost.js +7 -2
- package/dist/tools/index.js +3 -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 +49 -10
- package/dist/tools/profile-hook.js +62 -3
- package/dist/tools/profile-opponents.js +2 -0
- package/dist/tools/push.js +2 -2
- package/dist/tools/relations.js +2 -0
- package/dist/tools/scout.js +16 -2
- package/dist/tools/state.js +6 -1
- package/dist/tools/strategy.js +3 -3
- package/dist/tools/stress-opponents.js +2 -0
- package/dist/tools/surrender-pending.js +10 -1
- package/dist/tools/surrender.js +18 -3
- package/dist/tools/turn.js +313 -18
- package/dist/tools/where.js +3 -1
- package/dist/version.js +1 -1
- package/manifest.json +23 -2
- package/mint.yaml +23 -0
- package/package.json +1 -1
- package/server.json +20 -2
- package/skills/warapp-mcp/SKILL.md +42 -8
|
@@ -5,7 +5,7 @@ import { DEFAULT_BASE_INCOME } from '../player.js';
|
|
|
5
5
|
import { DEFENSE_DISCOUNT, HIDDEN_POOL_INCOMES, NEUTRAL_BORDER_COST, visibleState, WASTELAND_FACTOR, } from './shared.js';
|
|
6
6
|
import { teammateAt } from './state.js';
|
|
7
7
|
import { byNum } from './util.js';
|
|
8
|
-
import { denialsOf, emptyEnemiesOf } from './vacated.js';
|
|
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
11
|
/** The targets, the frontier costs and the bonus plans, in the order planPass defined them. */
|
|
@@ -102,6 +102,8 @@ export function captureTargets(pc, ps, input, threats, prev) {
|
|
|
102
102
|
*/
|
|
103
103
|
const bonusDropped = input.bonusPush?.dropped ?? new Set();
|
|
104
104
|
const droppedMembers = new Set([...bonusDropped].flatMap((id) => (g.bonusById.has(id) ? bonusTerritories(g, id).filter((t) => !mineSet.has(t)) : [])));
|
|
105
|
+
/** #421: the missing members of the contested bonuses a stockpile pushes all-in: targets, an opponent's included. */
|
|
106
|
+
const pileMembers = new Set([...(input.stockpileAllIn ?? [])].flatMap((id) => (g.bonusById.has(id) ? bonusTerritories(g, id).filter((t) => !mineSet.has(t)) : [])));
|
|
105
107
|
/**
|
|
106
108
|
* #240: territories my attacks failed on repeatedly while their owner reinforced them
|
|
107
109
|
* (`input.repulsed`, {@link repulsedAttacks}): still that opponent's, armies in view, next to mine,
|
|
@@ -159,7 +161,9 @@ export function captureTargets(pc, ps, input, threats, prev) {
|
|
|
159
161
|
const b = g.bonusById.get(bonusId);
|
|
160
162
|
if (!b)
|
|
161
163
|
continue;
|
|
162
|
-
|
|
164
|
+
// #421: a stockpile's push spends armies already on the board: capped at the payback horizon × its value.
|
|
165
|
+
const pile = input.stockpileAllIn?.has(bonusId) === true;
|
|
166
|
+
const cap = pile ? Math.max(0, pc.paybackTurns * b.value) : Math.max(0, Math.min(ALL_IN_VALUE_TURNS * b.value, pc.income));
|
|
163
167
|
const sized = [];
|
|
164
168
|
let why;
|
|
165
169
|
for (const t of bonusTerritories(g, bonusId).filter((x) => !mineSet.has(x))) {
|
|
@@ -184,7 +188,9 @@ export function captureTargets(pc, ps, input, threats, prev) {
|
|
|
184
188
|
}
|
|
185
189
|
const cost = sized.reduce((n, x) => n + x.cost, 0);
|
|
186
190
|
if (!why && cost > cap)
|
|
187
|
-
why =
|
|
191
|
+
why = pile
|
|
192
|
+
? `the push needs ${cost} armies, over the cap of ${cap} (${pc.paybackTurns} × its +${b.value}, #421)`
|
|
193
|
+
: `the push needs ${cost} armies, over the cap of ${cap} (${ALL_IN_VALUE_TURNS} × its +${b.value}, at most my income ${pc.income})`;
|
|
188
194
|
allInTries.set(bonusId, { feasible: !why, cost, cap, ...(why ? { detail: why } : {}) });
|
|
189
195
|
if (why)
|
|
190
196
|
continue;
|
|
@@ -246,6 +252,16 @@ export function captureTargets(pc, ps, input, threats, prev) {
|
|
|
246
252
|
warnings.push(`${label(t)} (player ${hiddenOwner}) borders my ${sources.map(label).join(', ')} and its armies are hidden by the fog: the threat from it counts ${bound} plus its deploy, and the win chance of an attack into it is unknown, so none is planned.`);
|
|
247
253
|
continue;
|
|
248
254
|
}
|
|
255
|
+
// #417, the breach force: land a static seat left, hidden now, is attacked at the 2-defender price
|
|
256
|
+
// (`defenceAt` reads it so), until it is taken or the fog shows another player there.
|
|
257
|
+
if (fogVacated(pc.vacated, st, t)) {
|
|
258
|
+
const cost = costAt(t);
|
|
259
|
+
if (cost !== null) {
|
|
260
|
+
targets.set(t, { id: t, cost, enemy: false, sources });
|
|
261
|
+
rationale.push(`${label(t)} is fogged and was player ${pc.vacated.get(t)}'s (out, no AI): its land behind the old border stands on ${VACATED_FOG_ARMIES} at most, so an attack into it is priced at ${VACATED_FOG_ARMIES} defenders (${cost} armies) (#417).`);
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
249
265
|
if (!st || st.owner.kind === 'unknown' || st.armies === null) {
|
|
250
266
|
warnings.push(`Fogged territory ${label(t)} borders my ${sources.map(label).join(', ')}: its armies are unknown (fog), so no attack is planned.`);
|
|
251
267
|
continue;
|
|
@@ -260,7 +276,7 @@ export function captureTargets(pc, ps, input, threats, prev) {
|
|
|
260
276
|
continue;
|
|
261
277
|
}
|
|
262
278
|
const enemy = st.owner.kind === 'player';
|
|
263
|
-
if (enemy && goal !== 'complete-bonus' && !(balanced && (breakMember.has(t) || counterAt.has(t)))) {
|
|
279
|
+
if (enemy && goal !== 'complete-bonus' && !(balanced && (breakMember.has(t) || counterAt.has(t))) && !pileMembers.has(t)) {
|
|
264
280
|
if (!leadStepsOn || unitsAt(t) > 0 || droppedMembers.has(t) || !g.map.bonuses.some((b) => b.value > 0 && bonusTs.get(b.id).includes(t)))
|
|
265
281
|
continue;
|
|
266
282
|
const defenders = defenceAt(t);
|
|
@@ -280,7 +296,8 @@ export function captureTargets(pc, ps, input, threats, prev) {
|
|
|
280
296
|
}
|
|
281
297
|
// Bonus passes work toward my own bonuses; under `balanced` enemy targets are only break candidates.
|
|
282
298
|
// #203: a lead step is a bonus target too.
|
|
283
|
-
|
|
299
|
+
// #421: a member of a contested bonus a stockpile pushes all-in is a bonus target too.
|
|
300
|
+
const bonusTarget = (t) => targets.has(t) && !(balanced && targets.get(t).enemy && !leadSteps.has(t) && !pileMembers.has(t));
|
|
284
301
|
return { targets, leadSteps, leadStepsOn, leadTry, leadNote, bonusTarget, repulsed, costFor, sizeOf, allInTries, bonusDropped, droppedMembers };
|
|
285
302
|
}
|
|
286
303
|
/** Rule 4d: what a capture adds to the frontier (#71), and the offence report (#72). */
|
|
@@ -392,9 +409,20 @@ export function bonusScoring(pc, ps, threats, prev) {
|
|
|
392
409
|
const { exposure } = threats;
|
|
393
410
|
const { targets, bonusTarget, survivorsOf, frontierDelta, scoreCost } = prev;
|
|
394
411
|
// ---- bonus scoring ----
|
|
395
|
-
/**
|
|
396
|
-
|
|
397
|
-
|
|
412
|
+
/**
|
|
413
|
+
* "N armies to finish", naming the fogged members counted in it (#101): those at the costliest visible
|
|
414
|
+
* member, and (#428) those costed as the game's neutral size.
|
|
415
|
+
*/
|
|
416
|
+
const fogNote = (f) => {
|
|
417
|
+
const parts = [
|
|
418
|
+
...(f.fogged ? [`${f.fogged} fogged member${f.fogged === 1 ? '' : 's'} counted at ${f.fogEach} each`] : []),
|
|
419
|
+
...(f.fogNeutral
|
|
420
|
+
? [`${f.fogNeutral.count} fogged member${f.fogNeutral.count === 1 ? '' : 's'} counted at ${f.fogNeutral.each} each: the game's neutral size, ${f.fogNeutral.size}`]
|
|
421
|
+
: []),
|
|
422
|
+
];
|
|
423
|
+
return parts.length ? ` (${parts.join('; ')})` : '';
|
|
424
|
+
};
|
|
425
|
+
const toFinish = (cost, f) => `${cost} armies to finish${fogNote(f)}`;
|
|
398
426
|
const plans = [];
|
|
399
427
|
/** #167: the share of the map's territories that started as wastelands, and what one costs to take and loses. */
|
|
400
428
|
const wasteShare = s.wastelands && s.wastelands.count > 0 && s.wastelands.size > 0 && g.territoryById.size > 0
|
|
@@ -410,6 +438,24 @@ export function bonusScoring(pc, ps, threats, prev) {
|
|
|
410
438
|
const negativeMember = new Set();
|
|
411
439
|
/** #201: a remembered neutral's rationale line (its index) and the bonuses it names. */
|
|
412
440
|
const rememberedSaid = new Map();
|
|
441
|
+
/** #428: the same for a member costed at its last sighting. */
|
|
442
|
+
const lastSeenSaid = new Map();
|
|
443
|
+
/** Says once per territory, naming every bonus it is costed in (#201, #428). */
|
|
444
|
+
const sayOnce = (said, t, b, tail) => {
|
|
445
|
+
const was = said.get(t);
|
|
446
|
+
if (was) {
|
|
447
|
+
was.bonuses.push(`${b.name} (#${b.id})`);
|
|
448
|
+
rationale[was.at] = `${was.bonuses.join(', ')}: ${tail}`;
|
|
449
|
+
}
|
|
450
|
+
else {
|
|
451
|
+
said.set(t, { at: rationale.length, bonuses: [`${b.name} (#${b.id})`] });
|
|
452
|
+
rationale.push(`${b.name} (#${b.id}): ${tail}`);
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
// #428: the game's neutral size, costed once: a fogged member no board showed, whose owner the fog hides.
|
|
456
|
+
const neutralSize = s.neutralArmies !== undefined && s.neutralArmies >= 0 ? s.neutralArmies : undefined;
|
|
457
|
+
const neutralCost = neutralSize !== undefined ? (costOf(neutralSize) ?? Infinity) : Infinity;
|
|
458
|
+
const neutralLoss = neutralSize !== undefined && Number.isFinite(neutralCost) ? Math.min(neutralCost - 1, straightKills(neutralSize, rates.defensiveKillRate)) + 1 : Infinity;
|
|
413
459
|
for (const b of [...g.map.bonuses].sort((x, y) => x.id - y.id)) {
|
|
414
460
|
const isFocus = focus.has(b.id);
|
|
415
461
|
const ts = bonusTerritories(g, b.id);
|
|
@@ -460,43 +506,62 @@ export function bonusScoring(pc, ps, threats, prev) {
|
|
|
460
506
|
rationale.push(`Skip bonus ${b.name} (#${b.id}): completing it costs more income than it pays (net ${net}).`);
|
|
461
507
|
continue;
|
|
462
508
|
}
|
|
463
|
-
// Armies to finish (#101): every missing member's capture cost. A fogged member
|
|
464
|
-
//
|
|
465
|
-
//
|
|
509
|
+
// Armies to finish (#101): every missing member's capture cost. A fogged member a static seat left
|
|
510
|
+
// is priced by #417 first (below); any other is costed from what is known of it (#428): its last sighting on my boards (unless the fog shows another owner
|
|
511
|
+
// now), else (#201) its size on the picking board, else the game's neutral size (when its owner is
|
|
512
|
+
// hidden too); only with none of those does it count at its bonus's costliest visible missing
|
|
513
|
+
// member (counting it as free made the figure jump when it came into view; 65 finished-game plans
|
|
514
|
+
// counted every one at 208); with none visible either, the bonus cannot be costed.
|
|
466
515
|
let cost = 0;
|
|
467
516
|
let worst = 0;
|
|
468
517
|
let fogged = 0;
|
|
518
|
+
let foggedNeutral = 0;
|
|
469
519
|
// #125: the economy test charges the armies lost, not the armies sent.
|
|
470
520
|
let loss = 0;
|
|
471
521
|
let worstLoss = 0;
|
|
522
|
+
const known = (t, armies) => {
|
|
523
|
+
const c = costAt(t, armies) ?? Infinity;
|
|
524
|
+
cost += c;
|
|
525
|
+
worst = Math.max(worst, c);
|
|
526
|
+
const l = Math.min(c - 1, straightKills(armies, rates.defensiveKillRate)) + 1;
|
|
527
|
+
loss += l;
|
|
528
|
+
worstLoss = Math.max(worstLoss, l);
|
|
529
|
+
};
|
|
530
|
+
/** #417: the fogged members a static seat left, each with its cost and loss at VACATED_FOG_ARMIES. */
|
|
531
|
+
const vacatedFog = [];
|
|
472
532
|
for (const t of remaining) {
|
|
473
533
|
const st = state.get(t);
|
|
474
534
|
if (!st || st.owner.kind === 'unknown' || st.armies === null) {
|
|
535
|
+
// #417 first: land a static seat left is thin behind its border stack: costed at most at
|
|
536
|
+
// VACATED_FOG_ARMIES defenders, and never raising what another fogged member counts at.
|
|
537
|
+
const left = pc.vacated.get(t);
|
|
538
|
+
if (left !== undefined) {
|
|
539
|
+
const c = costAt(t, VACATED_FOG_ARMIES) ?? Infinity;
|
|
540
|
+
vacatedFog.push({ t, left, c, l: Math.min(c - 1, straightKills(VACATED_FOG_ARMIES, rates.defensiveKillRate)) + 1 });
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
const shown = st?.owner.kind === 'player' ? st.owner.playerId : undefined;
|
|
544
|
+
// #428: its last sighting, under the owner the fog shows now (or any, when it shows none).
|
|
545
|
+
const seen = opts.lastSeen?.get(t);
|
|
546
|
+
if (seen && (shown === undefined || seen.owner === shown)) {
|
|
547
|
+
known(t, seen.armies);
|
|
548
|
+
if (remaining.some(bonusTarget))
|
|
549
|
+
sayOnce(lastSeenSaid, t, b, `${label(t)}, fogged now, was last seen at ${seen.armies} armies (#428): costed at that.`);
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
475
552
|
// #201: a neutral the picking board showed keeps its size (an owner the fog shows is not one).
|
|
476
553
|
const was = opts.rememberedNeutrals?.get(t);
|
|
477
|
-
if (was === undefined ||
|
|
478
|
-
|
|
554
|
+
if (was === undefined || shown !== undefined) {
|
|
555
|
+
// #428: a member whose owner is hidden too is costed as the game's neutral size, when known.
|
|
556
|
+
if (shown === undefined && Number.isFinite(neutralCost))
|
|
557
|
+
foggedNeutral++;
|
|
558
|
+
else
|
|
559
|
+
fogged++;
|
|
479
560
|
continue;
|
|
480
561
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
const l = Math.min(c - 1, straightKills(was, rates.defensiveKillRate)) + 1;
|
|
485
|
-
loss += l;
|
|
486
|
-
worstLoss = Math.max(worstLoss, l);
|
|
487
|
-
if (remaining.some(bonusTarget)) {
|
|
488
|
-
// Said once per territory, naming every bonus it is costed in.
|
|
489
|
-
const said = rememberedSaid.get(t);
|
|
490
|
-
const tail = `${label(t)}, fogged now, was a neutral of ${was} on the picking board (#201): costed at that.`;
|
|
491
|
-
if (said) {
|
|
492
|
-
said.bonuses.push(`${b.name} (#${b.id})`);
|
|
493
|
-
rationale[said.at] = `${said.bonuses.join(', ')}: ${tail}`;
|
|
494
|
-
}
|
|
495
|
-
else {
|
|
496
|
-
rememberedSaid.set(t, { at: rationale.length, bonuses: [`${b.name} (#${b.id})`] });
|
|
497
|
-
rationale.push(`${b.name} (#${b.id}): ${tail}`);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
562
|
+
known(t, was);
|
|
563
|
+
if (remaining.some(bonusTarget))
|
|
564
|
+
sayOnce(rememberedSaid, t, b, `${label(t)}, fogged now, was a neutral of ${was} on the picking board (#201): costed at that.`);
|
|
500
565
|
continue;
|
|
501
566
|
}
|
|
502
567
|
const c = costAt(t) ?? Infinity;
|
|
@@ -506,31 +571,51 @@ export function bonusScoring(pc, ps, threats, prev) {
|
|
|
506
571
|
loss += l;
|
|
507
572
|
worstLoss = Math.max(worstLoss, l);
|
|
508
573
|
}
|
|
509
|
-
|
|
510
|
-
|
|
574
|
+
// #417: a member a static seat left counts at the lesser of its VACATED_FOG_ARMIES cost and the
|
|
575
|
+
// costliest member in view; with none in view (only fog), at that cost.
|
|
576
|
+
const inView = remaining.length - fogged - foggedNeutral - vacatedFog.length > 0;
|
|
577
|
+
for (const v of vacatedFog) {
|
|
578
|
+
const c = inView ? Math.min(v.c, worst) : v.c;
|
|
579
|
+
cost += c;
|
|
580
|
+
loss += inView ? Math.min(v.l, worstLoss) : v.l;
|
|
581
|
+
if (remaining.some(bonusTarget))
|
|
582
|
+
sayOnce(rememberedSaid, v.t, b, `${label(v.t)}, fogged now, was player ${v.left}'s (out, no AI): its land behind a border stack stands on ${VACATED_FOG_ARMIES} at most, so it is costed at ${c}, not at a stack in view (#417).`);
|
|
583
|
+
}
|
|
584
|
+
let fogEach = fogged ? (inView ? worst : Infinity) : 0;
|
|
585
|
+
let fogLoss = fogged ? (inView ? worstLoss : Infinity) : 0;
|
|
586
|
+
let neutralEach = foggedNeutral ? neutralCost : 0;
|
|
587
|
+
let neutralEachLoss = foggedNeutral ? neutralLoss : 0;
|
|
511
588
|
// #167: with automatic Wastelands, a fogged member may be one: its expected surcharge over an
|
|
512
589
|
// ordinary member is (wastelands ÷ territories on the map) × (a wasteland's cost − this one's).
|
|
513
|
-
if (wasteShare > 0 && fogged
|
|
514
|
-
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
590
|
+
if (wasteShare > 0 && (fogged || foggedNeutral)) {
|
|
591
|
+
// The loss rises with the cost only (an expected surcharge of 0 adds no loss either).
|
|
592
|
+
const surcharge = (each, eachLoss) => {
|
|
593
|
+
const extra = Number.isFinite(each) ? Math.ceil(wasteShare * Math.max(0, wasteCost - each)) : 0;
|
|
594
|
+
return { extra, extraLoss: extra > 0 ? Math.ceil(wasteShare * Math.max(0, wasteLoss - eachLoss)) : 0 };
|
|
595
|
+
};
|
|
596
|
+
const a = fogged ? surcharge(fogEach, fogLoss) : { extra: 0, extraLoss: 0 };
|
|
597
|
+
const n = foggedNeutral ? surcharge(neutralEach, neutralEachLoss) : { extra: 0, extraLoss: 0 };
|
|
598
|
+
fogEach += a.extra;
|
|
599
|
+
fogLoss += a.extraLoss;
|
|
600
|
+
neutralEach += n.extra;
|
|
601
|
+
neutralEachLoss += n.extraLoss;
|
|
602
|
+
const count = (a.extra > 0 ? fogged : 0) + (n.extra > 0 ? foggedNeutral : 0);
|
|
603
|
+
const expected = a.extra * fogged + n.extra * foggedNeutral;
|
|
604
|
+
if (expected > 0 && remaining.some(bonusTarget))
|
|
605
|
+
rationale.push(`${b.name} (#${b.id}): its ${count} fogged member${count === 1 ? '' : 's'} may be ${count === 1 ? 'a wasteland' : 'wastelands'} (${s.wastelands.count} of the map's ${g.territoryById.size} territories start at ${s.wastelands.size}): +${expected} armies expected.`);
|
|
522
606
|
}
|
|
523
|
-
cost += fogged * fogEach;
|
|
524
|
-
loss += fogged * fogLoss;
|
|
607
|
+
cost += fogged * fogEach + foggedNeutral * neutralEach;
|
|
608
|
+
loss += fogged * fogLoss + foggedNeutral * neutralEachLoss;
|
|
609
|
+
const fogNeutral = foggedNeutral ? { count: foggedNeutral, each: neutralEach, size: neutralSize } : undefined;
|
|
525
610
|
if (b.value > 0)
|
|
526
|
-
finishCost.set(b.id, { cost, value: b.value, net, fogged, fogEach });
|
|
611
|
+
finishCost.set(b.id, { cost, value: b.value, net, fogged, fogEach, ...(fogNeutral ? { fogNeutral } : {}) });
|
|
527
612
|
const economic = isFocus || (loss <= paybackTurns * net && worstLoss <= WASTELAND_FACTOR * net);
|
|
528
613
|
for (const t of remaining)
|
|
529
614
|
(economic ? economicMember : uneconomicMember).add(t);
|
|
530
615
|
if (!remaining.some(bonusTarget))
|
|
531
616
|
continue;
|
|
532
617
|
if (!economic) {
|
|
533
|
-
rationale.push(`Skip bonus ${b.name} (#${b.id}): uneconomic for +${net === b.value ? b.value : `${b.value} (net +${net})`} (${toFinish(cost, fogged, fogEach)}, losing ~${loss}; ${worstLoss} lost on its costliest territory).`);
|
|
618
|
+
rationale.push(`Skip bonus ${b.name} (#${b.id}): uneconomic for +${net === b.value ? b.value : `${b.value} (net +${net})`} (${toFinish(cost, { fogged, fogEach, fogNeutral })}, losing ~${loss}; ${worstLoss} lost on its costliest territory).`);
|
|
534
619
|
continue;
|
|
535
620
|
}
|
|
536
621
|
// R3: what holding the completed bonus's frontier would cost next turn (each
|
|
@@ -564,6 +649,7 @@ export function bonusScoring(pc, ps, threats, prev) {
|
|
|
564
649
|
frontier,
|
|
565
650
|
fogged,
|
|
566
651
|
fogEach,
|
|
652
|
+
...(fogNeutral ? { fogNeutral } : {}),
|
|
567
653
|
});
|
|
568
654
|
}
|
|
569
655
|
const ratio = (p) => {
|
|
@@ -588,9 +674,10 @@ export function closestBonus(pc, ps, input, prev) {
|
|
|
588
674
|
// While no bonus is held (and in the opening and expansion phases), expansion goes to the bonus
|
|
589
675
|
// closest to completion — fewest turns to finish at this income (its armies to finish, counting
|
|
590
676
|
// the members I hold, over the income) — then the next closest, instead of one capture into each
|
|
591
|
-
// of several large bonuses by value per army. Bonuses as close as each other
|
|
592
|
-
//
|
|
593
|
-
//
|
|
677
|
+
// of several large bonuses by value per army. Bonuses as close as each other go by the income per
|
|
678
|
+
// army of every bonus their capture completes (#438: a pair bonus on top of a single-territory one
|
|
679
|
+
// counts), then a bonus advanced last turn (a member captured since `previousBoard`) first, then the
|
|
680
|
+
// score order (value per army, rule 4). Focused bonuses come first.
|
|
594
681
|
const holdsBonus = g.map.bonuses.some((b) => {
|
|
595
682
|
const ts = bonusTs.get(b.id);
|
|
596
683
|
return b.value > 0 && ts.length > 0 && ts.every((t) => mineSet.has(t));
|
|
@@ -621,10 +708,25 @@ export function closestBonus(pc, ps, input, prev) {
|
|
|
621
708
|
/** Turns to finish a bonus at this income, and at least its depth (with no income, its armies to finish). */
|
|
622
709
|
const turnsOf = (p) => (income > 0 ? Math.max(Math.ceil(p.cost / income), depthOf(p)) : p.cost);
|
|
623
710
|
const scoreRank = new Map(plans.map((p, i) => [p.bonusId, i]));
|
|
624
|
-
/**
|
|
711
|
+
/**
|
|
712
|
+
* #438: every bonus a plan's capture completes — each plan whose missing members are all among
|
|
713
|
+
* its own (a pair bonus beside a single-territory one) — with their net income added up.
|
|
714
|
+
*/
|
|
715
|
+
const completesWith = (p) => plans.filter((q) => q.remaining.every((t) => p.remaining.includes(t)));
|
|
716
|
+
const incomeOf = (p) => completesWith(p).reduce((n, q) => n + q.net, 0);
|
|
717
|
+
/** #438: that income per army, on the score's cost (`ratio`, scaled from this bonus's net to the sum). */
|
|
718
|
+
const perArmy = (p) => {
|
|
719
|
+
const r = prev.ratio(p);
|
|
720
|
+
return Number.isFinite(r) && p.net > 0 ? (r * incomeOf(p)) / p.net : r;
|
|
721
|
+
};
|
|
722
|
+
/**
|
|
723
|
+
* Bonus plans closest to completion first (focus first; ties: the income per army of every bonus
|
|
724
|
+
* the capture completes, #438, then advanced last turn, then the score order).
|
|
725
|
+
*/
|
|
625
726
|
const byCloseness = committing
|
|
626
727
|
? [...plans].sort((a, b) => Number(b.focus) - Number(a.focus) ||
|
|
627
728
|
turnsOf(a) - turnsOf(b) ||
|
|
729
|
+
perArmy(b) - perArmy(a) ||
|
|
628
730
|
Number(advancedLast.has(b.bonusId)) - Number(advancedLast.has(a.bonusId)) ||
|
|
629
731
|
scoreRank.get(a.bonusId) - scoreRank.get(b.bonusId))
|
|
630
732
|
: plans;
|
|
@@ -638,9 +740,22 @@ export function closestBonus(pc, ps, input, prev) {
|
|
|
638
740
|
? `${profile.phase[0].toUpperCase()}${profile.phase.slice(1)} phase${profile.phase === 'opening' || profile.phase === 'expansion' ? '' : ', neutrals in reach'}`
|
|
639
741
|
: 'No bonus held';
|
|
640
742
|
rationale.push(`${why}: expansion goes to the bonus closest to completion first — ${byCloseness
|
|
641
|
-
.map((p, i) => `${bonusName(p.bonusId)} ${i ? p.cost : `${p.cost} armies to finish`}${fogNote(p
|
|
743
|
+
.map((p, i) => `${bonusName(p.bonusId)} ${i ? p.cost : `${p.cost} armies to finish`}${fogNote(p)}, ${turnsText(p)}${i || income <= 0 ? '' : ` at income ${income}`}`)
|
|
642
744
|
.join(', ')} — and a farther bonus gets only armies the closer ones cannot use.`);
|
|
643
745
|
const top = byCloseness.find((p) => !p.focus);
|
|
746
|
+
// #438: a capture that completes more than one bonus says what they add up to per army.
|
|
747
|
+
const said = new Set();
|
|
748
|
+
for (const p of byCloseness) {
|
|
749
|
+
const all = completesWith(p);
|
|
750
|
+
const key = [...p.remaining].sort((x, y) => x - y).join(',');
|
|
751
|
+
// Only where it ranks: another bonus as close that this capture does not complete.
|
|
752
|
+
const rivals = byCloseness.some((q) => !all.includes(q) && !q.focus && turnsOf(q) === turnsOf(p));
|
|
753
|
+
if (all.length < 2 || !rivals || said.has(key))
|
|
754
|
+
continue;
|
|
755
|
+
said.add(key);
|
|
756
|
+
const names = all.map((q) => bonusName(q.bonusId));
|
|
757
|
+
rationale.push(`${names.slice(0, -1).join(', ')} and ${names.at(-1)} complete together for ${p.cost} armies: +${incomeOf(p)} next-turn income, ${(incomeOf(p) / p.cost).toFixed(2)} per army — ranked on that among bonuses as close (#438).`);
|
|
758
|
+
}
|
|
644
759
|
for (const p of byCloseness.filter((x) => advancedLast.has(x.bonusId))) {
|
|
645
760
|
if (p === top)
|
|
646
761
|
rationale.push(`${bonusName(p.bonusId)} keeps priority: I advanced it last turn, and no bonus is strictly closer to completion.`);
|
|
@@ -662,7 +777,7 @@ export function closestBonus(pc, ps, input, prev) {
|
|
|
662
777
|
const nearest = committing ? byCloseness.find((p) => !p.focus) ?? byCloseness[0] : undefined;
|
|
663
778
|
ps.warnings.push(`${mine.length} territories, no bonus: the captures are spread (income ${income}, base ${base}). ` +
|
|
664
779
|
(nearest
|
|
665
|
-
? `Nearest bonus to complete: ${bonusName(nearest.bonusId)}, ${nearest.cost} armies to finish${fogNote(nearest
|
|
780
|
+
? `Nearest bonus to complete: ${bonusName(nearest.bonusId)}, ${nearest.cost} armies to finish${fogNote(nearest)}, ` +
|
|
666
781
|
`${turnsText(nearest)}${income > 0 ? ` at income ${income}` : ''} (rule 4f).`
|
|
667
782
|
: 'No bonus is worth completing from here.') +
|
|
668
783
|
' Complete one before taking more territories outside it (#319).');
|
|
@@ -14,9 +14,9 @@ import { territoryIncome } from '../player.js';
|
|
|
14
14
|
import { simTerritories } from '../turn-sim.js';
|
|
15
15
|
import { byNum } from './util.js';
|
|
16
16
|
/** Read the threats against my territories, and state them. */
|
|
17
|
-
export function threatsPhase(pc, ps, input) {
|
|
17
|
+
export function threatsPhase(pc, ps, input, valueOf) {
|
|
18
18
|
const src = threatSources(pc, ps, input);
|
|
19
|
-
const forces = threatForces(pc, ps, src);
|
|
19
|
+
const forces = threatForces(pc, ps, src, valueOf);
|
|
20
20
|
const { borders, facing, borderAt, safeAtStart } = borderThreats(pc, ps, input, src, forces);
|
|
21
21
|
const { growthOf, deployReaching, reinforcementAt, holdArmies, bombSized, hiddenFoe, hiddenMovable, hiddenPool, } = src;
|
|
22
22
|
const { chainAt, stacksAt, forceAt, threatAt, nextTurnAt, expectedAt, exposure } = forces;
|
|
@@ -32,6 +32,8 @@ export function threatsPhase(pc, ps, input) {
|
|
|
32
32
|
return {
|
|
33
33
|
...seen,
|
|
34
34
|
growthOf,
|
|
35
|
+
/** #420: each opponent's full-deploy border and the borders its top-up sizes (the leftover's revival reads it). */
|
|
36
|
+
oneBorder: forces.oneBorder,
|
|
35
37
|
/** #290: the previous board as given (the leftover reads which enemy stacks grew since). */
|
|
36
38
|
previousBoard: input.previousBoard,
|
|
37
39
|
deployReaching,
|
|
@@ -326,6 +328,20 @@ export function threatSources(pc, ps, input) {
|
|
|
326
328
|
warnings.push(`Player ${l.player}'s stack of ${l.armies} armies last seen on ${label(l.seenOn)} on turn ${l.turn} is out of view and can stand on ${at.slice(0, MAX_NAMED_REVEALS).join('; ')}${more}, by next turn, and attack the turn after with up to ${l.movable} plus its deploy: not counted in this turn's holds${multiNote}.`);
|
|
327
329
|
}
|
|
328
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* #420: each opponent's largest top-up seen (its track's `topUp`: the most one of its stacks beside my
|
|
333
|
+
* land grew in one turn). None under an explicit `enemyDeploy` (the caller's figure stands as given).
|
|
334
|
+
*/
|
|
335
|
+
const topUpOf = new Map();
|
|
336
|
+
if (!custom)
|
|
337
|
+
for (const tr of input.tracks ?? [])
|
|
338
|
+
if (foe(tr.playerId) && typeof tr.topUp === 'number')
|
|
339
|
+
topUpOf.set(tr.playerId, tr.topUp);
|
|
340
|
+
/** #420 (P1 amended): the quiet neighbours with a top-up seen, by player. */
|
|
341
|
+
const quietOf = new Map();
|
|
342
|
+
for (const q of input.quiet ?? [])
|
|
343
|
+
if (topUpOf.has(q.player))
|
|
344
|
+
quietOf.set(q.player, { contactTurns: q.contactTurns, attacks: q.attacks });
|
|
329
345
|
return {
|
|
330
346
|
growthOf,
|
|
331
347
|
teamOf,
|
|
@@ -339,10 +355,12 @@ export function threatSources(pc, ps, input) {
|
|
|
339
355
|
hiddenMovable,
|
|
340
356
|
hiddenPool,
|
|
341
357
|
lostAt,
|
|
358
|
+
topUpOf,
|
|
359
|
+
quietOf,
|
|
342
360
|
};
|
|
343
361
|
}
|
|
344
362
|
/** What each opponent can bring against one territory: its stacks, its deploy, its Multi-Attack chains (#199). */
|
|
345
|
-
export function threatForces(pc, ps, src) {
|
|
363
|
+
export function threatForces(pc, ps, src, valueOf) {
|
|
346
364
|
const { g, board, s, foe, territories: state, mineSet, unitsAt, guard, rates, toTake, ffaLeader, untrustedAt } = pc;
|
|
347
365
|
const { captured } = ps;
|
|
348
366
|
/**
|
|
@@ -503,6 +521,49 @@ export function threatForces(pc, ps, src) {
|
|
|
503
521
|
}
|
|
504
522
|
return byPlayer;
|
|
505
523
|
};
|
|
524
|
+
/**
|
|
525
|
+
* #420 (owner decision of 2026-11-20, "One opponent's deploy"): an opponent deploys its income in one
|
|
526
|
+
* place, so its full deploy sizes only its single most valuable border of mine (by protected value —
|
|
527
|
+
* `valueOf` —, then its movable armies beside it, then id); each other border of mine its stacks face is
|
|
528
|
+
* sized at those stacks plus its largest top-up seen (`topUpOf`), never above the full deploy. `capAt`:
|
|
529
|
+
* by my territory, the players capped there and the figure; `primary`: each such player's full border.
|
|
530
|
+
* Not on my commander's territory (rule 1k's worst case), nor for an untrusted estimate (#275) at that
|
|
531
|
+
* border, a player with no top-up seen, or one facing a single border of mine. A quiet neighbour
|
|
532
|
+
* (`quietOf`, #420's P1 amendment) has every border capped so, its most valuable one included, and no
|
|
533
|
+
* `primary`. Judged on the board as it stands (no territory gone) and built once.
|
|
534
|
+
*/
|
|
535
|
+
let oneBorderMemo;
|
|
536
|
+
const oneBorder = () => {
|
|
537
|
+
if (oneBorderMemo)
|
|
538
|
+
return oneBorderMemo;
|
|
539
|
+
oneBorderMemo = { capAt: new Map(), primary: new Map() };
|
|
540
|
+
if (!src.topUpOf.size)
|
|
541
|
+
return oneBorderMemo;
|
|
542
|
+
const facing = new Map();
|
|
543
|
+
for (const t of [...pc.mine].sort(byNum))
|
|
544
|
+
for (const [player, p] of stacksAt(t, () => false, false)) {
|
|
545
|
+
if (!src.topUpOf.has(player))
|
|
546
|
+
continue;
|
|
547
|
+
facing.set(player, [...(facing.get(player) ?? []), { t, movable: p.stacks.reduce((n, x) => n + x.movable, 0) }]);
|
|
548
|
+
}
|
|
549
|
+
for (const [player, list] of [...facing].sort((a, b) => a[0] - b[0])) {
|
|
550
|
+
// #420 (P1 amended): a quiet neighbour's every border, its most valuable one included.
|
|
551
|
+
const quiet = src.quietOf.has(player);
|
|
552
|
+
if (list.length < 2 && !quiet)
|
|
553
|
+
continue;
|
|
554
|
+
const ranked = [...list].sort((a, b) => valueOf(b.t) - valueOf(a.t) || b.movable - a.movable || a.t - b.t);
|
|
555
|
+
if (!quiet)
|
|
556
|
+
oneBorderMemo.primary.set(player, ranked[0].t);
|
|
557
|
+
for (const { t } of quiet ? ranked : ranked.slice(1)) {
|
|
558
|
+
if (pc.myCommanders.has(t) || untrustedAt(player, t) > 0)
|
|
559
|
+
continue;
|
|
560
|
+
const m = oneBorderMemo.capAt.get(t) ?? new Map();
|
|
561
|
+
m.set(player, src.topUpOf.get(player));
|
|
562
|
+
oneBorderMemo.capAt.set(t, m);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return oneBorderMemo;
|
|
566
|
+
};
|
|
506
567
|
/**
|
|
507
568
|
* #199: the force of a Multi-Attack chain onto my `t`: its player's, its armies all of it (the
|
|
508
569
|
* deploy that reaches its stack is already inside them), no growth or separate deploy.
|
|
@@ -531,9 +592,12 @@ export function threatForces(pc, ps, src) {
|
|
|
531
592
|
.map(([player, p]) => {
|
|
532
593
|
// #275 (b): a held bonus's border is sized for an untrusted estimate's figure, never below the estimate
|
|
533
594
|
// (#293: under Local Deployment, what of that figure can reach these stacks).
|
|
534
|
-
const
|
|
595
|
+
const full = truced === player
|
|
535
596
|
? 0
|
|
536
597
|
: deployReaching(player, [...p.stacks.map((x) => x.id), ...(p.behind ?? [])], Math.max(pc.deployOf(player), untrustedAt(player, t)));
|
|
598
|
+
// #420: off its most valuable border, the stack plus its largest top-up seen.
|
|
599
|
+
const cap = oneBorder().capAt.get(t)?.get(player);
|
|
600
|
+
const deploy = cap !== undefined ? Math.min(full, cap) : full;
|
|
537
601
|
const growth = truced === player ? 0 : p.growth;
|
|
538
602
|
const movable = p.stacks.reduce((n, x) => n + x.movable, 0);
|
|
539
603
|
const add = Math.max(deploy, growth);
|
|
@@ -643,6 +707,7 @@ export function threatForces(pc, ps, src) {
|
|
|
643
707
|
return out;
|
|
644
708
|
};
|
|
645
709
|
return {
|
|
710
|
+
oneBorder,
|
|
646
711
|
chainAt,
|
|
647
712
|
stacksAt,
|
|
648
713
|
forceAt,
|
|
@@ -775,6 +840,29 @@ export function borderThreats(pc, ps, input, src, forces) {
|
|
|
775
840
|
rationale.push(`My commander's territory ${label(t)} is held against the worst case (#274), ~${b.threat}: ${w.players.length > 1 ? `players ${w.players.join(' and ')}` : `player ${w.players[0]}`}'s whole deploy, ~${w.deploy} (never below my own income), plus the ${w.stacks} movable armies ${w.players.length > 1 ? 'they have' : 'it has'} within two moves of it.`);
|
|
776
841
|
}
|
|
777
842
|
}
|
|
843
|
+
// #420: say where one opponent's full deploy is sized, and which borders take its top-up instead.
|
|
844
|
+
{
|
|
845
|
+
const { capAt, primary } = forces.oneBorder();
|
|
846
|
+
for (const [player, q] of [...src.quietOf].sort((a, b) => a[0] - b[0])) {
|
|
847
|
+
const sized = [...capAt].filter(([t, m]) => borders.has(t) && m.has(player)).map(([t]) => t).sort(byNum);
|
|
848
|
+
if (!sized.length)
|
|
849
|
+
continue;
|
|
850
|
+
rationale.push(`Player ${player} ${q.attacks ? `has attacked me on ${q.attacks} of ${q.contactTurns} contact turns, and not since it was read quiet` : `has not attacked me in ${q.contactTurns} contact turns`} (#420, P1 amended: a quiet neighbour): ${sized.map(label).join(', ')} ${sized.length === 1 ? 'is' : 'are'} sized at its stack beside ${sized.length === 1 ? 'it' : 'them'} plus its largest top-up seen, +${src.topUpOf.get(player)}, not its ~${pc.deployOf(player)} deploy, until its first attack on me.`);
|
|
851
|
+
}
|
|
852
|
+
for (const [player, top] of [...primary].sort((a, b) => a[0] - b[0])) {
|
|
853
|
+
// The deploy its most valuable border is sized for (under Local Deployment, what reaches it).
|
|
854
|
+
const at = borders.get(top);
|
|
855
|
+
const full = at && at.player === player && !at.chain && !at.commanderWorst ? at.deploy : pc.deployOf(player);
|
|
856
|
+
const rest = [...capAt]
|
|
857
|
+
.filter(([t, m]) => borders.has(t) && m.has(player) && m.get(player) < full)
|
|
858
|
+
.map(([t]) => t)
|
|
859
|
+
.sort(byNum);
|
|
860
|
+
if (!rest.length)
|
|
861
|
+
continue;
|
|
862
|
+
const one = rest.length === 1;
|
|
863
|
+
rationale.push(`Player ${player} deploys its ~${full} in one place (#420): its full deploy is sized only on its most valuable border, ${label(top)}; ${rest.map(label).join(', ')} ${one ? 'is' : 'are'} sized at its stack beside ${one ? 'it' : 'them'} plus its largest top-up seen, +${capAt.get(rest[0]).get(player)} (the most one of its stacks beside my land grew in a turn).`);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
778
866
|
// #199: say where a Multi-Attack chain sets a border's threat.
|
|
779
867
|
for (const b of [...borders.values()].filter((x) => x.chain).sort((x, y) => y.chain.armies - x.chain.armies || x.id - y.id).slice(0, MAX_NAMED_REVEALS)) {
|
|
780
868
|
const c = b.chain;
|
|
@@ -930,6 +1018,13 @@ export function borderThreats(pc, ps, input, src, forces) {
|
|
|
930
1018
|
const cut = e.newestCut;
|
|
931
1019
|
if (cut && e.source !== 'exact' && cut.reading > income)
|
|
932
1020
|
warnings.push(`Player ${p}'s newest turn (turn ${cut.from} → turn ${cut.to}) reads up to +${cut.reading} if the armies that arrived beside the fog were deploys (+${cut.observed} with those beyond twice the ~${cut.expected ?? '?'} it was expected to deploy read as moves); the estimate keeps ~${income} (${e.source === 'tracked' ? 'tracked' : e.source === 'prior' ? 'the fog prior' : 'its visible base + bonuses'}) because a stack walking in is not income (#123). To test the higher figure, pass enemy_deploy ${cut.reading} to warapp_check_plan.`);
|
|
1021
|
+
// #444: incomes other players stated scaled its fog prior down.
|
|
1022
|
+
if (e.stated && incomePrior?.stated) {
|
|
1023
|
+
const st = incomePrior.stated;
|
|
1024
|
+
const said = st.players.map((x) => `player ${x.id} states ${x.income}`).join(', ');
|
|
1025
|
+
const mid = e.stated.midpoint;
|
|
1026
|
+
warnings.push(`Player ${p}'s fog prior is scaled by the incomes stated in chat (known_income: ${said}), ${Math.round(st.ratio * 100) / 100}× my ${st.mine}: ~${e.stated.scaled} in place of ~${e.stated.full}, never below what is in view or tracked${mid !== null ? `; with no track it is sized at the midpoint ~${mid} between ~${e.stated.lower} and ~${e.stated.scaled} (#368)` : ''}.`);
|
|
1027
|
+
}
|
|
933
1028
|
// #368: an income the user supplied replaces the estimate.
|
|
934
1029
|
if (e.known) {
|
|
935
1030
|
warnings.push(`Enemy deploy estimate for player ${p}: ~${income} (the known income you supplied (known_income), in place of the estimate ~${e.known.was})${withCard}; a figure supplied is taken as it is, not checked against the board.`);
|
|
@@ -951,8 +1046,16 @@ export function borderThreats(pc, ps, input, src, forces) {
|
|
|
951
1046
|
: t.lower === t.tracked
|
|
952
1047
|
? `~${t.lower} (the tracked figure)`
|
|
953
1048
|
: `~${t.lower} (its visible income; the tracked ~${t.tracked})`;
|
|
1049
|
+
// #419: the upper bound's basis: the past winners' pace (map or format), the prior, or what it could earn.
|
|
1050
|
+
const upperIs = t.pace && t.upper === t.pace.figure
|
|
1051
|
+
? t.pace.basis === 'map'
|
|
1052
|
+
? `the median past winner's income after turn ${t.pace.afterTurn} on this map, ${t.pace.games} games of this format and settings (#419)`
|
|
1053
|
+
: `my income × ${t.pace.ratio}, the median past winner's pace against mine after turn ${t.pace.afterTurn} in this format, ${t.pace.games} games (fewer than 3 on this map) (#419)`
|
|
1054
|
+
: t.prior !== null && t.upper === Math.min(e.couldEarn, t.prior)
|
|
1055
|
+
? 'the fog prior, not shrunk toward the track'
|
|
1056
|
+
: 'the most it could earn';
|
|
954
1057
|
const sized = thin
|
|
955
|
-
? `it is sized between the lower bound ${lowerIs} and the upper bound ~${t.upper} (${
|
|
1058
|
+
? `it is sized between the lower bound ${lowerIs} and the upper bound ~${t.upper} (${upperIs}): the midpoint ~${t.midpoint}, moved toward what the evidence gives, ~${t.toward}, as more of its frontier is read (${Math.round(t.weight * 100)}% of the way from that to the midpoint)`
|
|
956
1059
|
: `its lower bound is ${lowerIs.startsWith('~') ? lowerIs.slice(1) : lowerIs}, read from enough of its frontier to plan on it`;
|
|
957
1060
|
warnings.push(`Enemy deploy estimate for player ${p}: ~${income} (thin evidence: ${why.join(' and ')}, so ${sized})${withCard}; it could deploy more.`);
|
|
958
1061
|
continue;
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
import { bfsDistances, neighborsOf } from '../graph.js';
|
|
20
20
|
import { teammateAt } from './state.js';
|
|
21
21
|
import { capStepRoom, truceKeep } from './relations.js';
|
|
22
|
+
import { breachLine, breachOf } from './vacated.js';
|
|
22
23
|
/** The transfers (rule 6), with staging toward `staging` (#125) when the leftover saved toward a step. */
|
|
23
24
|
export function transfers(pc, ps, book, threats, hd, caps, staging) {
|
|
24
25
|
const { g, me, s, foe, territories: state, label, bonusName, mine, mineSet, unitsAt, toTake, noSplit, myCommanders } = pc;
|
|
@@ -197,6 +198,9 @@ export function transfers(pc, ps, book, threats, hd, caps, staging) {
|
|
|
197
198
|
const n = avail.get(t);
|
|
198
199
|
if (n <= 0 || locked.has(t) || t === st.from || conceded.has(t) || myCommanders.has(t))
|
|
199
200
|
continue;
|
|
201
|
+
// #417: the breach force stays beside the land a static seat left (said by rule 6 below).
|
|
202
|
+
if (breachOf(pc, captured, t).length)
|
|
203
|
+
continue;
|
|
200
204
|
if (neighborsOf(g, t).some((x) => isEnemy(x) || x === st.t))
|
|
201
205
|
continue;
|
|
202
206
|
if (moves.some((m) => m.from === t && m.kind === 'attack'))
|
|
@@ -254,6 +258,13 @@ export function transfers(pc, ps, book, threats, hd, caps, staging) {
|
|
|
254
258
|
const n = avail.get(t);
|
|
255
259
|
if (n <= 0 || locked.has(t))
|
|
256
260
|
continue;
|
|
261
|
+
// #417, the breach force: beside land a static seat left, still untaken and cheap at the
|
|
262
|
+
// 2-defender price, the stack stays until it is taken (it attacks into it when a pass funds it).
|
|
263
|
+
const land = breachOf(pc, captured, t);
|
|
264
|
+
if (land.length) {
|
|
265
|
+
rationale.push(breachLine(pc, t, n, land));
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
257
268
|
// My commander's territory next to an enemy at the start of the turn keeps its armies,
|
|
258
269
|
// even when this turn's captures make it interior: a capture can still fail. So does one
|
|
259
270
|
// next to a border the plan concedes (#121): the enemy takes it next, and then faces it.
|