X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=a46c44627d4b1677b1f4a0a11f13825d24e0e746;hp=24c21c4e71057bbd92cb068a3b9b484207af1097;hb=6b16ebc82566a69b9336cca6aa7a19ab1824b85d;hpb=ee22b61f5e90a180af942828feb83cef90ea5683 diff --git a/src/search.cpp b/src/search.cpp index 24c21c4e..a46c4462 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -312,9 +312,14 @@ 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 ( (depthDiff > 0 && scoreDiff >= 0) + || (scoreDiff > 0 && depthDiff >= 0)) bestThread = th; + } } previousScore = bestThread->rootMoves[0].score; @@ -597,7 +602,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()]; @@ -654,10 +659,10 @@ namespace { // Step 4a. Tablebase probe if (!rootNode && TB::Cardinality) { - int piecesCnt = pos.count(WHITE) + pos.count(BLACK); + int piecesCount = pos.count(WHITE) + pos.count(BLACK); - if ( piecesCnt <= TB::Cardinality - && (piecesCnt < TB::Cardinality || depth >= TB::ProbeDepth) + if ( piecesCount <= TB::Cardinality + && (piecesCount < TB::Cardinality || depth >= TB::ProbeDepth) && pos.rule50_count() == 0 && !pos.can_castle(ANY_CASTLING)) { @@ -721,7 +726,7 @@ namespace { && eval + razor_margin[depth / ONE_PLY] <= alpha) { if (depth <= ONE_PLY) - return qsearch(pos, ss, alpha, beta); + return qsearch(pos, ss, alpha, alpha+1); Value ralpha = alpha - razor_margin[depth / ONE_PLY]; Value v = qsearch(pos, ss, ralpha, ralpha+1); @@ -1074,13 +1079,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 +1178,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()];