Skip to content

Add standalone poker odds calculator tool - #485

Merged
Marvy247 merged 2 commits into
HitEmPoka:mainfrom
gboigwe:fix/163-odds-calculator
Aug 31, 2026
Merged

Add standalone poker odds calculator tool#485
Marvy247 merged 2 commits into
HitEmPoka:mainfrom
gboigwe:fix/163-odds-calculator

Conversation

@gboigwe

@gboigwe gboigwe commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

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 existing bestHandRank hand 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 on main (audio-controls.test.tsx, reconnect-state.test.ts — unrelated, unchanged by this work)
  • Added 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)
  • Added 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 behavior
  • npx tsc --noEmit — no new errors from this change. Remaining errors are pre-existing and unrelated (token-selector.test.tsx, page.tsx tokenChoice typing, Table.tsx replayEntry/setReplayEntry, reconnect-state.ts) — not touched, since this PR doesn't cause them.

- 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
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Marvy247
Marvy247 merged commit 3fab70c into HitEmPoka:main Aug 31, 2026
5 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement a poker odds calculator tool within the app

2 participants