Fix simulator correctness bugs and reduce test iteration counts #61

Merged
chrisp merged 2 commits from fix/simulator-review-cleanups into main 2026-05-31 17:39:44 +00:00
Owner

Summary

  • Bug fix: EPL Elo/odds fallback was gated on `dbEloMap.size === 0` — if any team had a direct `sourceElo`, teams with only `sourceOdds` were never populated and the simulator threw "Missing Elo" instead of using their odds data
  • Iterations: WorldCupSimulator default 50k→10k; manifest `defaultConfig` for `world_cup` and `epl_standings` now explicitly override `BASE_CONFIG` with 10k so the production fallback matches; test iterations reduced (WorldCup 500→100, EPL 10k→500) to fix timeout failures on slower CI
  • Cleanup: Extracted `runKnockoutRound` out of the 10k-iteration simulation loop; replaced two hot-loop `toSorted()` calls on 2-element arrays with a conditional string comparison; removed local `normalizeProbabilities` in favour of the shared `normalizeSimulationResultColumns`

Test plan

  • `npm run test:run` — all simulator unit tests pass without timeout
  • Typecheck passes (`npm run typecheck`)
  • EPL simulate with mixed Elo+odds data no longer throws

🤖 Generated with Claude Code

## Summary - **Bug fix**: EPL Elo/odds fallback was gated on \`dbEloMap.size === 0\` — if any team had a direct \`sourceElo\`, teams with only \`sourceOdds\` were never populated and the simulator threw "Missing Elo" instead of using their odds data - **Iterations**: WorldCupSimulator default 50k→10k; manifest \`defaultConfig\` for \`world_cup\` and \`epl_standings\` now explicitly override \`BASE_CONFIG\` with 10k so the production fallback matches; test iterations reduced (WorldCup 500→100, EPL 10k→500) to fix timeout failures on slower CI - **Cleanup**: Extracted \`runKnockoutRound\` out of the 10k-iteration simulation loop; replaced two hot-loop \`toSorted()\` calls on 2-element arrays with a conditional string comparison; removed local \`normalizeProbabilities\` in favour of the shared \`normalizeSimulationResultColumns\` ## Test plan - [ ] \`npm run test:run\` — all simulator unit tests pass without timeout - [ ] Typecheck passes (\`npm run typecheck\`) - [ ] EPL simulate with mixed Elo+odds data no longer throws 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chrisp added 1 commit 2026-05-31 17:29:10 +00:00
Fix simulator correctness bugs and reduce test iteration counts
Some checks failed
🚀 Deploy / 🧪 Test (pull_request) Failing after 2m31s
🚀 Deploy / ʦ TypeScript (pull_request) Successful in 1m18s
🚀 Deploy / 🔍 Lint (pull_request) Successful in 48s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
c3b7c77f09
- Fix EPL Elo/odds fallback to populate odds-derived Elo for teams
  missing sourceElo even when other teams have it (was silently throwing)
- Reduce WorldCupSimulator default iterations 50k→10k; test iterations
  500→100 (WorldCup) and 10k→500 (EPL) to prevent timeouts on slow CI
- Override manifest defaultConfig iterations to 10k for world_cup and
  epl_standings so production fallback matches source-level defaults
- Extract runKnockoutRound out of the 10k-iteration simulation loop
- Replace hot-loop toSorted() on 2-element arrays with a conditional
  string comparison (eliminates allocation+sort on every group pair)
- Remove local normalizeProbabilities duplicate; use shared
  normalizeSimulationResultColumns from simulation-probabilities.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
chrisp added 1 commit 2026-05-31 17:34:54 +00:00
Fix darts simulator timeout and world-cup bracket edge case
All checks were successful
🚀 Deploy / 🧪 Test (pull_request) Successful in 2m26s
🚀 Deploy / ʦ TypeScript (pull_request) Successful in 1m16s
🚀 Deploy / 🔍 Lint (pull_request) Successful in 48s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
c0f674f648
- Add numSimulations constructor param to DartsSimulator (same pattern as
  WorldCupSimulator); drop default from 50k→10k; update manifest to match
- Pass 200 iterations in the slow darts column-sum test to prevent CI timeout
- Fix world-cup "SF losers" test to use 48 participants — with only 8,
  the R32 pool has 6 teams and SF never runs, leaving all placement counts
  at 0 and normalization producing probFirst=probThird=1 for one team
- Add manifest iterations: 10_000 override for darts_bracket

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
chrisp merged commit 03726f1a66 into main 2026-05-31 17:39:44 +00:00
Sign in to join this conversation.
No description provided.