Skip to content

Validate Precise equity mode against a known postflop equity number - #8

Merged
testtest126 merged 1 commit into
mainfrom
feature/postflop-ground-truth
Jul 21, 2026
Merged

Validate Precise equity mode against a known postflop equity number#8
testtest126 merged 1 commit into
mainfrom
feature/postflop-ground-truth

Conversation

@testtest126

Copy link
Copy Markdown
Owner

Context

Closing a gap flagged in review of #7: Precise mode was validated by cross-checking against headsUp/canonicalVsCanonical internally, 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:

  1. postflopGroundTruthFlushDrawCompletionRate — the primary validation. A 9-out flush draw completes by the river 1 - (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♠ on 2♠7♠9♣ — no pair, no straight draw live) and exhaustively enumerates all C(47,2) = 1,081 turn/river combinations directly through HandEvaluator, no Equity API involved. Measured: 378/1,081 = 34.968% — 0.002pt from the cited figure.
  2. postflopGroundTruthFlushDrawVsSetViaEquityEngine — closes the loop through Equity.headsUp itself: 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-verified HandEvaluator math 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).
  • App: re-ran 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).

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.
@testtest126
testtest126 merged commit f266f19 into main Jul 21, 2026
2 checks passed
@testtest126
testtest126 deleted the feature/postflop-ground-truth branch July 21, 2026 17:12
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.

1 participant