From 69ad4667fb40cc0d7195f9fa20652903813d698c Mon Sep 17 00:00:00 2001 From: Shawn Xu Date: Sun, 30 Jun 2024 22:04:51 -0700 Subject: [PATCH] Do Capture History Updates In Probcut This patch introduces history updates to probcut. Standard depth - 3 bonus and maluses are given to the capture that caused fail high and previously searched captures, respectively. Similar to #5243, a negative history fill is applied to compensate for an increase in capture history average, thus improving the scaling of this patch. Passed STC: LLR: 2.95 (-2.94,2.94) <0.00,2.00> Total: 84832 W: 21941 L: 21556 D: 41335 Ptnml(0-2): 226, 9927, 21688, 10386, 189 https://tests.stockfishchess.org/tests/view/6682fab9389b9ee542b1d029 Passed LTC: LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 104298 W: 26469 L: 26011 D: 51818 Ptnml(0-2): 43, 11458, 28677, 11940, 31 https://tests.stockfishchess.org/tests/view/6682ff06389b9ee542b1d0a0 closes https://github.com/official-stockfish/Stockfish/pull/5428 bench 1281351 --- src/search.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/search.cpp b/src/search.cpp index 31278241..188e81f4 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -502,7 +502,7 @@ void Search::Worker::iterative_deepening() { void Search::Worker::clear() { counterMoves.fill(Move::none()); mainHistory.fill(0); - captureHistory.fill(0); + captureHistory.fill(-700); pawnHistory.fill(-1193); correctionHistory.fill(0); @@ -862,12 +862,19 @@ Value Search::Worker::search( assert(probCutBeta < VALUE_INFINITE && probCutBeta > beta); MovePicker mp(pos, ttData.move, probCutBeta - ss->staticEval, &thisThread->captureHistory); + Move probcutCapturesSearched[32]; + int probcutCaptureCount = 0; + Piece captured; while ((move = mp.next_move()) != Move::none()) if (move != excludedMove && pos.legal(move)) { assert(pos.capture_stage(move)); + movedPiece = pos.moved_piece(move); + captured = pos.piece_on(move.to_sq()); + + // Prefetch the TT entry for the resulting position prefetch(tt.first_entry(pos.key_after(move))); @@ -891,12 +898,28 @@ Value Search::Worker::search( if (value >= probCutBeta) { + thisThread->captureHistory[movedPiece][move.to_sq()][type_of(captured)] + << stat_bonus(depth - 2); + + for (int i = 0; i < probcutCaptureCount; i++) + { + movedPiece = pos.moved_piece(probcutCapturesSearched[i]); + captured = pos.piece_on(probcutCapturesSearched[i].to_sq()); + + thisThread->captureHistory[movedPiece][probcutCapturesSearched[i].to_sq()] + [type_of(captured)] + << -stat_malus(depth - 3); + } + // Save ProbCut data into transposition table ttWriter.write(posKey, value_to_tt(value, ss->ply), ss->ttPv, BOUND_LOWER, depth - 3, move, unadjustedStaticEval, tt.generation()); return std::abs(value) < VALUE_TB_WIN_IN_MAX_PLY ? value - (probCutBeta - beta) : value; } + + if (probcutCaptureCount < 32) + probcutCapturesSearched[probcutCaptureCount++] = move; } Eval::NNUE::hint_common_parent_position(pos, networks[numaAccessToken], refreshTable);