X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=866444a8388e29236d50ec4a609a59f11f45df74;hp=517499b543971798d432ab0856049ce11a8343a2;hb=368f976fb6fc9096d7f19b0443fb4d1af40eec14;hpb=e89bc30fdc93f739869d0d4b285a2cfc3e7a74ee diff --git a/src/search.cpp b/src/search.cpp index 517499b5..866444a8 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -18,6 +18,7 @@ along with this program. If not, see . */ +#include #include #include #include // For std::memset @@ -593,7 +594,10 @@ namespace { // starts with statScore = 0. Later grandchildren start with the last calculated // statScore of the previous grandchild. This influences the reduction rules in // LMR which are based on the statScore of parent position. - (ss+2)->statScore = 0; + if (rootNode) + (ss + 4)->statScore = 0; + else + (ss + 2)->statScore = 0; // Step 4. Transposition table lookup. We don't want the score of a partial // search to overwrite a previous full search TT value, so we use a different @@ -606,15 +610,6 @@ namespace { : ttHit ? tte->move() : MOVE_NONE; ttPv = (ttHit && tte->is_pv()) || (PvNode && depth > 4 * ONE_PLY); - // If position has been searched at higher depths and we are shuffling, - // return value_draw. - if ( pos.rule50_count() > 36 - 6 * (pos.count() > 14) - && ss->ply > 36 - 6 * (pos.count() > 14) - && ttHit - && tte->depth() > depth - && pos.count() > 0) - return VALUE_DRAW; - // At non-PV nodes we check for an early TT cutoff if ( !PvNode && ttHit @@ -903,7 +898,7 @@ moves_loop: // When in check, search starts from here && move == ttMove && !rootNode && !excludedMove // Avoid recursive singular search - /* && ttValue != VALUE_NONE Already implicit in the next condition */ + /* && ttValue != VALUE_NONE Already implicit in the next condition */ && abs(ttValue) < VALUE_KNOWN_WIN && (tte->bound() & BOUND_LOWER) && tte->depth() >= depth - 3 * ONE_PLY @@ -939,9 +934,8 @@ moves_loop: // When in check, search starts from here // Shuffle extension else if ( PvNode && pos.rule50_count() > 18 - && ss->ply > 18 && depth < 3 * ONE_PLY - && ss->ply < 3 * thisThread->rootDepth / ONE_PLY) // To avoid infinite loops + && ss->ply < 3 * thisThread->rootDepth / ONE_PLY) // To avoid too deep searches extension = ONE_PLY; // Passed pawn extension @@ -1013,8 +1007,10 @@ moves_loop: // When in check, search starts from here // Step 16. Reduced depth search (LMR). If the move fails high it will be // re-searched at full depth. if ( depth >= 3 * ONE_PLY - && moveCount > 1 - && (!captureOrPromotion || moveCountPruning)) + && moveCount > 1 + 3 * rootNode + && ( !captureOrPromotion + || moveCountPruning + || ss->staticEval + PieceValue[EG][pos.captured_piece()] <= alpha)) { Depth r = reduction(improving, depth, moveCount); @@ -1211,8 +1207,8 @@ moves_loop: // When in check, search starts from here } - // qsearch() is the quiescence search function, which is called by the main - // search function with depth zero, or recursively with depth less than ONE_PLY. + // qsearch() is the quiescence search function, which is called by the main search + // function with zero depth, or recursively with further decreasing depth per call. template Value qsearch(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth) {