X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=654efb3265f453caf9e8cfe398e04c625abc0b08;hp=07405d42beed4a52f586d0ccae66c4b327797226;hb=52bbf372bb4956595e730f4dba05ee6b78305ad0;hpb=feeafb0a50556654e345a09d16529a5eb7715dc0 diff --git a/src/search.cpp b/src/search.cpp index 07405d42..654efb32 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -482,7 +482,7 @@ namespace { Key posKey; Move ttMove, move, excludedMove, bestMove, threatMove; Depth ext, newDepth; - Value bestValue, value, ttValue, ttValueUpper; + Value bestValue, value, ttValue; Value eval, nullValue, futilityValue; bool inCheck, givesCheck, pvMove, singularExtensionNode; bool captureOrPromotion, dangerous, doFullDepthSearch; @@ -544,43 +544,31 @@ namespace { tte = TT.probe(posKey); ttMove = RootNode ? RootMoves[PVIdx].pv[0] : tte ? tte->move() : MOVE_NONE; ttValue = tte ? value_from_tt(tte->value(), ss->ply) : VALUE_NONE; - ttValueUpper = tte ? value_from_tt(tte->value_upper(), ss->ply) : VALUE_NONE; // At PV nodes we check for exact scores, while at non-PV nodes we check for // a fail high/low. Biggest advantage at probing at PV nodes is to have a // smooth experience in analysis mode. We don't probe at Root nodes otherwise // we should also update RootMoveList to avoid bogus output. - if (!RootNode && tte) + if ( !RootNode + && tte + && tte->depth() >= depth + && ttValue != VALUE_NONE // Only in case of TT access race + && ( PvNode ? tte->type() == BOUND_EXACT + : ttValue >= beta ? (tte->type() & BOUND_LOWER) + : (tte->type() & BOUND_UPPER))) { - // Fail High - if ( (tte->type() & BOUND_LOWER) - && ttValue >= beta - && tte->depth() >= depth - && ttValue != VALUE_NONE) // Only in case of TT access race - { - // Update killers, we assume ttMove caused a cut-off - if ( ttMove - && !pos.is_capture_or_promotion(ttMove) - && ttMove != ss->killers[0]) - { - ss->killers[1] = ss->killers[0]; - ss->killers[0] = ttMove; - } - TT.refresh(tte); - ss->currentMove = ttMove; // Can be MOVE_NONE - return ttValue; - } + TT.refresh(tte); + ss->currentMove = ttMove; // Can be MOVE_NONE - // Fail Low - if ( (tte->type() & BOUND_UPPER) - && ttValueUpper < beta - && tte->depth_upper() >= depth - && ttValueUpper != VALUE_NONE) // Only in case of TT access race + if ( ttValue >= beta + && ttMove + && !pos.is_capture_or_promotion(ttMove) + && ttMove != ss->killers[0]) { - TT.refresh(tte); - ss->currentMove = ttMove; // Can be MOVE_NONE - return ttValueUpper; + ss->killers[1] = ss->killers[0]; + ss->killers[0] = ttMove; } + return ttValue; } // Step 5. Evaluate the position statically and update parent's gain statistics @@ -1015,9 +1003,10 @@ split_point_start: // At split points actual search starts from here // Step 19. Check for splitting the search if ( !SpNode && depth >= Threads.min_split_depth() - && bestValue < beta && Threads.available_slave_exists(thisThread)) { + assert(bestValue < beta); + bestValue = Threads.split(pos, ss, alpha, beta, bestValue, &bestMove, depth, threatMove, moveCount, mp, NT); if (bestValue >= beta) @@ -1101,7 +1090,7 @@ split_point_start: // At split points actual search starts from here const TTEntry* tte; Key posKey; Move ttMove, move, bestMove; - Value bestValue, value, ttValue, ttValueUpper, futilityValue, futilityBase, oldAlpha; + Value bestValue, value, ttValue, futilityValue, futilityBase, oldAlpha; bool givesCheck, enoughMaterial, evasionPrunable, fromNull; Depth ttDepth; @@ -1123,34 +1112,21 @@ split_point_start: // At split points actual search starts from here tte = TT.probe(posKey); ttMove = tte ? tte->move() : MOVE_NONE; ttValue = tte ? value_from_tt(tte->value(),ss->ply) : VALUE_NONE; - ttValueUpper = tte ? value_from_tt(tte->value_upper(),ss->ply) : VALUE_NONE; // Decide whether or not to include checks, this fixes also the type of // TT entry depth that we are going to use. Note that in qsearch we use // only two types of depth in TT: DEPTH_QS_CHECKS or DEPTH_QS_NO_CHECKS. ttDepth = InCheck || depth >= DEPTH_QS_CHECKS ? DEPTH_QS_CHECKS : DEPTH_QS_NO_CHECKS; - if (tte) + if ( tte + && tte->depth() >= ttDepth + && ttValue != VALUE_NONE // Only in case of TT access race + && ( PvNode ? tte->type() == BOUND_EXACT + : ttValue >= beta ? (tte->type() & BOUND_LOWER) + : (tte->type() & BOUND_UPPER))) { - // Fail High - if ( (tte->type() & BOUND_LOWER) - && ttValue >= beta - && tte->depth() >= ttDepth - && ttValue != VALUE_NONE) // Only in case of TT access race - { - ss->currentMove = ttMove; // Can be MOVE_NONE - return ttValue; - } - - // Fail Low - if ( (tte->type() & BOUND_UPPER) - && ttValueUpper < beta - && tte->depth_upper() >= ttDepth - && ttValueUpper != VALUE_NONE) // Only in case of TT access race - { - ss->currentMove = ttMove; // Can be MOVE_NONE - return ttValueUpper; - } + ss->currentMove = ttMove; // Can be MOVE_NONE + return ttValue; } // Evaluate the position statically