Skip to content

Two percent solution#223

Open
tameware wants to merge 3 commits into
dds-bridge:developfrom
tameware:two-percent-solution
Open

Two percent solution#223
tameware wants to merge 3 commits into
dds-bridge:developfrom
tameware:two-percent-solution

Conversation

@tameware

@tameware tameware commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Fixes that give a small performance improvement. Merged from branch opus-two-percent.

tameware and others added 2 commits July 3, 2026 00:40
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 indexing bit_map_rank and rel_rank.
  • Simplified assignments from RelRanksType::abs_rank into 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.

Comment thread library/src/ab_search.cpp Outdated
Comment thread library/src/heuristic_sorting/heuristic_sorting.cpp Outdated
Comment thread library/src/heuristic_sorting/heuristic_sorting.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@tameware tameware marked this pull request as ready for review July 3, 2026 12:47
@tameware tameware requested a review from Copilot July 3, 2026 12:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread library/src/ab_search.cpp
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.
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