Add ICM (Independent Chip Model) calculator - #10
Merged
Conversation
ICM.equities computes exact tournament $EV via bitmask-memoized recursion over finishing-position probabilities, validated against a published Wikipedia worked example (exact fractions independently re-derived by hand) plus a second hand-derived 3-payout example, ICM-tax and conservation sanity checks. ICMRiskPremium is a separate overlay (same shape as BountyEquity) computing the ICM-adjusted equity required to profitably call an all-in, with every simplification (single all-in, busting=$0, no FGS, complete-remaining-field assumption) disclosed in the doc comment.
Full by-hand re-derivation of the Wikipedia worked example's exact fractions, and every ICMRiskPremium simplification spelled out.
Live-recomputing stacks + payouts -> per-seat $EV screen (ICM.equities is pure and fast, no async dispatch needed). Deliberately scoped to just the calculator; ICMRiskPremium has no dedicated screen yet.
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
ICM.equities(stacks:payouts:)— exact Malmuth-Harville tournament $EV via bitmask-memoized recursion over finishing-position probabilities (O(2ⁿ·n²), not literaln!enumeration). The one model in this codebase that's exact math rather than a hand-tuned percentage table.1e-9against exact fractions independently re-derived by hand (shown in full inai-docs/ICM.mdso the arithmetic is checkable without running code). A second hand-derived 3-payout example exercises the recursion's 3rd-place branch, which the 2-payout published example never reaches.ICMRiskPremium.assess— an ICM-adjusted required-equity-to-call overlay for all-in confrontations (same "adjustment layer, not mutation" shape asBountyEquity), with every simplification disclosed in the doc comment andai-docs/ICM.md: single full-stack all-in, busting = $0 (not a guaranteed min-cash — flagged as slightly overstating the true premium), no Future Game State, andotherStacksmust be the complete remaining field.ICM.equitiesis pure/fast, no async dispatch needed), wired intoStudyTool. Deliberately scoped to just the calculator;ICMRiskPremiumis implemented and tested but has no dedicated screen yet (noted as a natural follow-up, not a gap).Test plan
swift test(PokerKit): 220/220 green (208 baseline + 12 new ICM tests), no lost tests.BankrollTrackerUITests.testLogSessionUpdatesListAndSummary, previously confirmed pre-existing/flaky on a cleanmaincheckout, unrelated to this or the prior PR).ICMCalculatorUITestscovering default-stacks equity summing to the prize pool, adding a player row, and invalid-stack validation.ICM validation numbers (actual vs. published)
Wikipedia's worked example (stacks 50/30/20, payouts 70/30):
Sum: exactly $100 in both the published figures (approximately) and this project's exact computation.
🤖 Generated with Claude Code