X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=5e04dbb7b696cc874f63641c2643f9ca34f9653d;hp=30179e8f27fafa2c931c3ef0840d95875a21b568;hb=c6ba14b7c939fd212d002d5f4385219c5ffec53f;hpb=52129955637610488936648066f80a4515f6ce57 diff --git a/src/search.cpp b/src/search.cpp index 30179e8f..5e04dbb7 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1673,9 +1673,9 @@ namespace { // Step 12. Futility pruning (is omitted in PV nodes) if ( !PvNode - && !isCheck - && !dangerous && !captureOrPromotion + && !isCheck + && !dangerous && !move_is_castle(move)) { // Move count based pruning @@ -1709,16 +1709,18 @@ namespace { // If the move fails high will be re-searched at full depth. bool doFullDepthSearch = true; - if ( !dangerous - && !captureOrPromotion + if ( !captureOrPromotion + && !dangerous && !move_is_castle(move) && !move_is_killer(move, ss)) { ss->reduction = reduction(sp->depth, moveCount); if (ss->reduction) { - Value localAlpha = sp->alpha; - value = -search(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth-ss->reduction, true, threadID); + Value localAlpha = sp->alpha; + Depth d = newDepth - ss->reduction; + value = d < OnePly ? -qsearch(pos, ss+1, -(localAlpha+1), -localAlpha, Depth(0), threadID) + : - search(pos, ss+1, -(localAlpha+1), -localAlpha, d, true, threadID); doFullDepthSearch = (value > localAlpha); } @@ -1727,6 +1729,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 localAlpha = sp->alpha; value = -search(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth-ss->reduction, true, threadID); @@ -1739,10 +1743,15 @@ namespace { { ss->reduction = Depth(0); Value localAlpha = sp->alpha; - value = -search(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth, true, threadID); + value = newDepth < OnePly ? -qsearch(pos, ss+1, -(localAlpha+1), -localAlpha, Depth(0), threadID) + : - search(pos, ss+1, -(localAlpha+1), -localAlpha, 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 > localAlpha && value < sp->beta) - value = -search(pos, ss+1, -sp->beta, -sp->alpha, newDepth, false, threadID); + value = newDepth < OnePly ? -qsearch(pos, ss+1, -sp->beta, -sp->alpha, Depth(0), threadID) + : - search(pos, ss+1, -sp->beta, -sp->alpha, newDepth, false, threadID); } // Step 16. Undo move