Repository navigation
Add ETC at the fourth hand and killer-second lead ordering - #459
Conversation
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>
|
Small change. Bigger benefit on AMD/Intel hardware. |
There was a problem hiding this comment.
🔵 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
|
@randalburns, I am happy to merge this once conflicts have been resolved. |
…ring # Conflicts: # library/tests/moves/moves_test.cpp
|
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. |
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_0applies first: thetricks_maxbounds, 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) withdtest -n 1(single thread) onhands/list1000.txt, optimized builds on Apple silicon, with base and patched runs interleaved:calc(CalcDDtable), all 1000 dealscalc, costliest 1% of deals (10)calc, costliest 10% of deals (100)solve(SolveBoard), 1000 dealsThe two
calcrepetitions 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) runsdtestonhands/list100.txtinsolve,calcandplaymodes and fails on any mismatch with the stored reference results.playmode solves positions partway through a trick. Deliberately breaking ETC (cutting on the wrong child value, not restoringtricks_max, dropping the child's win ranks) fails all three modes.Moves::PromoteNextandGetMovecover:list1000in either mode.🤖 Generated with Claude Code