X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=cd4bf3e4d26faad6a5f3a3c7f5e535d4bab13e14;hp=292c35b0c38fb6934eb2002895002fc29a4928d3;hb=c0136fb7286416be2ec179b4787f53d77023eeaf;hpb=9b1708391233fe117b435975197592c067d93cc1 diff --git a/src/search.cpp b/src/search.cpp index 292c35b0..cd4bf3e4 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1056,9 +1056,6 @@ namespace { refinedValue = bestValue = value = -VALUE_INFINITE; oldAlpha = alpha; - if (depth < OnePly) - return qsearch(pos, ss, alpha, beta, Depth(0), threadID); - // Step 1. Initialize node and poll. Polling can abort search TM.incrementNodeCounter(threadID); ss->init(ply); @@ -1067,7 +1064,7 @@ namespace { if (threadID == 0 && ++NodesSincePoll > NodesBetweenPolls) { NodesSincePoll = 0; - poll(); + poll(); } // Step 2. Check for aborted search and immediate draw @@ -1179,8 +1176,8 @@ namespace { pos.do_null_move(st); - nullValue = -search(pos, ss+1, -beta, -alpha, depth-R*OnePly, false, threadID); - + nullValue = depth-R*OnePly < OnePly ? -qsearch(pos, ss+1, -beta, -alpha, Depth(0), threadID) + : - search(pos, ss+1, -beta, -alpha, depth-R*OnePly, false, threadID); pos.undo_null_move(); if (nullValue >= beta) @@ -1314,7 +1311,8 @@ namespace { // Step extra. pv search (only in PV nodes) // The first move in list is the expected PV if (PvNode && moveCount == 1) - value = -search(pos, ss+1, -beta, -alpha, newDepth, false, threadID); + value = newDepth < OnePly ? -qsearch(pos, ss+1, -beta, -alpha, Depth(0), threadID) + : - search(pos, ss+1, -beta, -alpha, newDepth, false, threadID); else { // Step 14. Reduced depth search @@ -1330,7 +1328,10 @@ namespace { ss->reduction = reduction(depth, moveCount); if (ss->reduction) { - value = -search(pos, ss+1, -(alpha+1), -alpha, newDepth-ss->reduction, true, threadID); + Depth r = newDepth - ss->reduction; + value = r < OnePly ? -qsearch(pos, ss+1, -(alpha+1), -alpha, Depth(0), threadID) + : - search(pos, ss+1, -(alpha+1), -alpha, r, true, threadID); + doFullDepthSearch = (value > alpha); } @@ -1339,6 +1340,8 @@ namespace { // if the move fails high again then go with full depth search. if (doFullDepthSearch && ss->reduction > 2 * OnePly) { + assert(newDepth - OnePly >= OnePly); + ss->reduction = OnePly; value = -search(pos, ss+1, -(alpha+1), -alpha, newDepth-ss->reduction, true, threadID); doFullDepthSearch = (value > alpha); @@ -1349,13 +1352,15 @@ namespace { if (doFullDepthSearch) { ss->reduction = Depth(0); - value = -search(pos, ss+1, -(alpha+1), -alpha, newDepth, true, threadID); + value = newDepth < OnePly ? -qsearch(pos, ss+1, -(alpha+1), -alpha, Depth(0), threadID) + : - search(pos, ss+1, -(alpha+1), -alpha, newDepth, true, threadID); // Step extra. pv search (only in PV nodes) // Search only for possible new PV nodes, if instead value >= beta then // parent node fails low with value <= alpha and tries another move. if (PvNode && value > alpha && value < beta) - value = -search(pos, ss+1, -beta, -alpha, newDepth, false, threadID); + value = newDepth < OnePly ? -qsearch(pos, ss+1, -beta, -alpha, Depth(0), threadID) + : - search(pos, ss+1, -beta, -alpha, newDepth, false, threadID); } }