Skip to content

Refactor - #268

Open
tameware wants to merge 6 commits into
dds-bridge:developfrom
tameware:refactor
Open

Refactor#268
tameware wants to merge 6 commits into
dds-bridge:developfrom
tameware:refactor

Conversation

@tameware

Copy link
Copy Markdown
Collaborator

Factor out duplication. Each change is a separate commit.

Reviewers, let me know if you'd prefer to see this split into four PRs.

tameware and others added 4 commits July 24, 2026 16:20
Deduplicate the trump-first / skip-trump iteration logic used throughout
QuickTricks behind next_quick_trick_suit, with unit tests pinning the order.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add characterization tests for the hand-0..2 make/undo path, then factor
the identical rank/aggr/length updates into remove_card and restore_card.

Co-authored-by: Cursor <cursoragent@cursor.com>
Collapse the thrp and ctx duplicates into a single make_3/undo_0 pair that
uses the search facade, reuse remove_card/restore_card, and delete the unused
simple helpers. Characterization tests cover trick completion and undo.

Co-authored-by: Cursor <cursoragent@cursor.com>
Collapse the identical depth>=20 and depth<20 TT lookup blocks into
apply_ab_tt_lookup, with unit tests covering miss, hit polarity, and
best-move TT updates on both depth paths.

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 refactors duplicated logic in core solver components by extracting shared helpers (QuickTricks suit iteration and AB-search TT lookup / make+undo card handling) and adds characterization/unit tests to lock in existing behavior before further consolidation.

Changes:

  • Introduces next_quick_trick_suit() and replaces repeated suit-advance blocks in QuickTricks() with the helper.
  • Factors the duplicated ab_search TT lookup logic into apply_ab_tt_lookup() and consolidates repeated card remove/restore code paths.
  • Adds new Bazel test targets and unit/characterization tests for the extracted helpers, plus updates test visibility to allow new test subpackages to link against testable_dds.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
library/tests/quick_tricks/next_suit_test.cpp Adds unit tests that pin QuickTricks suit-iteration order and skipping behavior.
library/tests/quick_tricks/BUILD.bazel Introduces a dedicated Bazel cc_test target for the QuickTricks suit-iteration tests.
library/tests/ab_search/tt_lookup_test.cpp Adds tests that pin TT hit/miss behavior and best-move propagation for the shared lookup helper.
library/tests/ab_search/make3_test.cpp Adds characterization tests for make_3/undo_0 trick completion and winners snapshot/restore behavior.
library/tests/ab_search/make_undo_test.cpp Adds characterization tests for make/undo behavior for hands 0–2 and confirms isolation from other hands.
library/tests/ab_search/BUILD.bazel Introduces Bazel cc_test targets for the new ab_search unit/characterization tests.
library/src/quick_tricks.hpp Declares the new next_quick_trick_suit() helper used by QuickTricks and tested by new unit tests.
library/src/quick_tricks.cpp Implements next_quick_trick_suit() and replaces duplicated suit-advance logic with the helper.
library/src/BUILD.bazel Extends testable_dds visibility to new test subpackages (ab_search, quick_tricks).
library/src/ab_search.hpp Exposes undo helpers and the new apply_ab_tt_lookup() function for unit testing and shared use.
library/src/ab_search.cpp Implements apply_ab_tt_lookup() and consolidates repeated card remove/restore logic across make/undo paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
@tameware
tameware marked this pull request as ready for review July 24, 2026 15:44
@tameware tameware self-assigned this Jul 24, 2026
@tameware
tameware requested a review from zzcgumn July 24, 2026 15:45
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