diff --git a/src/search.cpp b/src/search.cpp index f0fa6f05132..28cbffd6d4c 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -472,7 +472,10 @@ void Thread::search() { ++failedHighCnt; } else + { + ++rootMoves[pvIdx].bestMoveCount; break; + } delta += delta / 4 + 5; @@ -1072,7 +1075,8 @@ namespace { // Step 16. Reduced depth search (LMR). If the move fails high it will be // re-searched at full depth. if ( depth >= 3 * ONE_PLY - && moveCount > 1 + 3 * rootNode + && moveCount > 1 + 2 * rootNode + && (!rootNode || thisThread->best_move_count(move) == 0) && ( !captureOrPromotion || moveCountPruning || ss->staticEval + PieceValue[EG][pos.captured_piece()] <= alpha diff --git a/src/search.h b/src/search.h index 24c58d3085e..c77ca3ad899 100644 --- a/src/search.h +++ b/src/search.h @@ -70,6 +70,7 @@ struct RootMove { Value previousScore = -VALUE_INFINITE; int selDepth = 0; int tbRank = 0; + int bestMoveCount = 0; Value tbScore; std::vector pv; }; diff --git a/src/thread.cpp b/src/thread.cpp index e5043b6ea35..5165fd90ae9 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -52,6 +52,15 @@ Thread::~Thread() { stdThread.join(); } +/// Thread::bestMoveCount(Move move) return best move counter for the given root move + +int Thread::best_move_count(Move move) { + + auto rm = std::find(rootMoves.begin() + pvIdx, + rootMoves.begin() + pvLast, move); + + return rm != rootMoves.begin() + pvLast ? rm->bestMoveCount : 0; +} /// Thread::clear() reset histories, usually before a new game diff --git a/src/thread.h b/src/thread.h index c11d17873df..ed427b10c1e 100644 --- a/src/thread.h +++ b/src/thread.h @@ -56,6 +56,7 @@ class Thread { void idle_loop(); void start_searching(); void wait_for_search_finished(); + int best_move_count(Move move); Pawns::Table pawnsTable; Material::Table materialTable;