@chrischall/warapp-mcp 0.11.0 → 0.12.1
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 +10 -8
- package/dist/analysis/cards-in-effect.js +10 -1
- package/dist/analysis/chat-mentions.js +17 -0
- package/dist/analysis/commander-fog.js +126 -0
- package/dist/analysis/end-game-stats.js +149 -0
- package/dist/analysis/local-deploy.js +3 -2
- package/dist/analysis/outlook.js +133 -55
- package/dist/analysis/picks.js +125 -0
- package/dist/analysis/plan/commander.js +3 -2
- package/dist/analysis/plan/deploy-estimates.js +11 -7
- package/dist/analysis/plan/estimates.js +63 -9
- package/dist/analysis/plan/relations.js +24 -14
- package/dist/analysis/plan/shared.js +21 -0
- package/dist/analysis/plan/threats.js +74 -5
- package/dist/analysis/player.js +23 -10
- package/dist/analysis/relations.js +29 -4
- package/dist/analysis/scale.js +71 -0
- package/dist/analysis/single-pick.js +356 -0
- package/dist/bundle.js +2560 -596
- package/dist/finished-store.js +30 -0
- package/dist/index.js +1 -1
- package/dist/known-mods.js +33 -0
- package/dist/map-stats.js +24 -2
- package/dist/mod-alliances.js +217 -0
- package/dist/mod-data.js +160 -0
- package/dist/my-games.js +53 -2
- package/dist/normalize.js +7 -0
- package/dist/outlook-log.js +13 -0
- package/dist/protocol/methods.js +14 -2
- package/dist/tools/card-advice.js +29 -9
- package/dist/tools/card-effects.js +3 -1
- package/dist/tools/card-support-advice.js +1 -1
- package/dist/tools/chat-inbox.js +61 -8
- package/dist/tools/check-plan.js +101 -10
- package/dist/tools/close-finished-game.js +110 -0
- package/dist/tools/commander-check.js +80 -1
- package/dist/tools/diplomacy.js +11 -2
- package/dist/tools/end-of-game.js +57 -3
- package/dist/tools/game.js +11 -6
- package/dist/tools/how-lost.js +68 -5
- package/dist/tools/index.js +21 -1
- package/dist/tools/map.js +50 -1
- package/dist/tools/mod-alliances.js +191 -0
- package/dist/tools/my-games.js +12 -1
- package/dist/tools/pace.js +44 -0
- package/dist/tools/picks.js +41 -1
- package/dist/tools/relations.js +16 -1
- package/dist/tools/session.js +20 -6
- package/dist/tools/stress-opponents.js +25 -2
- package/dist/tools/turn.js +257 -32
- package/dist/tools/write-kit.js +1 -0
- package/dist/version.js +1 -1
- package/manifest.json +10 -2
- package/mint.yaml +3 -4
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/warapp-mcp/SKILL.md +57 -9
|
@@ -40,7 +40,7 @@ import { bonusTerritories } from '../bonuses.js';
|
|
|
40
40
|
import { bfsDistances, neighborsOf } from '../graph.js';
|
|
41
41
|
import { simTerritories, simulateTurn } from '../turn-sim.js';
|
|
42
42
|
import { armiesToTake, DEFAULT_DEFENSIVE_KILL_RATE, straightKills } from '../combat.js';
|
|
43
|
-
import { captureCost, CONCEDE_FACTOR, } from './shared.js';
|
|
43
|
+
import { captureCost, CONCEDE_FACTOR, ruleOnly, } from './shared.js';
|
|
44
44
|
import { byNum } from './util.js';
|
|
45
45
|
/** T3: a covered border protecting more than this share of my income keeps its full hold. */
|
|
46
46
|
export const TRUCE_RELAX_VALUE = 0.25;
|
|
@@ -167,14 +167,14 @@ function truceFrom(input, o) {
|
|
|
167
167
|
else if (r.state === 'broken')
|
|
168
168
|
st = 'broken';
|
|
169
169
|
// D3: a relation that is only a card ends with it.
|
|
170
|
-
else if (r
|
|
170
|
+
else if (ruleOnly(r) && !enforcedNow[i])
|
|
171
171
|
st = 'over';
|
|
172
172
|
else if (r.state === 'notice' && r.endsTurn !== undefined && o.turnNow !== null && o.turnNow >= r.endsTurn)
|
|
173
173
|
st = 'over';
|
|
174
174
|
else
|
|
175
175
|
st = r.state;
|
|
176
176
|
kept.push(st === 'active' || st === 'notice');
|
|
177
|
-
if (!ffa && !r
|
|
177
|
+
if (!ffa && !ruleOnly(r) && !(enforcedNow[i] && kept[i]))
|
|
178
178
|
st = 'ignored';
|
|
179
179
|
status.push(st);
|
|
180
180
|
binds.push(st === 'active' || st === 'notice');
|
|
@@ -193,7 +193,7 @@ function truceFrom(input, o) {
|
|
|
193
193
|
given.forEach((r, i) => {
|
|
194
194
|
if (!kept[i])
|
|
195
195
|
return;
|
|
196
|
-
if (!r
|
|
196
|
+
if (!ruleOnly(r))
|
|
197
197
|
keptWith.add(r.player);
|
|
198
198
|
// T2–T5 and T9 only in a free-for-all; T1 (never a surprise break, D3) wherever the agreement binds.
|
|
199
199
|
if (binds[i]) {
|
|
@@ -620,7 +620,13 @@ export function reportTruce(pc, ps, tp, freedOn) {
|
|
|
620
620
|
const relations = truce.given.map((r, i) => {
|
|
621
621
|
const st = truce.status[i];
|
|
622
622
|
const flags = [...(r.watch ?? [])];
|
|
623
|
-
const name = r.card
|
|
623
|
+
const name = r.card
|
|
624
|
+
? `Diplomacy card with player ${r.player}`
|
|
625
|
+
: ruleOnly(r)
|
|
626
|
+
? `Diplomacy 2 alliance with player ${r.player}`
|
|
627
|
+
: `Truce with player ${r.player}${r.agreement ? ` (agreement ${r.agreement})` : ''}`;
|
|
628
|
+
// What enforces it: the Diplomacy 2 mod's alliance (a card enforcing it too lasts longer and is named instead).
|
|
629
|
+
const byMod = r.mod !== undefined && !r.card && !(r.enforcedUntil !== undefined && turnNow !== null && r.enforcedUntil > turnNow + 1);
|
|
624
630
|
const mineRelaxed = tp ? [...tp.relaxed].filter(([t, p]) => p === r.player && r.coveredMine.includes(t)).map(([t]) => t).sort(byNum) : [];
|
|
625
631
|
const fullHold = tp
|
|
626
632
|
? [...tp.fullHold]
|
|
@@ -633,7 +639,7 @@ export function reportTruce(pc, ps, tp, freedOn) {
|
|
|
633
639
|
warnings.push(`${name} is broken by them: ${r.breach.term} on turn ${r.breach.turn}${r.breach.territories.length ? ` (${r.breach.territories.map(label).join(', ')})` : ''} — ${r.breach.evidence}. Player ${r.player} is planned as an ordinary opponent from this turn (T8). ${RECORD_BROKEN(r)}`);
|
|
634
640
|
else if (st === 'broken')
|
|
635
641
|
warnings.push(`${name} is broken by them: player ${r.player} is planned as an ordinary opponent from this turn (T8). ${RECORD_BROKEN(r)}`);
|
|
636
|
-
else if (st === 'over' && r
|
|
642
|
+
else if (st === 'over' && ruleOnly(r))
|
|
637
643
|
rationale.push(`${name}: it is gone by this turn, so player ${r.player} is an ordinary opponent (T9).`);
|
|
638
644
|
else if (st === 'over')
|
|
639
645
|
rationale.push(`${name}: its notice ran out on turn ${r.endsTurn}, so player ${r.player} is an ordinary opponent this turn (T7).`);
|
|
@@ -642,14 +648,17 @@ export function reportTruce(pc, ps, tp, freedOn) {
|
|
|
642
648
|
else if (st === 'active' || st === 'notice') {
|
|
643
649
|
const enforced = truce.enforced.has(r.player);
|
|
644
650
|
const notice = st === 'notice' && r.endsTurn !== undefined ? ` (in notice${r.noticeBy ? ` given by ${r.noticeBy === 'me' ? 'me' : 'them'}` : ''}: binding until turn ${r.endsTurn})` : '';
|
|
645
|
-
rationale.push(enforced
|
|
646
|
-
? `${name}${notice}:
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
651
|
+
rationale.push(enforced && byMod
|
|
652
|
+
? `${name}${notice}: the Diplomacy 2 mod's alliance is in effect, so the game skips every attack between player ${r.player} and me this turn — its threat is 0 and no attack on it is planned (T9); ` +
|
|
653
|
+
'either side may enter a break this turn, unseen, that applies at its end, so its stacks still count for next turn\'s look-ahead.'
|
|
654
|
+
: enforced
|
|
655
|
+
? `${name}${notice}: a Diplomacy card is in effect, so player ${r.player}'s attacks on me do nothing this turn — its threat is 0 and no attack on it is planned (T9)` +
|
|
656
|
+
(truce.lookAheadFoes.has(r.player)
|
|
657
|
+
? `; the card is gone by turn ${r.enforcedUntil}, so its stacks still count for next turn's look-ahead.`
|
|
658
|
+
: r.enforcedUntil !== undefined
|
|
659
|
+
? `; the card lasts until turn ${r.enforcedUntil}.`
|
|
660
|
+
: '.')
|
|
661
|
+
: `${name}${notice}: none of its ${r.coveredTheirs.length} covered ${r.coveredTheirs.length === 1 ? 'territory is' : 'territories are'} a target this turn (T1), and player ${r.player} is no front for the no-second-front rule or the idle armies (T4).`);
|
|
653
662
|
for (const e of r.exceptions ?? [])
|
|
654
663
|
rationale.push(e.direction === 'mine'
|
|
655
664
|
? `${name}: player ${r.player} agreed to an exception this turn, so ${e.territories.map(label).join(', ')} ${e.territories.length === 1 ? 'is a normal target' : 'are normal targets'} — no break.`
|
|
@@ -673,6 +682,7 @@ export function reportTruce(pc, ps, tp, freedOn) {
|
|
|
673
682
|
enforced: truce.binds[i] && truce.enforced.has(r.player),
|
|
674
683
|
...(r.enforcedUntil !== undefined ? { enforcedUntil: r.enforcedUntil } : {}),
|
|
675
684
|
...(r.card ? { card: r.card } : {}),
|
|
685
|
+
...(r.mod ? { mod: r.mod } : {}),
|
|
676
686
|
trust: r.trust,
|
|
677
687
|
flags,
|
|
678
688
|
...(r.endsTurn !== undefined ? { endsTurn: r.endsTurn } : {}),
|
|
@@ -157,8 +157,29 @@ export function localFreeOn(base, floor, clock, turn) {
|
|
|
157
157
|
export function bombPossibleOn(settings, turn) {
|
|
158
158
|
return settings.bombFrom !== undefined && (turn === null || turn === undefined || turn >= settings.bombFrom);
|
|
159
159
|
}
|
|
160
|
+
/** Round to the nearest, .5 down: the client's rounding of a progressive card (`Round(x, false)`). */
|
|
161
|
+
const roundHalfDown = (x) => {
|
|
162
|
+
const whole = Math.floor(x);
|
|
163
|
+
return x - whole > 0.5 + 1e-9 ? whole + 1 : whole;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* An opponent's Reinforcement card under `r`: a flat card's armies, or a progressive one by the client's formula.
|
|
167
|
+
* `territories` is every territory a player (any player, me included) holds in view: under fog only a floor of
|
|
168
|
+
* the count the game uses, so a Reinforcement card in my hand worth more (`r.armies`: the client's figure for
|
|
169
|
+
* the same formula in the same game) is taken instead, labelled "my card's value". `turn` is the turn being
|
|
170
|
+
* played: the latest card was earned on the turn before it.
|
|
171
|
+
*/
|
|
172
|
+
export function reinforcementArmiesFor(r, opts) {
|
|
173
|
+
if (!r.progressive)
|
|
174
|
+
return { armies: r.armies };
|
|
175
|
+
const basis = r.progressive.by === 'territories' ? opts.territories : Math.max(0, opts.turn - 1);
|
|
176
|
+
const formula = Math.max(1, roundHalfDown(r.progressive.percentage * basis));
|
|
177
|
+
return r.armies > formula ? { armies: r.armies, basis: "my card's value" } : { armies: formula, basis: 'client formula' };
|
|
178
|
+
}
|
|
160
179
|
/** #164: GameFeed fog levels that show every territory's owner (No, Light and Dense fog): income is exact. */
|
|
161
180
|
export const OWNERS_SHOWN_FOG = new Set(['NoFog', 'LightFog', 'ModerateFog']);
|
|
181
|
+
/** A relation that is only a game rule — a Diplomacy card, or a Diplomacy 2 alliance with no agreement recorded. */
|
|
182
|
+
export const ruleOnly = (r) => r.card !== undefined || (r.mod !== undefined && r.agreement === undefined);
|
|
162
183
|
/** An opponent with at most this many visible territories has its exits listed (#179). */
|
|
163
184
|
export const FEW_TERRITORIES = 3;
|
|
164
185
|
/** The most turns {@link EliminateEta} looks ahead. */
|
|
@@ -6,18 +6,20 @@
|
|
|
6
6
|
import { carriesTeam } from '../../teams.js';
|
|
7
7
|
import { searchChains } from '../chains.js';
|
|
8
8
|
import { guaranteedKills } from '../combat.js';
|
|
9
|
+
import { FOG_PLAYER, foggedAttacks, foggedTakes, likelyStackAt } from '../commander-fog.js';
|
|
9
10
|
import { bfsDistances, neighborsOf } from '../graph.js';
|
|
10
11
|
import { couldHoldBonusPools, enemyDeployReaching, freeIncome } from '../local-deploy.js';
|
|
11
12
|
import { incomeBasis, LOST_STACK_TURNS } from '../opponents.js';
|
|
12
13
|
import { HIDDEN_POOL_INCOMES, MAX_NAMED_REVEALS, coverageText, LOW_COVERAGE, MIN_ENEMY_DEPLOY, openingArmies, ownerShown, visibleState, } from './shared.js';
|
|
13
14
|
import { gameBaseIncome, territoryIncome } from '../player.js';
|
|
14
15
|
import { simTerritories } from '../turn-sim.js';
|
|
16
|
+
import { VACATED_FOG_ARMIES } from './vacated.js';
|
|
15
17
|
import { byNum } from './util.js';
|
|
16
18
|
/** Read the threats against my territories, and state them. */
|
|
17
19
|
export function threatsPhase(pc, ps, input, valueOf) {
|
|
18
20
|
const src = threatSources(pc, ps, input);
|
|
19
21
|
const forces = threatForces(pc, ps, src, valueOf);
|
|
20
|
-
const { borders, facing, borderAt, safeAtStart } = borderThreats(pc, ps, input, src, forces);
|
|
22
|
+
const { borders, facing, borderAt, visibleBorderAt, safeAtStart } = borderThreats(pc, ps, input, src, forces);
|
|
21
23
|
const { growthOf, deployReaching, reinforcementAt, holdArmies, bombSized, hiddenFoe, hiddenMovable, hiddenPool, } = src;
|
|
22
24
|
const { chainAt, stacksAt, forceAt, threatAt, nextTurnAt, expectedAt, exposure } = forces;
|
|
23
25
|
const seen = visibleOpponents(pc, input);
|
|
@@ -53,6 +55,7 @@ export function threatsPhase(pc, ps, input, valueOf) {
|
|
|
53
55
|
borders,
|
|
54
56
|
facing,
|
|
55
57
|
borderAt,
|
|
58
|
+
visibleBorderAt,
|
|
56
59
|
safeAtStart,
|
|
57
60
|
};
|
|
58
61
|
}
|
|
@@ -724,7 +727,7 @@ export function threatForces(pc, ps, src, valueOf) {
|
|
|
724
727
|
export function borderThreats(pc, ps, input, src, forces) {
|
|
725
728
|
const { g, board, game: ctx, foe, custom, estimates, incomePrior, incomePriorSkipped, enemyDeploy, territories: state, label, mine, mineSet, armiesOf, unitsAt, uncounted, uncountedKind, bombOn, toTake, turnNow, holdPasses, myCommanders, s, baseIncome, rates, } = pc;
|
|
726
729
|
const { warnings, rationale } = ps;
|
|
727
|
-
const { growthOf, holdArmies, hiddenFoe, lostAt, teamOf, deployReaching, bombSized } = src;
|
|
730
|
+
const { growthOf, holdArmies, hiddenFoe, lostAt, teamOf, deployReaching, bombSized, killsOf, takesAlone } = src;
|
|
728
731
|
/** #226: the game pays per territory (BonusArmyPer). */
|
|
729
732
|
const perTerritory = (s.bonusArmyPer ?? 0) > 0;
|
|
730
733
|
/** #226: what the bonuses it could still hold add to what it could earn (its territories' pay aside). */
|
|
@@ -778,7 +781,67 @@ export function borderThreats(pc, ps, input, src, forces) {
|
|
|
778
781
|
}
|
|
779
782
|
return worst;
|
|
780
783
|
};
|
|
784
|
+
/**
|
|
785
|
+
* Part 5 (mega game, `PlanOptions.foggedAttackers`): my commander's territory `t` against the fog's
|
|
786
|
+
* attackers ({@link foggedAttacks}): the `count` strongest fogged territories within two moves of it, each
|
|
787
|
+
* hiding a player with `stack` armies and my whole income (a what-if `enemyDeploy` as given), striking in
|
|
788
|
+
* turn (#201's separate-attack arithmetic). `undefined` when off or with no fogged territory in reach.
|
|
789
|
+
*/
|
|
790
|
+
const fogWorstAt = (t, gone) => {
|
|
791
|
+
const fa = pc.opts.foggedAttackers;
|
|
792
|
+
if (!fa || fa.count <= 0)
|
|
793
|
+
return undefined;
|
|
794
|
+
const view = {
|
|
795
|
+
mine: (x) => mineSet.has(x),
|
|
796
|
+
fogged: (x) => {
|
|
797
|
+
const st = state.get(x);
|
|
798
|
+
if (!st || st.owner.kind === 'unknown')
|
|
799
|
+
return true;
|
|
800
|
+
if (st.armies !== null)
|
|
801
|
+
return false;
|
|
802
|
+
return st.owner.kind !== 'player' || foe(st.owner.playerId);
|
|
803
|
+
},
|
|
804
|
+
armies: (x) => {
|
|
805
|
+
const st = state.get(x);
|
|
806
|
+
return st && st.owner.kind !== 'unknown' ? st.armies : null;
|
|
807
|
+
},
|
|
808
|
+
};
|
|
809
|
+
const deploy = custom ? (enemyDeploy ?? 0) : Math.max(0, pc.income - pc.cardArmies);
|
|
810
|
+
/** #529: a start's armies only on a likely holder; elsewhere the fogged territory's usual estimate. */
|
|
811
|
+
const stackAt = likelyStackAt({
|
|
812
|
+
stack: fa.stack,
|
|
813
|
+
me: pc.me,
|
|
814
|
+
starts: new Set(fa.starts ?? []),
|
|
815
|
+
shownPlayer: (x) => {
|
|
816
|
+
const o = state.get(x)?.owner;
|
|
817
|
+
return o?.kind === 'player' ? o.playerId : undefined;
|
|
818
|
+
},
|
|
819
|
+
lastSeen: pc.opts.lastSeen,
|
|
820
|
+
vacated: pc.vacated,
|
|
821
|
+
vacatedArmies: VACATED_FOG_ARMIES,
|
|
822
|
+
rememberedNeutrals: pc.opts.rememberedNeutrals,
|
|
823
|
+
neutralArmies: s.neutralArmies,
|
|
824
|
+
});
|
|
825
|
+
const all = foggedAttacks(g, view, t, { stack: stackAt, deploy, defensiveKillRate: rates.defensiveKillRate }, gone);
|
|
826
|
+
if (!all.length)
|
|
827
|
+
return undefined;
|
|
828
|
+
const used = all.slice(0, fa.count);
|
|
829
|
+
const joint = used.length > 1 ? (toTake(foggedTakes(used.map((a) => a.armies), used.length, killsOf, takesAlone)) ?? used[0].armies) : used[0].armies;
|
|
830
|
+
const threat = bombSized(t, Math.max(used[0].armies, joint));
|
|
831
|
+
return { threat, fog: { attackers: used.length, territories: used.map((a) => a.territory), stacks: used.map((a) => stackAt(a.territory)), stack: fa.stack, deploy } };
|
|
832
|
+
};
|
|
781
833
|
const borderAt = (t, gone) => {
|
|
834
|
+
const b = visibleBorderAt(t, gone);
|
|
835
|
+
if (!myCommanders.has(t))
|
|
836
|
+
return b;
|
|
837
|
+
const fw = fogWorstAt(t, gone);
|
|
838
|
+
if (!fw || (b && b.threat >= fw.threat))
|
|
839
|
+
return b;
|
|
840
|
+
if (b)
|
|
841
|
+
return { ...b, threat: fw.threat, fogWorst: fw.fog };
|
|
842
|
+
return { id: t, player: FOG_PLAYER, movable: 0, growth: 0, deploy: fw.fog.deploy, threat: fw.threat, fogWorst: fw.fog };
|
|
843
|
+
};
|
|
844
|
+
const visibleBorderAt = (t, gone) => {
|
|
782
845
|
// #235: a leader's border whose joint hold does not pay is sized for each opponent alone.
|
|
783
846
|
const solo = ps.soloHeld.has(t);
|
|
784
847
|
const f = forceAt(t, gone, { trend: true, allPlayers: true, solo });
|
|
@@ -838,6 +901,10 @@ export function borderThreats(pc, ps, input, src, forces) {
|
|
|
838
901
|
const b = borderAt(t, () => false);
|
|
839
902
|
if (b)
|
|
840
903
|
borders.set(t, b);
|
|
904
|
+
if (b?.fogWorst) {
|
|
905
|
+
const w = b.fogWorst;
|
|
906
|
+
rationale.push(`My commander's territory ${label(t)} is held against the fog too (mega game, part 5), ~${b.threat}: ${w.attackers} unknown opponent${w.attackers === 1 ? '' : 's'} the fog may hide on ${w.territories.map((x, i) => `${label(x)} (${w.stacks[i]})`).join(', ')} (within two moves of it; in brackets the armies each may hold — a start's ${w.stack} only where a start could be or a player was last seen, #529) striking ${w.attackers === 1 ? 'it' : 'it together'}, each plus a whole deploy of ~${w.deploy}.`);
|
|
907
|
+
}
|
|
841
908
|
if (b?.commanderWorst) {
|
|
842
909
|
const w = b.commanderWorst;
|
|
843
910
|
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.`);
|
|
@@ -1015,13 +1082,14 @@ export function borderThreats(pc, ps, input, src, forces) {
|
|
|
1015
1082
|
: `Player ${p}'s Reinforcement card is taken as played on turn ${e.cardPlayed} (a deployment of a card's armies over its visible income), so none is added until the next can be due; income the fog hides can look the same, so it may still hold one and the estimate errs low.`);
|
|
1016
1083
|
// #164: the income behind the estimate; a card the clock adds is named on top of it.
|
|
1017
1084
|
const income = e.estimate - (e.card?.armies ?? 0);
|
|
1018
|
-
// G2 (D3): Sanctions on it the decoder is sure of —
|
|
1085
|
+
// G2 (D3): Sanctions on it the decoder is sure of — every income figure cut, unless read from deploys under the card.
|
|
1019
1086
|
if (e.sanctioned) {
|
|
1020
1087
|
const z = e.sanctioned;
|
|
1021
1088
|
const pct = z.percentages.map((x) => `${Math.round(x * 100)}%`).join(' then ');
|
|
1089
|
+
const range = z.applied && e.thinEvidence ? ` (its range ~${e.thinEvidence.lower}–${e.thinEvidence.upper})` : '';
|
|
1022
1090
|
warnings.push(z.applied
|
|
1023
|
-
? `Player ${p} is under Sanctions (${pct}, until turn ${z.untilTurn}, read from the board by an unverified decoder): its estimate is cut from ~${z.before} to ~${income} by the client's rule.`
|
|
1024
|
-
: `Player ${p} is under Sanctions (${pct}, until turn ${z.untilTurn}, read from the board by an unverified decoder)
|
|
1091
|
+
? `Player ${p} is under Sanctions (${pct}, until turn ${z.untilTurn}, read from the board by an unverified decoder): its estimate is cut from ~${z.before} to ~${income}${range} by the client's rule.`
|
|
1092
|
+
: `Player ${p} is under Sanctions (${pct}, until turn ${z.untilTurn}, read from the board by an unverified decoder): its estimate ~${income} is not cut again, since it was read from deploys made under the card${z.fromTurn !== undefined ? ` (from turn ${z.fromTurn})` : ''}, which already carry the cut.`);
|
|
1025
1093
|
}
|
|
1026
1094
|
// #332: a commerce game's rising army price, applied to a figure read off the board.
|
|
1027
1095
|
if (e.armyPrice)
|
|
@@ -1111,6 +1179,7 @@ export function borderThreats(pc, ps, input, src, forces) {
|
|
|
1111
1179
|
borders,
|
|
1112
1180
|
facing,
|
|
1113
1181
|
borderAt,
|
|
1182
|
+
visibleBorderAt,
|
|
1114
1183
|
safeAtStart,
|
|
1115
1184
|
};
|
|
1116
1185
|
}
|
package/dist/analysis/player.js
CHANGED
|
@@ -112,11 +112,10 @@ export function incomeRules(settings) {
|
|
|
112
112
|
* the game uses is modelled (base, BonusArmyPer, held bonuses, card armies,
|
|
113
113
|
* overridden bonus values once read — only unreadable overrides are listed).
|
|
114
114
|
* Cities and per-player income mods have no known settings key, so they are
|
|
115
|
-
* not detected: those games still get the hard deploy-total check. Sanctions
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* income already carries the Sanctions read on me) the reason says so instead. An army cap is
|
|
115
|
+
* not detected: those games still get the hard deploy-total check. Sanctions are a reason only
|
|
116
|
+
* when they are on me and their cut is not modelled (`sanctionsUnmodelled`: under Local Deployment,
|
|
117
|
+
* where the pools the cut comes from are unknown); an enabled card nobody played on me, or Sanctions
|
|
118
|
+
* on me that the income already carries (PLAN-TEAMS D3), are none. An army cap is
|
|
120
119
|
* modelled ({@link armyCapIncome}, #253) and verified by six live cases, yet stays listed (where the
|
|
121
120
|
* card armies and Local Deployment's pools fall is not verified): with
|
|
122
121
|
* `armyCap` (the figure the caller applied) the reason states its arithmetic.
|
|
@@ -134,15 +133,29 @@ export function incomeUncertainties(settings, opts = {}) {
|
|
|
134
133
|
// Overrides that were read are applied to the map (applyBonusOverrides), so only unreadable ones make income uncertain.
|
|
135
134
|
if (settings?.overriddenBonusesUnparsed)
|
|
136
135
|
out.push(OVERRIDES_UNPARSED);
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
// Owner spec 2026-11-23: the Sanctions on me are modelled (the income carries the cut), so the card is no
|
|
137
|
+
// reason to doubt the income — only Sanctions on me whose cut the model could not apply are.
|
|
138
|
+
if (opts.sanctionsUnmodelled) {
|
|
139
|
+
const pct = settings?.raw?.SanctionsCard;
|
|
139
140
|
const p = isRecord(pct) && typeof pct.Percentage === 'number' ? ` by ${Math.round(pct.Percentage * 100)}%` : '';
|
|
140
|
-
out.push(
|
|
141
|
-
? `the Sanctions on you${p} are applied as read from the board by an unverified decoder (#163).`
|
|
142
|
-
: `This game has the Sanctions card, which cuts a sanctioned player's income${p}; the model does not apply it.`);
|
|
141
|
+
out.push(`Sanctions are on you, which cut your income${p}; the model does not apply the cut here (Local Deployment).`);
|
|
143
142
|
}
|
|
144
143
|
return out;
|
|
145
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* warapp_submit_turn only: a game with the Sanctions card and none read on me this turn. The board's
|
|
147
|
+
* active-card reader is unverified (#163), so a deploy total below the model still warns there rather
|
|
148
|
+
* than refuses. Not an income doubt for warapp_plan_turn (it plans on the Sanctions it reads).
|
|
149
|
+
*/
|
|
150
|
+
export function unreadSanctionsUncertainty(settings, opts) {
|
|
151
|
+
if (!settings?.cards.includes('Sanctions') || opts.sanctionsOnMe)
|
|
152
|
+
return [];
|
|
153
|
+
const pct = settings.raw?.SanctionsCard;
|
|
154
|
+
const p = isRecord(pct) && typeof pct.Percentage === 'number' ? ` by ${Math.round(pct.Percentage * 100)}%` : '';
|
|
155
|
+
return [
|
|
156
|
+
`This game has the Sanctions card, which cuts a sanctioned player's income${p}; none is read on you this turn, but the board's active-card reader is unverified, so a lower total is not refused.`,
|
|
157
|
+
];
|
|
158
|
+
}
|
|
146
159
|
/**
|
|
147
160
|
* Why warapp_submit_turn's deploy-total check must warn rather than refuse: the income
|
|
148
161
|
* uncertainties plus, while the overrides' shape is unverified, a game's overrides.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { carriesTeam, teammatesOf } from '../teams.js';
|
|
2
2
|
import { bonusTerritories } from './bonuses.js';
|
|
3
3
|
import { bfsDistances, neighborsOf } from './graph.js';
|
|
4
|
-
import { ownerShown, OWNERS_SHOWN_FOG, visibleState, } from './plan/shared.js';
|
|
4
|
+
import { ownerShown, OWNERS_SHOWN_FOG, visibleState, ruleOnly, } from './plan/shared.js';
|
|
5
5
|
import { planTurn } from './planner.js';
|
|
6
6
|
/** Every status an agreement can be recorded in. */
|
|
7
7
|
export const AGREEMENT_STATUSES = [
|
|
@@ -633,6 +633,29 @@ export function planRelationsFrom(input) {
|
|
|
633
633
|
: {}),
|
|
634
634
|
});
|
|
635
635
|
}
|
|
636
|
+
// T9: the Diplomacy 2 mod's alliances, a game rule like a card: enforced this turn whatever the ledger says.
|
|
637
|
+
for (const player of [...new Set(input.modAllies ?? [])].sort((x, y) => x - y)) {
|
|
638
|
+
if (player === me)
|
|
639
|
+
continue;
|
|
640
|
+
const bound = relations.filter((r) => r.player === player && (r.state === 'active' || r.state === 'notice'));
|
|
641
|
+
for (const r of bound) {
|
|
642
|
+
r.enforced = true;
|
|
643
|
+
r.enforcedUntil = turn + 1;
|
|
644
|
+
r.mod = 'Diplomacy 2';
|
|
645
|
+
}
|
|
646
|
+
if (bound.length)
|
|
647
|
+
continue;
|
|
648
|
+
relations.push({
|
|
649
|
+
player,
|
|
650
|
+
coveredMine: [...mine].sort((x, y) => x - y),
|
|
651
|
+
coveredTheirs: [...holding(player)].sort((x, y) => x - y),
|
|
652
|
+
state: 'active',
|
|
653
|
+
trust: 'clear',
|
|
654
|
+
enforced: true,
|
|
655
|
+
enforcedUntil: turn + 1,
|
|
656
|
+
mod: 'Diplomacy 2',
|
|
657
|
+
});
|
|
658
|
+
}
|
|
636
659
|
// D3 (T9): the Diplomacy cards in effect. A card is a game rule, not a promise: it binds whatever the ledger says.
|
|
637
660
|
for (const d of [...(input.diplomacy ?? [])].sort((x, y) => x.player - y.player)) {
|
|
638
661
|
if (d.player === me || d.untilTurn <= turn)
|
|
@@ -640,7 +663,8 @@ export function planRelationsFrom(input) {
|
|
|
640
663
|
const bound = relations.filter((r) => r.player === d.player && (r.state === 'active' || r.state === 'notice'));
|
|
641
664
|
for (const r of bound) {
|
|
642
665
|
r.enforced = true;
|
|
643
|
-
|
|
666
|
+
// A mod alliance enforcing it already: the card keeps it at least as long.
|
|
667
|
+
r.enforcedUntil = r.enforcedUntil !== undefined ? Math.max(r.enforcedUntil, d.untilTurn) : d.untilTurn;
|
|
644
668
|
}
|
|
645
669
|
if (bound.length)
|
|
646
670
|
continue;
|
|
@@ -759,7 +783,8 @@ export function priceTruce(input, player, terms, opts = {}) {
|
|
|
759
783
|
trust: 'clear',
|
|
760
784
|
enforced: true,
|
|
761
785
|
...(enforcing.enforcedUntil !== undefined ? { enforcedUntil: enforcing.enforcedUntil } : {}),
|
|
762
|
-
|
|
786
|
+
// A Diplomacy 2 alliance binds like a card, with or without the deal.
|
|
787
|
+
...(enforcing.mod && !enforcing.card ? { mod: enforcing.mod } : { card: 'Diplomacy' }),
|
|
763
788
|
},
|
|
764
789
|
]
|
|
765
790
|
: [];
|
|
@@ -772,7 +797,7 @@ export function priceTruce(input, player, terms, opts = {}) {
|
|
|
772
797
|
const coveredTheirs = coveredTerritories(input.graph, terms.scope, holding(player));
|
|
773
798
|
// The board's reading of a recorded truce with this player (planRelationsFrom) is kept: words
|
|
774
799
|
// never clear a flag, and a price never trusts more than warapp_plan_turn does (PLAN-TEAMS §4).
|
|
775
|
-
const standing = (input.relations ?? []).find((r) => r.player === player && !r
|
|
800
|
+
const standing = (input.relations ?? []).find((r) => r.player === player && !ruleOnly(r));
|
|
776
801
|
const watch = [...new Set([...(standing?.watch ?? []), ...(opts.watch ?? [])])];
|
|
777
802
|
const trusted = standing?.trust === 'watch' || opts.trust === 'watch' ? 'watch' : 'clear';
|
|
778
803
|
const state = standing?.state ?? 'active';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Scale (mega games, ~100 players): which opponents a tool estimates one by one, and a summary of the rest.
|
|
2
|
+
// A game with more than LARGE_GAME_OPPONENTS opponents still playing is "large": its per-opponent estimates,
|
|
3
|
+
// rows and lists keep only the players near me — in view (fog shows their land) or holding land within
|
|
4
|
+
// NEAR_STEPS steps of mine — and the others are counted. Every other game is unchanged (no scope at all).
|
|
5
|
+
// Pure and deterministic.
|
|
6
|
+
import { neighborsOf } from './graph.js';
|
|
7
|
+
/** More opponents still playing than this makes a game large (a 1v1, a team game or an ordinary free-for-all never is). */
|
|
8
|
+
export const LARGE_GAME_OPPONENTS = 16;
|
|
9
|
+
/** A player holding land this many steps from mine, or fewer, is near. */
|
|
10
|
+
export const NEAR_STEPS = 2;
|
|
11
|
+
/**
|
|
12
|
+
* The players (never `me`) near my land on `board`: each holding a territory within `steps` steps of one of
|
|
13
|
+
* mine, and, under fog (some territory's owner hidden), each whose land is in view anywhere (a card's vision,
|
|
14
|
+
* say). Without fog every owner is in view, so only the steps count.
|
|
15
|
+
*/
|
|
16
|
+
export function nearPlayers(g, board, me, steps = NEAR_STEPS) {
|
|
17
|
+
const owner = new Map();
|
|
18
|
+
let fogged = false;
|
|
19
|
+
for (const t of board.territories) {
|
|
20
|
+
if (t.owner.kind === 'player')
|
|
21
|
+
owner.set(t.territoryId, t.owner.playerId);
|
|
22
|
+
else if (t.owner.kind === 'unknown')
|
|
23
|
+
fogged = true;
|
|
24
|
+
}
|
|
25
|
+
const out = new Set();
|
|
26
|
+
let frontier = [...owner].filter(([, p]) => p === me).map(([t]) => t);
|
|
27
|
+
const seen = new Set(frontier);
|
|
28
|
+
for (let d = 0; d < steps && frontier.length; d++) {
|
|
29
|
+
const next = [];
|
|
30
|
+
for (const t of frontier)
|
|
31
|
+
for (const n of neighborsOf(g, t)) {
|
|
32
|
+
if (seen.has(n))
|
|
33
|
+
continue;
|
|
34
|
+
seen.add(n);
|
|
35
|
+
next.push(n);
|
|
36
|
+
const p = owner.get(n);
|
|
37
|
+
if (p !== undefined && p !== me)
|
|
38
|
+
out.add(p);
|
|
39
|
+
}
|
|
40
|
+
frontier = next;
|
|
41
|
+
}
|
|
42
|
+
if (fogged)
|
|
43
|
+
for (const p of owner.values())
|
|
44
|
+
if (p !== me)
|
|
45
|
+
out.add(p);
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/** The scope over `opponents` (teammates and me already left out): every one unless the game is large. */
|
|
49
|
+
export function opponentScope(g, board, me, opponents) {
|
|
50
|
+
const ids = [...new Set(opponents)].filter((p) => p !== me).sort((a, b) => a - b);
|
|
51
|
+
if (ids.length <= LARGE_GAME_OPPONENTS)
|
|
52
|
+
return { large: false, near: ids, far: [] };
|
|
53
|
+
const near = nearPlayers(g, board, me);
|
|
54
|
+
return { large: true, near: ids.filter((p) => near.has(p)), far: ids.filter((p) => !near.has(p)) };
|
|
55
|
+
}
|
|
56
|
+
export const FAR_NOTE = `A large game (more than ${LARGE_GAME_OPPONENTS} opponents): only the opponents in view or holding land within ` +
|
|
57
|
+
`${NEAR_STEPS} steps of yours are estimated one by one; the rest are summed here. Their estimates are priors (the fog ` +
|
|
58
|
+
'hides them), so the sum is a scale, not a threat: none of them can reach your land this turn.';
|
|
59
|
+
export function farSummary(far, estimateOf) {
|
|
60
|
+
let sum = null;
|
|
61
|
+
let biggest = null;
|
|
62
|
+
for (const p of far) {
|
|
63
|
+
const e = estimateOf(p);
|
|
64
|
+
if (e === undefined)
|
|
65
|
+
continue;
|
|
66
|
+
sum = (sum ?? 0) + e;
|
|
67
|
+
if (!biggest || e > biggest.deploy)
|
|
68
|
+
biggest = { player: p, deploy: e };
|
|
69
|
+
}
|
|
70
|
+
return { count: far.length, estimatedDeploy: sum, biggest, note: FAR_NOTE };
|
|
71
|
+
}
|