Add standalone poker odds calculator tool - #485
Merged
Conversation
- odds-calculator.ts: Monte Carlo win/tie/loss estimator built on the existing bestHandRank evaluator. Takes hole cards, known board cards, and an opponent count (each opponent modeled as a random unknown hand); validates inputs (card count, duplicates, range, remaining-deck size) before simulating. - OddsCalculatorModal.tsx: standalone modal with rank/suit pickers for hole cards and up to 5 board cards, an opponent-count slider, and a win/tie/loss result display. - page.tsx: adds a "🎲 ODDS" button next to the existing STATS link to open the calculator as a standalone tool, independent of any active table. Closes HitEmPoka#163
|
@gboigwe Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a standalone odds calculator, accessible from the main menu independent of any active table (a "🎲 ODDS" button next to the existing STATS link).
odds-calculator.ts: a Monte Carlo win/tie/loss estimator built on top of the existingbestHandRankhand evaluator (no duplicated evaluation logic). Takes hole cards, 0-5 known board cards, and an opponent count; validates card count/duplicates/range/remaining-deck-size before simulating.OddsCalculatorModal.tsx: rank/suit dropdown pickers for both hole cards and up to 5 board cards, an opponent-count slider (1-8), and a win/tie/loss percentage display.Issue
Closes #163
Scope note on "opponent ranges"
The issue mentions inputting "opponent ranges." This implementation models each opponent as a random unknown two-card hand (equivalent to an "any two cards" range) rather than building a full hand-range selection UI, which would be a much larger separate feature (a 13x13 range-grid picker, weighted range logic, etc.). This still delivers real, useful win/tie/loss probabilities for the stated learning-tool purpose; a dedicated range-input UI is a reasonable follow-up, not attempted here.
Test plan
npx vitest run— 138 passed, same 4 pre-existing failures as onmain(audio-controls.test.tsx,reconnect-state.test.ts— unrelated, unchanged by this work)odds-calculator.test.ts(9 tests): input validation (hole card count, board size, opponent range, duplicates, out-of-range values, insufficient remaining deck), a deterministic case (hero holds a royal flush on a complete board → exactly 100% win rate, since no hand can tie or beat it), a probability-sums-to-1 check, and a statistical sanity check (pocket aces heads-up preflop wins >70% against a random hand, consistent with the well-known ~85% baseline)odds-calculator-modal.test.tsx(6 tests): closed/open rendering, validation error when hole cards are incomplete, a full calculate flow asserting win/tie/loss are displayed, duplicate-card rejection, and close-button behaviornpx tsc --noEmit— no new errors from this change. Remaining errors are pre-existing and unrelated (token-selector.test.tsx,page.tsxtokenChoicetyping,Table.tsxreplayEntry/setReplayEntry,reconnect-state.ts) — not touched, since this PR doesn't cause them.