diff options
Diffstat (limited to 'src/search.c')
| -rwxr-xr-x | src/search.c | 76 |
1 files changed, 50 insertions, 26 deletions
diff --git a/src/search.c b/src/search.c index 6e596ab..fbef312 100755 --- a/src/search.c +++ b/src/search.c @@ -146,6 +146,8 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx, INT iExtend; ULONG uNextDepth; ULONG uLegalMoves = 0; + FLAG fInLeftovers = FALSE; + ULONG uLeftoverPicks = 0; HASH_ENTRY *pHash; FLAG fThreat; FLAG fSkipNull; @@ -421,7 +423,7 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx, // we generated at this ply using a shallower // search. "Internal Iterative Deepening" or // something like it. - if ((iAlpha + 1 != iBeta) && + if ((TRUE == pi->fPvNode) && (mvHash.uMove == 0) && (ctx->sMoveStack.mvf[x].iValue < SORT_THESE_FIRST) && (0 == (ctx->sMoveStack.mvf[x].iValue & @@ -462,36 +464,58 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx, if (x < ctx->sMoveStack.uEnd[ctx->uPly]) { ASSERT(x >= ctx->sMoveStack.uBegin[ctx->uPly]); - if (uLegalMoves < SEARCH_SORT_LIMIT(ctx->uPly)) + // EXPERIMENT (replaces the old pure move-count + // SEARCH_SORT_LIMIT gate -- see lmr_testing/RESULTS.md): + // a fixed count is blind to whether this move list is a + // "strong team" (lots of winning captures/killers) or a + // "weak team" (nothing but ordinary quiet moves) -- + // stopping at count N throws away real signal when N + // good moves is an arbitrary cutoff partway through a + // list full of good moves, modeled on Crafty (hash, + // then MVV/LVA captures, then killers -- all always + // fully ordered -- only *then* does its cheap fallback + // kick in) and Stockfish (a value threshold, not a + // position threshold, decides what's worth sorting). + // + // On an IID-rescored ply, iValue is a real eval-axis + // score (see RescoreMovesViaSearch/ComputeMoveScore) -- + // GOOD_MOVE is a generate.c ordering-encoding constant, + // meaningless on that axis, so always fully select + // there with no bailout point at all (unchanged from + // before this experiment). + // + // Otherwise: keep fully selecting for as long as every + // move found so far is >= GOOD_MOVE (a "high performer" + // -- this constant already sits, by construction, below + // every killer tier and SORT_THESE_FIRST's + // winning/even-capture range, and above ordinary quiet + // moves and losing captures, so it's a real quality + // floor already baked into generate.c's own encoding, + // not a new one). The first time a selection reveals a + // move below that floor, we've hit "the rest of the + // team" -- from then on, apply a budget (borrowing + // SEARCH_SORT_LIMIT's existing table as an untuned + // starting point for this new meaning) on how many more + // full selections are worth the cost before just taking + // the remainder in place. + if (TRUE == pi->fMovesRescoredByIID) { - // On an IID-rescored ply, mvf[].iValue holds a - // real, honest eval-axis score from an actual - // shallow search (see RescoreMovesViaSearch) -- - // trust it outright, same principle as - // ComputeMoveScore's IID-trust branch. Two - // alternatives were measured and rejected (see - // RESULTS.md): blending history into the real - // score (scaled or capped) invents a new, - // leak-prone move-scoring axis on top of an - // already-crowded set (generate.c's ordering - // encoding, RescoreMovesViaSearch's real scores, - // root.c's own scheme) and measures no better - // than trusting the score outright; a pure - // tiebreak-on-exact-ties compromise still cost - // solves relative to full mixing, so it wasn't - // buying its complexity either. The branch lives - // here (once per selection call), not inside - // SelectBestWithHistory (once per candidate - // move in a hot per-node loop), to keep the - // overwhelmingly common non-rescored path at - // zero added cost. - if (TRUE == pi->fMovesRescoredByIID) + SelectBestNoHistory(ctx, x); + } + else if ((FALSE == fInLeftovers) || + (uLeftoverPicks < SEARCH_SORT_LIMIT(ctx->uPly))) + { + SelectBestWithHistory(ctx, x); + if (FALSE == fInLeftovers) { - SelectBestNoHistory(ctx, x); + if (ctx->sMoveStack.mvf[x].iValue < GOOD_MOVE) + { + fInLeftovers = TRUE; + } } else { - SelectBestWithHistory(ctx, x); + uLeftoverPicks++; } } mv = ctx->sMoveStack.mvf[x].mv; |
