Repository navigation
Support exact suited combos (e.g. KhQh:1.0) in range strings - #227
Conversation
PrivateRangeConverter::rangeStr2Cards currently accepts rank-class tokens (AA, AKs, AKo) with an optional weight, but rejects any 4-character token with "range str X len not valid" - there's no way to specify a single exact suited combo, only a whole rank class expanded across all 4 suits. This comes up whenever a range needs to distinguish combos by suit - most commonly when constructing a range for a turn/river solve where only some suits of a given rank-class actually have relevant equity (e.g. only the two suits that make a flush should continue, not all four). This was previously raised in bupticybee#111, where the maintainer said they'd merge a fix if submitted as a proper PR with passing tests. The attached patch in that issue was never followed up as an actual PR, so it never landed. This is a clean implementation of the same idea: - Adds a range_len == 4 branch to rangeStr2Cards, following the exact pattern of the existing 2/3-character branches: parse the two 2-char card codes, validate they're not the same card, apply the existing dead-card interception check, push a single PrivateCards with the given weight. - Existing rank-class tokens (AKs, AA, etc.) are completely unaffected. - Adds 3 unit tests in test/test.cpp covering the happy path (mixed weights alongside a normal rank-class token), invalid input (same card twice), and dead-card collision handling.
|
I think this will break isomorphism calculation. Mind do a few more tests? One thing can do is to disable isomorphism when using KhQh:1.0 kind of string. |
An exact suited combo (e.g. "KhQh:1.0") only ever produces the one suit-pair requested, never its siblings in the other 3 suits. Suit isomorphism assumes every rank-class is symmetric across all 4 suits, so this breaks it: exchange_color()'s missing-entry lookup silently defaults to index 0 when a combo has no sibling in the swapped suit, corrupting an unrelated hand's value. Verified both in isolation (exchange_color corrupts values for an asymmetric range but not a symmetric one) and end-to-end against a real solve with a real pending chance node: leaving isomorphism on for an asymmetric-combo range produces up to 0.99 absolute strategy divergence vs. isomorphism off, versus ~0.0006 for a symmetric control range. PokerSolver::train() now detects exact combos via a new optional has_exact_combo out-param on PrivateRangeConverter::rangeStr2Cards, and silently disables isomorphism (with a warning) rather than producing corrupted results. Added PokerSolver::usedIsomorphism() so callers can detect the override. Addresses maintainer feedback on bupticybee#227: bupticybee#227 (comment)
|
Confirmed — you were right, this does break isomorphism. Pushed a fix. Root cause: Verified two ways against the unpatched code:
Fix: went with your suggested approach — disable isomorphism when an exact combo is present, rather than trying to make isomorphism itself suit-aware (bigger, riskier change). Added tests: detection-flag correctness, a direct 🤖 Generated with Claude Code |
|
Yeah I think it's good to merge now. |
PrivateRangeConverter::rangeStr2Cardscurrently accepts rank-class tokens (AA,AKs,AKo) with an optional weight, but rejects any 4-character token withrange str X len not valid— there's no way to specify a single exact suited combo, only a whole rank class expanded across all 4 suits.This comes up whenever a range needs to distinguish combos by suit — most commonly when constructing a range for a turn/river solve where only some suits of a given rank-class actually have relevant equity (e.g. only the two suits that make a flush should continue, not all four).
This was previously raised in #111, where the maintainer said they'd merge a fix if submitted as a proper PR with passing tests — the attached patch in that issue was never followed up as an actual PR, so it never landed. This PR is a clean implementation of the same idea:
range_len == 4branch torangeStr2Cards, following the exact pattern of the existing 2/3-character branches: parse the two 2-char card codes, validate they're not the same card, apply the existing dead-card interception check, push a singlePrivateCardswith the given weight.AKs,AA, etc.) are completely unaffected — this only adds a new branch, doesn't touch the existing ones.test/test.cpp:test_converter_exact_combo— mixing an exact combo with a weight, another exact combo with a different weight, and a normal rank-class token in the same range string; verifies only the requested suits appear (e.g.KhQh/KcQcpresent,KdQd/KsQsabsent).test_converter_exact_combo_invalid— same card twice (AhAh) throws, matching existing behavior forAAs.test_converter_exact_combo_dead_card— a combo colliding with a board card is silently dropped, matching existingboardsHasInterceptbehavior in the other branches.All 3 new tests pass; the existing (sole enabled) test
test_poker_solver_benchis unaffected. Rancmake .. && make install && make testclean end to end.Happy to also add a line to the README's range example if useful.
Closes #111.
🤖 Generated with Claude Code