X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=06262131f40bfe895e891540c6985f2405504285;hp=3a54bf01b0d4e9ac41632c8f03c40a1f2ce723b7;hb=bf485f4affc37cd408a65b66b8a3aad059bad5f3;hpb=002bf4d8dbf804ce8303e01733341a0922af2e71 diff --git a/src/search.cpp b/src/search.cpp index 3a54bf01..06262131 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -308,7 +308,9 @@ void MainThread::search() { Depth depthDiff = th->completedDepth - bestThread->completedDepth; Value scoreDiff = th->rootMoves[0].score - bestThread->rootMoves[0].score; - if (scoreDiff > 0 && depthDiff >= 0) + // Select the thread with the best score, always if it is a mate + if ( scoreDiff > 0 + && (depthDiff >= 0 || th->rootMoves[0].score >= VALUE_MATE_IN_MAX_PLY)) bestThread = th; } } @@ -455,16 +457,20 @@ void Thread::search() { // Sort the PV lines searched so far and update the GUI std::stable_sort(rootMoves.begin(), rootMoves.begin() + PVIdx + 1); - if (!mainThread) - continue; - - if (Threads.stop || PVIdx + 1 == multiPV || Time.elapsed() > 3000) + if ( mainThread + && (Threads.stop || PVIdx + 1 == multiPV || Time.elapsed() > 3000)) sync_cout << UCI::pv(rootPos, rootDepth, alpha, beta) << sync_endl; } if (!Threads.stop) completedDepth = rootDepth; + // Have we found a "mate in x"? + if ( Limits.mate + && bestValue >= VALUE_MATE_IN_MAX_PLY + && VALUE_MATE - bestValue <= 2 * Limits.mate) + Threads.stop = true; + if (!mainThread) continue; @@ -472,12 +478,6 @@ void Thread::search() { if (skill.enabled() && skill.time_to_pick(rootDepth)) skill.pick_best(multiPV); - // Have we found a "mate in x"? - if ( Limits.mate - && bestValue >= VALUE_MATE_IN_MAX_PLY - && VALUE_MATE - bestValue <= 2 * Limits.mate) - Threads.stop = true; - // Do we have time for the next iteration? Can we stop searching now? if (Limits.use_time_management()) { @@ -908,7 +908,8 @@ moves_loop: // When in check search starts from here } // Reduced depth of the next LMR search - int lmrDepth = std::max(newDepth - reduction(improving, depth, moveCount), DEPTH_ZERO) / ONE_PLY; + int mch = std::max(1, moveCount - (ss-1)->moveCount / 16); + int lmrDepth = std::max(newDepth - reduction(improving, depth, mch), DEPTH_ZERO) / ONE_PLY; // Countermoves based pruning if ( lmrDepth < 3 @@ -959,7 +960,8 @@ moves_loop: // When in check search starts from here && moveCount > 1 && (!captureOrPromotion || moveCountPruning)) { - Depth r = reduction(improving, depth, moveCount); + int mch = std::max(1, moveCount - (ss-1)->moveCount / 16); + Depth r = reduction(improving, depth, mch); if (captureOrPromotion) r -= r ? ONE_PLY : DEPTH_ZERO;