Skip to content

Suit isomorphism: leave a combo without a suit-swapped twin in place - #236

Open
adihebbalae wants to merge 1 commit into
bupticybee:consolefrom
adihebbalae:fix/iso-mirror-swap
Open

adihebbalae wants to merge 1 commit into
bupticybee:consolefrom
adihebbalae:fix/iso-mirror-swap

Conversation

@adihebbalae

@adihebbalae adihebbalae commented Nov 22, 2026 •

Copy link
Copy Markdown

What

exchange_color() (include/tools/utils.h) looks up each combo's suit-swapped twin in privateint2ind, which was zero-filled. A combo whose twin is not in the range was therefore swapped with the combo at index 0. The table now starts at -1, and such a combo keeps its own value.

Why

This is not only the exact-combo case from #227. It happens in ordinary solves with plain rank-class ranges. On Kh7d2c the turn Ks makes hearts and spades interchangeable for the river. Every combo holding Ks has its twin holding Kh, a board card, so the twin is not in the range. On each mirrored river card, combo 0 (a live hand) lost its river values, and a dead combo received them. BestResponse.cpp calls the same function, so the printed exploitability is affected too.

How tested

  • test_exchange_color_corrupts_asymmetric_range pinned the old swap. It is renamed test_exchange_color_asymmetric_range, and its second block now expects a no-op. That block fails before the fix and passes after it.
  • New test_exchange_color_dealt_card_twin_on_board: the solver's own case (Kh7d2c, hearts <-> spades exchanged, range AK,KQ,QJ,T9s). Each twinless combo keeps its value, and each other combo swaps with its twin.
  • Repro: resources/text/repro_iso_mirror_swap.txt. Kh7d2c is checked through to the river, with one 50% river bet. Run it once with set_use_isomorphism 1 and once with 0 (set_dump_rounds 3), then compare OOP's river strategies on the check-check / check-check line. Before this change, combo 0 (AdAc) shows exactly 50/50 after the turn Ks on every spade river with isomorphism on. That is the untrained strategy of the dead combo it was swapped with. With isomorphism off, the same combo checks 0.1% to 14% and bets the rest (actions are [CHECK, BET]). Exploitability does not show this: the best response goes through the same function, and the error cancels.

Before (console 02c8021) / after (this branch):

gtest, this branch's test/test.cpp built against console's utils.h (before):
[  FAILED  ] TestCase.test_exchange_color_asymmetric_range
[  FAILED  ] TestCase.test_exchange_color_dealt_card_twin_on_board
  (11 failed EXPECT_EQs, e.g. value[i2c3d] is 2, expected before[i2c3d] = 1)

gtest, this branch (after):
[       OK ] TestCase.test_exchange_color_asymmetric_range
[       OK ] TestCase.test_exchange_color_dealt_card_twin_on_board
[       OK ] TestCase.test_poker_solver_disables_isomorphism_for_exact_combo
[       OK ] TestCase.test_poker_solver_keeps_isomorphism_without_exact_combo
[       OK ] TestCase.test_converter_exact_combo_flags_isomorphism_unsafe
repro, river strategies with isomorphism on vs off (82156 turn/river/combo entries):
console 02c8021: 18 entries differ by more than 0.0001, worst 0.4985, all after the turn Ks
  turn Ks river Ts combo AdAc: on [0.5, 0.5] off [0.001, 0.999]
  turn Ks river Js combo AdAc: on [0.5, 0.5] off [0.075, 0.925]
  turn Ks river 8s combo AdAc: on [0.5, 0.5] off [0.144, 0.856]
this branch: worst difference 0.0001 (6 entries on one river card, float rounding)

Notes

exchange_color() looked each combo's twin up in a zero-filled table, so a
combo whose twin is not in the range (the twin holds a board card) was
swapped with the combo at index 0 of the range.

This happens in ordinary solves with plain rank-class ranges: on Kh7d2c the
turn Ks makes hearts and spades interchangeable for the river, and every
combo holding Ks has its twin holding Kh. Combo 0, a live hand, then lost
its river values on the mirrored river cards and a dead combo received
them. BestResponse uses the same function, so the printed exploitability
is off too.

The table now starts at -1 and a combo without a twin keeps its value.
test_exchange_color_corrupts_asymmetric_range pinned the old swap; it is
renamed test_exchange_color_asymmetric_range and now expects a no-op.
test_exchange_color_dealt_card_twin_on_board covers the solver's case.
resources/text/repro_iso_mirror_swap.txt: Kh7d2c checked to the river,
one 50% river bet. Run it with set_use_isomorphism 1 and 0: after the turn
Ks, combo 0 (AdAc) shows 50/50 on every spade river with isomorphism on,
the untrained strategy of the dead combo it was swapped with; with the fix
both runs agree.
@Takumi-trbl

Takumi-trbl commented Nov 22, 2026 via email

Copy link
Copy Markdown

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.

2 participants