Seed the bots in the Spain & Portugal Step 2 test (#175)
The test seeded the game but not the bots, which choose with Math.random, so a game could now and then draw the Step 3 card during Step 1 and skip Step 2 (Engine - Test failed this way on master after #173, then passed on re-run). A sweep of 400 bot seeds: deck2 skips Step 2 in 13 games (3.3%), deck1 in 1. Seeding Math.random per deck, as wrapper.spec does, makes the test the same on every run. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
03f9986bb1
commit
1a8c74f55e
1 changed files with 26 additions and 14 deletions
|
|
@ -279,8 +279,17 @@ describe('power plant decks on maps with deck-specific changes', () => {
|
|||
});
|
||||
|
||||
it('holds the Spain & Portugal ecological plants back until Step 2', () => {
|
||||
// The bots choose with Math.random, so seed it: unseeded, a game could now and then
|
||||
// draw the Step 3 card during Step 1 and skip Step 2 (seen once on CI, 2026-11-20).
|
||||
const realRandom = Math.random;
|
||||
try {
|
||||
for (const deck of decks) {
|
||||
let G = setup(4, { map: 'Spain & Portugal', variant: 'recharged', powerPlantDeck: deck }, `spain-${deck}`);
|
||||
Math.random = seedrandom(`spain-bots-${deck}`);
|
||||
let G = setup(
|
||||
4,
|
||||
{ map: 'Spain & Portugal', variant: 'recharged', powerPlantDeck: deck },
|
||||
`spain-${deck}`
|
||||
);
|
||||
G.players.forEach((p, i) => {
|
||||
p.name = `AI ${i}`;
|
||||
p.isAI = true;
|
||||
|
|
@ -290,11 +299,14 @@ describe('power plant decks on maps with deck-specific changes', () => {
|
|||
for (let turn = 0; turn < 5000 && G.step == 1 && G.currentPlayers.length > 0; turn++) {
|
||||
G = moveAI(G, G.currentPlayers[0]);
|
||||
}
|
||||
expect(G.step).to.equal(2);
|
||||
expect(G.step, deck).to.equal(2);
|
||||
// The first replaces the plant removed at the start of Step 2; the other two follow.
|
||||
const known = numbers([...G.actualMarket, ...G.futureMarket, ...G.powerPlantsDeck.slice(0, 2)]);
|
||||
expect(known, deck).to.include.members(held);
|
||||
}
|
||||
} finally {
|
||||
Math.random = realRandom;
|
||||
}
|
||||
});
|
||||
|
||||
it("swaps Northern Europe's regional cards in by the map's numbers", () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue