From 189b6fc270f91f4111c1a8049c97455093f8be97 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 13 Oct 2012 11:32:31 +0200 Subject: [PATCH] Retire can_return_tt() and rewirte TT-hit code Simplify the code and doing this introduce a couple of (very small) functional changes: - Always compare to depth even in "mate value" condition - TT cut-off in qsearch also in case of PvNode, as in search Verified against regression with 2500 games at 30"+0.05 on 2 threads: 451 - 444 - 1602 Functional changed: new bench is 5544977 --- src/search.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index ca23aa37..a3d87818 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -104,7 +104,6 @@ namespace { bool connected_moves(const Position& pos, Move m1, Move m2); Value value_to_tt(Value v, int ply); Value value_from_tt(Value v, int ply); - bool can_return_tt(const TTEntry* tte, Depth depth, Value ttValue, Value beta); bool connected_threat(const Position& pos, Move m, Move threat); Value refine_eval(const TTEntry* tte, Value ttValue, Value defaultEval); Move do_skill_level(); @@ -544,8 +543,11 @@ namespace { // 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 && (PvNode ? tte->depth() >= depth && tte->type() == BOUND_EXACT - : can_return_tt(tte, depth, ttValue, beta))) + if ( !RootNode + && tte && tte->depth() >= depth + && ( PvNode ? tte->type() == BOUND_EXACT + : ttValue >= beta ? (tte->type() & BOUND_LOWER) + : (tte->type() & BOUND_UPPER))) { TT.refresh(tte); ss->currentMove = ttMove; // Can be MOVE_NONE @@ -1095,7 +1097,10 @@ split_point_start: // At split points actual search starts from here // 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 (!PvNode && tte && can_return_tt(tte, ttDepth, ttValue, beta)) + if ( tte && tte->depth() >= ttDepth + && ( PvNode ? tte->type() == BOUND_EXACT + : ttValue >= beta ? (tte->type() & BOUND_LOWER) + : (tte->type() & BOUND_UPPER))) { ss->currentMove = ttMove; // Can be MOVE_NONE return ttValue; @@ -1419,20 +1424,6 @@ split_point_start: // At split points actual search starts from here } - // can_return_tt() returns true if a transposition table score can be used to - // cut-off at a given point in search. - - bool can_return_tt(const TTEntry* tte, Depth depth, Value v, Value beta) { - - return ( tte->depth() >= depth - || v >= std::max(VALUE_MATE_IN_MAX_PLY, beta) - || v < std::min(VALUE_MATED_IN_MAX_PLY, beta)) - - && ( ((tte->type() & BOUND_LOWER) && v >= beta) - || ((tte->type() & BOUND_UPPER) && v < beta)); - } - - // refine_eval() returns the transposition table score if possible, otherwise // falls back on static position evaluation. -- 2.39.2