Validate Precise equity mode against a known postflop equity number - #8
Merged
Conversation
Adds the postflop counterpart to the preflop ground-truth suite: a 9-out flush draw's exact completion rate, 1 - (38/47) x (37/46) ~= 34.97%, the single most rigorously-citable postflop statistic in poker math (exact combinatorics, not scraped from a site). Measured 378/1081 = 34.968% by exhaustively enumerating all C(47,2) turn/river combinations directly through HandEvaluator, with no Equity API involved — isolates the hand-ranking machinery Precise mode depends on from a 0.002-point margin. A second test cross-checks the same flush draw against a set on the same flop through the actual Equity.headsUp API, against a commonly-cited rough "75/25" figure for that matchup (75.35%/24.65% measured, zero ties) — wider tolerance since that citation is an approximation, not exact math, but confirms the Equity API surfaces the underlying verified math correctly. swift test: 183/183 (181 baseline + 2 new). No source changes — Precise mode's existing implementation is unchanged; this closes the "validated against a known postflop equity number" gap in its original validation.
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.
Context
Closing a gap flagged in review of #7: Precise mode was validated by cross-checking against
headsUp/canonicalVsCanonicalinternally, but not against an independently-published postflop equity number the way the preflop ground truths were (cardfight.com citations).What's new
Two tests,
ai-docs/EQUITY.md's new "Postflop" ground-truth subsection:postflopGroundTruthFlushDrawCompletionRate— the primary validation. A 9-out flush draw completes by the river1 - (38/47) × (37/46) ≈ 34.97%of the time: exact combinatorics, the actual source of the widely-repeated "Rule of 4-and-2," not a website figure to trust secondhand. Sets up a naked flush draw (A♠K♠on2♠7♠9♣— no pair, no straight draw live) and exhaustively enumerates allC(47,2) = 1,081turn/river combinations directly throughHandEvaluator, noEquityAPI involved. Measured: 378/1,081 = 34.968% — 0.002pt from the cited figure.postflopGroundTruthFlushDrawVsSetViaEquityEngine— closes the loop throughEquity.headsUpitself: the same flush draw vs. a set on the same flop, against a commonly-cited rough "~75/25" figure (found via web search). Measured: 75.35% / 24.65%. Wider tolerance (±5pt) since this citation is an approximation, not exact math — a corroborating check that the API surfaces the already-verifiedHandEvaluatormath correctly, not a second precision claim.No source changes — Precise mode's implementation (
Equity.exactRangeVsRange,EquityCalculatorView) is unchanged. This PR only adds the missing external validation.Testing
swift test: 183/183 passing (181 baseline + 2 new).EquityCalculatorUITests(no app code touched, but reconfirmed per the standing gate) — all 5 pass.Self-merging once CI is green, per the standing auto-merge policy (all four gates hold: tests, ground-truth validation, app/UI green, CI green; nothing flagged as uncertain beyond what's already documented in
EQUITY.md).