From: Giacomo Lorenzetti Date: Tue, 1 Mar 2022 08:34:40 +0000 (+0100) Subject: Sort captures X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=4ac7d726ec5ba38ba593bca2ab5cb7589785a957 Sort captures This patch (partially) sort captures in analogy to quiet moves. All three movepickers are affected, hence `depth` is added as an argument in probcut's. Passed STC: https://tests.stockfishchess.org/tests/view/621a4576da649bba32ef6fd4 LLR: 2.95 (-2.94,2.94) <0.00,2.50> Total: 103848 W: 27884 L: 27473 D: 48491 Ptnml(0-2): 587, 11691, 26974, 12068, 604 Passed LTC: https://tests.stockfishchess.org/tests/view/621aaa5bda649bba32ef7c2d LLR: 2.96 (-2.94,2.94) <0.50,3.00> Total: 212032 W: 56420 L: 55739 D: 99873 Ptnml(0-2): 198, 21310, 62348, 21933, 227 closes https://github.com/official-stockfish/Stockfish/pull/3952 Bench: 6833580 --- diff --git a/src/movepick.cpp b/src/movepick.cpp index 694b9222..dc35113f 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -87,8 +87,8 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHist /// MovePicker constructor for ProbCut: we generate captures with SEE greater /// than or equal to the given threshold. -MovePicker::MovePicker(const Position& p, Move ttm, Value th, const CapturePieceToHistory* cph) - : pos(p), captureHistory(cph), ttMove(ttm), threshold(th) +MovePicker::MovePicker(const Position& p, Move ttm, Value th, Depth d, const CapturePieceToHistory* cph) + : pos(p), captureHistory(cph), ttMove(ttm), threshold(th), depth(d) { assert(!pos.checkers()); @@ -169,11 +169,12 @@ top: endMoves = generate(pos, cur); score(); + partial_insertion_sort(cur, endMoves, -3000 * depth); ++stage; goto top; case GOOD_CAPTURE: - if (select([&](){ + if (select([&](){ return pos.see_ge(*cur, Value(-69 * cur->value / 1024)) ? // Move losing capture to endBadCaptures to be tried later true : (*endBadCaptures++ = *cur, false); })) @@ -241,10 +242,10 @@ top: return select([](){ return true; }); case PROBCUT: - return select([&](){ return pos.see_ge(*cur, threshold); }); + return select([&](){ return pos.see_ge(*cur, threshold); }); case QCAPTURE: - if (select([&](){ return depth > DEPTH_QS_RECAPTURES + if (select([&](){ return depth > DEPTH_QS_RECAPTURES || to_sq(*cur) == recaptureSquare; })) return *(cur - 1); diff --git a/src/movepick.h b/src/movepick.h index e2cbfcde..9a3c279b 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -126,7 +126,7 @@ public: const CapturePieceToHistory*, const PieceToHistory**, Square); - MovePicker(const Position&, Move, Value, const CapturePieceToHistory*); + MovePicker(const Position&, Move, Value, Depth, const CapturePieceToHistory*); Move next_move(bool skipQuiets = false); private: diff --git a/src/search.cpp b/src/search.cpp index 6785ba4c..a6552daf 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -863,7 +863,7 @@ namespace { { assert(probCutBeta < VALUE_INFINITE); - MovePicker mp(pos, ttMove, probCutBeta - ss->staticEval, &captureHistory); + MovePicker mp(pos, ttMove, probCutBeta - ss->staticEval, depth - 3, &captureHistory); bool ttPv = ss->ttPv; ss->ttPv = false;