Add Precise (exact) equity mode alongside Fast (Monte Carlo) - #7
Merged
Conversation
New Equity.exactRangeVsRange/exactCanonicalVsCanonical: exact combo-weighted equity, computed by enumerating every valid (non-overlapping) combo pair and exactly enumerating every board completion per pair via headsUp, then averaging equally across pairs — mathematically exact, not an approximation, since every combo pair has the same number of board completions for a fixed board state. 4 new tests, including a direct cross-check against headsUp and against canonicalVsCanonical's Monte Carlo estimate on the same spot. EquityCalculatorView gets a Fast/Precise mode toggle. Precise is disabled with an on-screen explanation whenever the board is empty (Preflop) — exact combo-weighted enumeration there is (valid pairs) x 1,712,304 boards, minutes not seconds even for one pairing, and switching street back to Preflop while Precise is selected falls back to Fast automatically rather than stranding the toggle on an unreachable selection. Also corrects the Fast path's live iteration count from a value that looked fine against macOS-native `swift test` timings down to one actually measured fast on an iOS Simulator (10,000, not 50,000 — the simulator runs meaningfully slower for this CPU-bound work than the command-line benchmark suggested), and fixes two more UI-test-only issues surfaced while verifying Precise mode end-to-end: SwiftUI's rank-selection menu doesn't show all 13 ranks without scrolling, and tapping an element immediately after an adjacent Form row changes can compute a stale off-screen hit point before layout settles. swift test: 181/181 (177 baseline + 4 new). App: all 7 UI test suites green on simulator, including 5 EquityCalculatorUITests (2 new, covering Precise mode's availability rules and an end-to-end exact calculation on a flop).
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
Follow-up to #6 (merged). Resolves an explicit ask: an optional "Precise" (exact enumeration) mode for the Equity Calculator UI, kept separate from the default Fast (Monte Carlo) path so a button tap can never hang the screen.
Correcting the premise that prompted this: the Calculate button never actually called
Equity.headsUp/exact enumeration — that was already fixed before #6 merged (verified by reading the merged code directly:EquityCalculatorModel.calculatecalledEquity.rangeVsRange). The original UI test failures were a notation-case bug and SwiftUIForm/Listlazy rendering, both fixed in #6. This PR adds the genuinely new ask — an explicit exact mode — as its own scoped feature.What's new
Equity.exactRangeVsRange/exactCanonicalVsCanonical— exact combo-weighted equity: enumerates every valid (non-card-overlapping) combo pair, exactly enumerates every board completion per pair viaheadsUp, averages equally across pairs. This is mathematically exact, not an approximation — every combo pair has the same number of board completions for a fixed board state, so uniform averaging is the true combo-weighted figure, the same quantitycanonicalVsCanonicalestimates by sampling. 4 new tests, including direct cross-checks againstheadsUpand againstcanonicalVsCanonical.EquityCalculatorViewFast/Precise toggle — Precise is disabled (with an on-screen explanation) whenever the board is empty. Exact combo-weighted enumeration preflop is(valid pairs) × 1,712,304 boards— minutes, not seconds, even for one pairing. Switching back to Preflop while Precise is selected auto-falls-back to Fast.Bugs found and fixed while verifying end-to-end (not just "compiles")
swift test(macOS-native,-Onone) timings, but the iOS Simulator runs measurably slower for this CPU-bound work — 50k took 30+ seconds there, not sub-second. Corrected to 10,000 (measured, not estimated: ~10s tap-to-result end-to-end, confirmed via the UI tests). Documented the discrepancy inEQUITY.md.tapWhenHittablehelper that waits for.isHittablebefore tapping, used for the new board-card-picker interactions.Testing
swift test: 181/181 passing (177 baseline + 4 new).EquityCalculatorUITests(2 new: Precise-mode availability rules, and an end-to-end exact calculation on a flop board).Not merging until CI is green and gates hold, per the standing auto-merge policy.