X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=a9fc1c6d4c80b41aec8c20c4b6b2e7c070760050;hp=8089130e594c153a8f87955fde79f4a05dbff1ab;hb=d39ffbeea6ad54c90123a352d50b65c5bda1561b;hpb=af7412e58a4ce374b5035d9bb1e8c47a108ff352 diff --git a/src/search.cpp b/src/search.cpp index 8089130e..a9fc1c6d 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -153,11 +153,11 @@ namespace { {1, 0, 0, 0, 0, 1, 1 ,1}, }; + const size_t HalfDensitySize = std::extent::value; + Value bonus(Depth depth) { int d = depth / ONE_PLY ; return Value(d * d + 2 * d - 2); } Value penalty(Depth depth) { int d = depth / ONE_PLY ; return -Value(d * d + 4 * d + 1); } - const size_t HalfDensitySize = std::extent::value; - EasyMoveManager EasyMove; Value DrawValue[COLOR_NB]; @@ -312,9 +312,13 @@ void MainThread::search() { && rootMoves[0].pv[0] != MOVE_NONE) { for (Thread* th : Threads) - if ( th->completedDepth > bestThread->completedDepth - && th->rootMoves[0].score > bestThread->rootMoves[0].score) + { + Depth depthDiff = th->completedDepth - bestThread->completedDepth; + Value scoreDiff = th->rootMoves[0].score - bestThread->rootMoves[0].score; + + if (scoreDiff > 0 && depthDiff >= 0) bestThread = th; + } } previousScore = bestThread->rootMoves[0].score; @@ -597,7 +601,7 @@ namespace { if (!rootNode) { // Step 2. Check for aborted search and immediate draw - if (Signals.stop.load(std::memory_order_relaxed) || pos.is_draw() || ss->ply >= MAX_PLY) + if (Signals.stop.load(std::memory_order_relaxed) || pos.is_draw(ss->ply) || ss->ply >= MAX_PLY) return ss->ply >= MAX_PLY && !inCheck ? evaluate(pos) : DrawValue[pos.side_to_move()]; @@ -1074,13 +1078,6 @@ moves_loop: // When in check search starts from here if (value > alpha) { - // If there is an easy move for this position, clear it if unstable - if ( PvNode - && thisThread == Threads.main() - && EasyMove.get(pos.key()) - && (move != EasyMove.get(pos.key()) || moveCount > 1)) - EasyMove.clear(); - bestMove = move; if (PvNode && !rootNode) // Update pv even in fail-high case @@ -1180,7 +1177,7 @@ moves_loop: // When in check search starts from here ss->ply = (ss-1)->ply + 1; // Check for an instant draw or if the maximum ply has been reached - if (pos.is_draw() || ss->ply >= MAX_PLY) + if (pos.is_draw(ss->ply) || ss->ply >= MAX_PLY) return ss->ply >= MAX_PLY && !InCheck ? evaluate(pos) : DrawValue[pos.side_to_move()];