Fix flaky Champions Stage stochastic test

The makeTeams(8) helper creates only a 70-pt Elo spread (1800→1730).
With the Champions Stage bracket math this gives team-0 a ~19.6% win
rate — right at the 0.2 threshold, causing the test to fail ~63% of
the time in CI despite 1000 iterations.

Use 100-pt steps (1800→1100) instead, giving team-0 a ~40% win rate
and raising the assertion threshold to 0.25 for a clear safety margin.

https://claude.ai/code/session_019w21Nkf5TvTZHH6oVHaQXR
This commit is contained in:
Claude 2026-04-05 20:35:48 +00:00
parent fb16db64e7
commit d240cd5d94
No known key found for this signature in database

View file

@ -217,14 +217,21 @@ describe("simulateChampionsStage", () => {
});
it("top Elo team wins more often than last (stochastic)", () => {
const teams = makeTeams(8);
// team-0 has highest Elo, team-7 has lowest
// Use a clear Elo spread so team-0 has a decisive advantage.
// makeTeams(8) only gives a 70-pt gap (1800→1730) which puts the
// true win rate right at the 0.2 threshold — extremely flaky.
// 100-pt steps (1800→1100) give team-0 a ~40% win rate, well clear of 0.25.
const teams = Array.from({ length: 8 }, (_, i) => ({
id: `team-${i}`,
elo: 1800 - i * 100,
rank: i + 1,
}));
let wins = 0;
for (let i = 0; i < 1000; i++) {
const result = simulateChampionsStage(teams);
if (result.placements.get("team-0") === 1) wins++;
}
// Should win significantly more than 12.5% of the time (1/8 random)
expect(wins / 1000).toBeGreaterThan(0.2);
// Should win well above 12.5% (1/8 random baseline)
expect(wins / 1000).toBeGreaterThan(0.25);
});
});