Skip to content

Add ETC at the fourth hand and killer-second lead ordering - #459

Merged
zzcgumn merged 3 commits into
dds-bridge:developfrom
randalburns:ordering
Nov 17, 2026
Merged

zzcgumn merged 3 commits into
dds-bridge:developfrom
randalburns:ordering

Conversation

@randalburns

Copy link
Copy Markdown
Contributor

This adds two search-ordering changes. Values are unchanged; only the order in which positions are searched changes.

Enhanced transposition cutoff (ETC) at the fourth hand. In the first three tricks of a search, before searching the fourth hand's cards, each resulting position is probed with the same quick tests ab_search_0 applies first: the tricks_max bounds, then the transposition table. If any child is already known to cut, the node returns at once.

Killer second. At a lead node, when the first lead fails, the lead that last cut at this depth is tried next (Moves::PromoteNext).

Results
Measured against develop (b761675) with dtest -n 1 (single thread) on hands/list1000.txt, optimized builds on Apple silicon, with base and patched runs interleaved:

Workload develop this PR Ratio
calc (CalcDDtable), all 1000 deals 91.2 s 89.6 s 0.983
calc, costliest 1% of deals (10) 0.953
calc, costliest 10% of deals (100) 0.970
solve (SolveBoard), 1000 deals 19.39 s 19.37 s 1.00

The two calc repetitions gave 0.990 and 0.976. Run-to-run variation of the same binary was under 1%. The gain is concentrated in hard deals: the median per-deal ratio is 0.998. Single-board solves are neutral.

Tests

  • dtest_reference_list_test (new) runs dtest on hands/list100.txt in solve, calc and play modes and fails on any mismatch with the stored reference results. play mode solves positions partway through a trick. Deliberately breaking ETC (cutting on the wrong child value, not restoring tricks_max, dropping the child's win ranks) fails all three modes.
  • Unit tests for Moves::PromoteNext and GetMove cover:
    • the match becomes the next move, and the moves in between keep their order;
    • a rank inside a move's sequence matches;
    • the current and last moves are handled;
    • moves in another suit, moves already tried and cards with no match leave the list unchanged.
  • In the full benchmark runs above, there were no mismatches on list1000 in either mode.

🤖 Generated with Claude Code

randalburns and others added 2 commits November 13, 2026 17:43
Enhanced transposition cutoff: in the first three tricks of a search,
before searching the fourth hand's cards, probe each resulting position
with the same quick tests ab_search_0 applies first (tricks_max bounds,
then the transposition table). If any child is already known to cut,
return at once. Values are unchanged; only the search order changes.

Killer second: at a lead node, when the first lead fails, try the lead
that last cut at this depth next.

Tested against unpatched DDS on 2000 deals: 0 mismatches in all 20
CalcDDtable values, the SolveBoard score and the returned card.
Single-thread CalcDDtableN wall time ratio 0.962 overall, 0.940 on the
costliest 1% of deals. SolveBoard NT is neutral (1.007); spades 0.985.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ETC and the killer-second lead change only the search order, so the
values must match earlier releases. Add dtest_reference_list_test, which
runs dtest on hands/list100.txt in solve, calc and play modes and fails
on any mismatch with the stored reference results; play mode solves
positions partway through a trick. Breaking ETC (cutting on the wrong
child value, not restoring tricks_max, dropping the child's win ranks)
fails all three.

Add unit tests for Moves::PromoteNext and GetMove: the match becomes the
next move and the moves between keep their order, a rank inside a
move's sequence matches, the current and last moves are handled, and
moves in another suit, moves already tried and cards with no match
leave the list unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@randalburns

Copy link
Copy Markdown
Contributor Author

Small change. Bigger benefit on AMD/Intel hardware.

@randalburns
randalburns marked this pull request as ready for review November 13, 2026 23:03
@zzcgumn
zzcgumn requested a balanced review from Copilot November 14, 2026 12:27

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.

🔵 Needs a closer look

Core pruning, winning-rank propagation, and speculative trick-state changes require maintainer validation across partial-trick/warm-context searches and all three transposition-table implementations because runtime regression testing was unavailable.

No open issues 🎉

What changed in this PR

This PR optimizes DDS search by adding fourth-hand cutoffs and prioritizing previously successful leads, with regression tests to check that solver results remain unchanged.

Changes:

  • Probe fourth-hand child positions against trick bounds and the transposition table during the first three tricks.
  • Try the previously successful lead next when the first lead fails.
  • Add move-ordering unit tests and reference-result checks for solve, table calculation, and play analysis.
File Description
library/​tests/​test_dtest_reference_list.py Checks three solver modes against stored reference results.
library/​tests/​moves/​moves_test.cpp Tests indexed move access and promotion behavior.
library/​tests/​BUILD.bazel Registers the reference regression test.
library/​src/​solver_context/​solver_context.hpp Declares move access and promotion wrappers.
library/​src/​solver_context/​solver_context.cpp Implements the move-generation wrappers.
library/​src/​moves/​moves.hpp Declares and documents move access and promotion methods.
library/​src/​moves/​moves.cpp Implements indexed access and stable move promotion.
library/​src/​ab_search.cpp Adds fourth-hand cutoff probing and killer-second lead ordering.
hands/​BUILD.bazel Exports list100.txt for the regression test.

Review effort: Balanced

@zzcgumn

zzcgumn commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

@randalburns, I am happy to merge this once conflicts have been resolved.

…ring

# Conflicts:
#	library/tests/moves/moves_test.cpp
@randalburns

Copy link
Copy Markdown
Contributor Author

Conflict is resolved. I'm passing all tests on MacOS and Linux. Claude thinks the failed test is a slow windows runner that timed out at 60s. I don't have rerun permission on the workflow. Cheers.

@zzcgumn
zzcgumn merged commit 9c41963 into dds-bridge:develop Nov 17, 2026
16 of 17 checks passed
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.

3 participants