Skip to content

Commit f47d80c

Browse files
author
Sorra
authored
Merge pull request #425 from TheWizardsCode/copilot/cg-0mmn8uke10g7gasw-implement-random-strategy
Main Street M3: Add 100-seed RandomStrategy acceptance test
2 parents 6789756 + de22245 commit f47d80c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/main-street/ai-strategy.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,4 +353,16 @@ describe('MainStreetAiPlayer', () => {
353353
expect(['win', 'loss']).toContain(state.gameResult);
354354
}
355355
});
356+
357+
it('RandomStrategy completes 100 seeds without error, using seeded RNG, never making illegal actions', () => {
358+
for (let i = 0; i < 100; i++) {
359+
const seed = `random-strategy-seed-${i}`;
360+
const state = setupMainStreetGame({ seed });
361+
const player = new MainStreetAiPlayer(RandomStrategy, makeRng(i));
362+
// playGame calls executeAction which throws on any illegal action;
363+
// enumerateLegalActions guarantees only legal actions are returned.
364+
expect(() => player.playGame(state)).not.toThrow();
365+
expect(['win', 'loss']).toContain(state.gameResult);
366+
}
367+
});
356368
});

0 commit comments

Comments
 (0)