Skip to content

Add ICM (Independent Chip Model) calculator - #10

Merged
testtest126 merged 3 commits into
mainfrom
feature/icm-model
Jul 22, 2026
Merged

Add ICM (Independent Chip Model) calculator#10
testtest126 merged 3 commits into
mainfrom
feature/icm-model

Conversation

@testtest126

Copy link
Copy Markdown
Owner

Summary

  • ICM.equities(stacks:payouts:) — exact Malmuth-Harville tournament $EV via bitmask-memoized recursion over finishing-position probabilities (O(2ⁿ·n²), not literal n! enumeration). The one model in this codebase that's exact math rather than a hand-tuned percentage table.
  • Validated against a published worked example (Wikipedia's "Independent Chip Model" article: 50/30/20 stacks, 70/30 payouts) — matched to the source's own rounding, and to 1e-9 against exact fractions independently re-derived by hand (shown in full in ai-docs/ICM.md so 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.
  • Sanity gates: equal stacks split equally, the 2-player closed form, total-equity-conservation across varied fields, and the "ICM tax" (chip leader's $/chip < short stack's $/chip).
  • ICMRiskPremium.assess — an ICM-adjusted required-equity-to-call overlay for all-in confrontations (same "adjustment layer, not mutation" shape as BountyEquity), with every simplification disclosed in the doc comment and ai-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, and otherStacks must be the complete remaining field.
  • New ICM Calculator app view (stacks + payouts in, per-seat $EV out, live recompute — ICM.equities is pure/fast, no async dispatch needed), wired into StudyTool. Deliberately scoped to just the calculator; ICMRiskPremium is 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.
  • App build succeeds on simulator (iPhone 17, iOS 27.0, Xcode 27 beta).
  • App UI test suite: 18/18 green (excludes BankrollTrackerUITests.testLogSessionUpdatesListAndSummary, previously confirmed pre-existing/flaky on a clean main checkout, unrelated to this or the prior PR).
  • New ICMCalculatorUITests covering 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):

Seat Published (≈) This project (exact)
A $45 $45.178571... (1265/28)
B $32 $32.25 (129/4)
C $22 $22.571429... (158/7)

Sum: exactly $100 in both the published figures (approximately) and this project's exact computation.

🤖 Generated with Claude Code

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.
@testtest126
testtest126 merged commit d041bf2 into main Jul 22, 2026
2 checks passed
@testtest126
testtest126 deleted the feature/icm-model branch July 22, 2026 02:57
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