fix(calpoker): correct kicker selection with 3+ pairs#256
Open
MrDennisV wants to merge 2 commits intoChia-Network:mainfrom
Open
fix(calpoker): correct kicker selection with 3+ pairs#256MrDennisV wants to merge 2 commits intoChia-Network:mainfrom
MrDennisV wants to merge 2 commits intoChia-Network:mainfrom
Conversation
When a hand contains 3 or more pairs, the kicker was incorrectly selected from the third pair instead of the highest singleton. Example with cards: 2♣, 4♠, 5♥, 4♥, 5♣, 9♥, 9♣, K♦ (3 pairs + K + 2) - Before: Two Pair (9s & 5s) with 4 as kicker - After: Two Pair (9s & 5s) with K as kicker The bug occurred because truncate 5 blindly took the first 5 cards after sorting by (count DESC, rank DESC), meaning cards with count=2 (pairs) always came before count=1 (singletons). The fix adds two helper functions: - best_singleton_index: finds highest singleton in sorted list - select_group_indices: detects incomplete pairs and fixes kicker Edge case handled: when no singleton exists (e.g., 4 pairs), the original behavior is preserved. Performance: ~0.2% overhead for normal hands, similar cost for the bug case (3+ pairs).
Contributor
|
Thank you. I'll read these changes today! |
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.
When a hand contains 3 or more pairs, the kicker was incorrectly selected from the third pair instead of the highest singleton.
Example with cards: 2♣, 4♠, 5♥, 4♥, 5♣, 9♥, 9♣, K♦ (3 pairs + K + 2)
The bug occurred because truncate 5 blindly took the first 5 cards after sorting by (count DESC, rank DESC), meaning cards with count=2 (pairs) always came before count=1 (singletons).
The fix adds two helper functions:
Edge case handled: when no singleton exists (e.g., 4 pairs), the original behavior is preserved.
Performance: ~0.2% overhead for normal hands, similar cost for the bug case (3+ pairs).