From c6ba14b7c939fd212d002d5f4385219c5ffec53f Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Wed, 2 Jun 2010 10:49:34 +0100 Subject: [PATCH] Sync sp_search() with main search() And fix qserahc() dispatch also there. No functional change tested wit Faked Split. Signed-off-by: Marco Costalba --- src/search.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) 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