Two percent solution#223
Open
tameware wants to merge 3 commits into
Open
Conversation
The heuristic/quick-tricks refactor introduced static_cast<unsigned char>
wrappers on values that v2.9 used as signed, changing search behavior:
- make_3 / make_3_ctx: winner[]/second_best[] .hand and .rank were cast
to unsigned char, turning the -1 "no card" sentinel into 255. This broke
winner[trump].hand == -1 style checks in QuickTricks, losing cutoffs.
- weight_alloc_trump_void2 / _void3: rel_rank[aggr[suit]][...] indexed
through static_cast<unsigned char>(aggr[suit]), truncating the 13-bit
aggregate holding to 8 bits and reading the wrong rel_rank row.
- QuickTricksPartnerHand{Trump,NT}: bit_map_rank index cast the signed
rank through unsigned char.
With these reverted to v2.9's signed handling, the per-move-generation
ordering trace now matches v2.9 exactly (0 divergences on list1), closing
the residual calc gap to parity. Ordering/pruning-only change; double-dummy
results are unchanged and all library tests pass.
Co-authored-by: Cursor <cursoragent@cursor.com>
Whitespace-only cleanup of misindented if/else-if chains and wrapped conditions left over from the v2.9 port; no logic change. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR applies small, targeted micro-optimizations by removing redundant casts in a few hot paths (quick tricks evaluation, heuristic sorting, and alpha-beta search), aiming for a modest performance improvement.
Changes:
- Removed unnecessary
static_cast<unsigned char>/ intermediate temporaries when indexingbit_map_rankandrel_rank. - Simplified assignments from
RelRanksType::abs_rankinto per-suit winner/second-best tracking. - Minor whitespace/formatting adjustments in heuristic sorting code.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| library/src/quick_tricks.cpp | Removes redundant casts when mapping abs_rank[3][suit].rank into bit_map_rank indices. |
| library/src/heuristic_sorting/heuristic_sorting.cpp | Simplifies rel_rank indexing (avoids unnecessary truncating casts) and tidies formatting in void/trump weighting paths. |
| library/src/ab_search.cpp | Removes redundant casts when copying abs_rank winner/second-best rank/hand into Pos state. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| posPoint->winner[st].rank = thrp->rel[aggr].abs_rank[1][st].rank; | ||
| posPoint->winner[st].hand = thrp->rel[aggr].abs_rank[1][st].hand; | ||
| posPoint->second_best[st].rank = thrp->rel[aggr].abs_rank[2][st].rank; | ||
| posPoint->second_best[st].hand = thrp->rel[aggr].abs_rank[2][st].hand |
Copilot AI
added a commit
that referenced
this pull request
Jul 3, 2026
The ASAN CI job was failing because PR #223 (Two percent solution) introduced a missing semicolon at the end of ab_search.cpp:884 in the make_3() function: posPoint->second_best[st].hand = thrp->rel[aggr].abs_rank[2][st].hand ^ missing ; This commit applies all of PR #223's changes (removing unnecessary static_cast<unsigned char>() wrappers and fixing indentation) with the missing semicolon corrected.
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.
Fixes that give a small performance improvement. Merged from branch opus-two-percent.