X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=e6ffcb19f42cf73abcbb082f7a4789442ba36a06;hp=fd5687ea9714ab625bbc8a6cf106003ab293bb34;hb=909e3adede210a124ed9ec4a2f21d73fda61c26d;hpb=a9e9746495821fe7251d5f86ea3a97cb91eac729 diff --git a/src/search.cpp b/src/search.cpp index fd5687ea..e6ffcb19 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -294,7 +294,7 @@ namespace { Depth extension(const Position&, Move, bool, bool, bool, bool, bool, bool*); bool ok_to_do_nullmove(const Position& pos); bool ok_to_prune(const Position& pos, Move m, Move threat); - bool ok_to_use_TT(const TTEntry* tte, Depth depth, Value beta, int ply); + bool ok_to_use_TT(const TTEntry* tte, Depth depth, Value beta, int ply, bool allowNullmove); Value refine_eval(const TTEntry* tte, Value defaultEval, int ply); void update_history(const Position& pos, Move move, Depth depth, Move movesSearched[], int moveCount); void update_killers(Move m, SearchStack& ss); @@ -1299,7 +1299,7 @@ namespace { tte = TT.retrieve(posKey); ttMove = (tte ? tte->move() : MOVE_NONE); - if (tte && ok_to_use_TT(tte, depth, beta, ply)) + if (tte && ok_to_use_TT(tte, depth, beta, ply, allowNullmove)) { ss[ply].currentMove = ttMove; // Can be MOVE_NONE return value_from_tt(tte->value(), ply); @@ -1388,7 +1388,9 @@ namespace { { assert(value_to_tt(nullValue, ply) == nullValue); - TT.store(posKey, nullValue, VALUE_TYPE_LOWER, depth, MOVE_NONE); + // Special flag null values that are not zugzwang checked + ValueType vt = (depth < 6 * OnePly ? VALUE_TYPE_NS_LO : VALUE_TYPE_LOWER); + TT.store(posKey, nullValue, vt, depth, MOVE_NONE); return nullValue; } } else { @@ -1625,7 +1627,7 @@ namespace { tte = TT.retrieve(pos.get_key()); ttMove = (tte ? tte->move() : MOVE_NONE); - if (!pvNode && tte && ok_to_use_TT(tte, depth, beta, ply)) + if (!pvNode && tte && ok_to_use_TT(tte, depth, beta, ply, true)) { assert(tte->type() != VALUE_TYPE_EVAL); @@ -2306,14 +2308,18 @@ namespace { } - // ok_to_use_TT() returns true if a transposition table score - // can be used at a given point in search. + // ok_to_use_TT() returns true if a transposition table score can be used at a + // given point in search. To avoid zugzwang issues TT cutoffs at the root node + // of a null move verification search are not allowed if the TT value was found + // by a null search, this is implemented testing allowNullmove and TT entry type. - bool ok_to_use_TT(const TTEntry* tte, Depth depth, Value beta, int ply) { + bool ok_to_use_TT(const TTEntry* tte, Depth depth, Value beta, int ply, bool allowNullmove) { Value v = value_from_tt(tte->value(), ply); - return ( tte->depth() >= depth + return (allowNullmove || !(tte->type() & VALUE_TYPE_NULL)) + + && ( tte->depth() >= depth || v >= Max(value_mate_in(PLY_MAX), beta) || v < Min(value_mated_in(PLY_MAX), beta))