From 4784ff2b3be97a0364b77a677e21a644403f7b3a Mon Sep 17 00:00:00 2001 From: Guenther Demetz Date: Mon, 3 Nov 2025 08:55:26 +0100 Subject: [PATCH] Unify do_move & do_null_move workload While being there also remove and unused assignment. Tested for non-regression at STC: https://tests.stockfishchess.org/tests/view/69060d81ea4b268f1fac1f36 LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 94496 W: 24570 L: 24421 D: 45505 Ptnml(0-2): 264, 10145, 26275, 10306, 258 closes https://github.com/official-stockfish/Stockfish/pull/6383 no functional change --- src/search.cpp | 17 ++++++++--------- src/search.h | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 43d96bf24..d28ac5f27 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -544,7 +544,12 @@ void Search::Worker::do_move( } } -void Search::Worker::do_null_move(Position& pos, StateInfo& st) { pos.do_null_move(st, tt); } +void Search::Worker::do_null_move(Position& pos, StateInfo& st, Stack* const ss) { + pos.do_null_move(st, tt); + ss->currentMove = Move::null(); + ss->continuationHistory = &continuationHistory[0][0][NO_PIECE][0]; + ss->continuationCorrectionHistory = &continuationCorrectionHistory[NO_PIECE][0]; +} void Search::Worker::undo_move(Position& pos, const Move move) { pos.undo_move(move); @@ -868,12 +873,7 @@ Value Search::Worker::search( // Null move dynamic reduction based on depth Depth R = 6 + depth / 3 + improving; - - ss->currentMove = Move::null(); - ss->continuationHistory = &continuationHistory[0][0][NO_PIECE][0]; - ss->continuationCorrectionHistory = &continuationCorrectionHistory[NO_PIECE][0]; - - do_null_move(pos, st); + do_null_move(pos, st, ss); Value nullValue = -search(pos, ss + 1, -beta, -beta + 1, depth - R, false); @@ -1580,8 +1580,7 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta) futilityBase = ss->staticEval + 352; } - const PieceToHistory* contHist[] = {(ss - 1)->continuationHistory, - (ss - 2)->continuationHistory}; + const PieceToHistory* contHist[] = {(ss - 1)->continuationHistory}; Square prevSq = ((ss - 1)->currentMove).is_ok() ? ((ss - 1)->currentMove).to_sq() : SQ_NONE; diff --git a/src/search.h b/src/search.h index 4c4357d3e..f3d99d415 100644 --- a/src/search.h +++ b/src/search.h @@ -299,7 +299,7 @@ class Worker { void do_move(Position& pos, const Move move, StateInfo& st, Stack* const ss); void do_move(Position& pos, const Move move, StateInfo& st, const bool givesCheck, Stack* const ss); - void do_null_move(Position& pos, StateInfo& st); + void do_null_move(Position& pos, StateInfo& st, Stack* const ss); void undo_move(Position& pos, const Move move); void undo_null_move(Position& pos);