X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=d419cd30ede15e192142b040de9caf14d8b8005c;hp=2149df2ba8fe340326ac45be06440f981e7d8826;hb=ee0371f86e319aa24bc1d32f02d9495eea79aa72;hpb=6c040c821a50475840607ef5f11c270ee21d61da diff --git a/src/search.cpp b/src/search.cpp index 2149df2b..d419cd30 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -181,6 +181,18 @@ void Search::init() { } +/// Search::reset() clears all search memory, to obtain reproducible search results + +void Search::reset () { + + TT.clear(); + History.clear(); + CounterMovesHistory.clear(); + Gains.clear(); + Countermoves.clear(); +} + + /// Search::perft() is our utility to verify move generation. All the leaf nodes /// up to the given depth are generated and counted and the sum returned. template @@ -339,10 +351,6 @@ namespace { beta = VALUE_INFINITE; TT.new_search(); - History.clear(); - CounterMovesHistory.clear(); - Gains.clear(); - Countermoves.clear(); size_t multiPV = Options["MultiPV"]; Skill skill(Options["Skill Level"]); @@ -850,7 +858,7 @@ moves_loop: // When in check and at SpNode search starts from here captureOrPromotion = pos.capture_or_promotion(move); givesCheck = type_of(move) == NORMAL && !ci.dcCandidates - ? ci.checkSq[type_of(pos.piece_on(from_sq(move)))] & to_sq(move) + ? ci.checkSquares[type_of(pos.piece_on(from_sq(move)))] & to_sq(move) : pos.gives_check(move, ci); dangerous = givesCheck @@ -960,9 +968,9 @@ moves_loop: // When in check and at SpNode search starts from here ss->reduction = reduction(improving, depth, moveCount); if ( (!PvNode && cutNode) - || ( History[pos.piece_on(to_sq(move))][to_sq(move)] - + CounterMovesHistory[pos.piece_on(prevMoveSq)][prevMoveSq] - [pos.piece_on(to_sq(move))][to_sq(move)] < VALUE_ZERO)) + || ( History[pos.piece_on(to_sq(move))][to_sq(move)] < VALUE_ZERO + && CounterMovesHistory[pos.piece_on(prevMoveSq)][prevMoveSq] + [pos.piece_on(to_sq(move))][to_sq(move)] <= VALUE_ZERO)) ss->reduction += ONE_PLY; if (move == countermove) @@ -1273,7 +1281,7 @@ moves_loop: // When in check and at SpNode search starts from here assert(is_ok(move)); givesCheck = type_of(move) == NORMAL && !ci.dcCandidates - ? ci.checkSq[type_of(pos.piece_on(from_sq(move)))] & to_sq(move) + ? ci.checkSquares[type_of(pos.piece_on(from_sq(move)))] & to_sq(move) : pos.gives_check(move, ci); // Futility pruning