X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=097faf90f7c2fc4d15f5845335c306fa792ae99f;hp=95f1332ed1ddb6e1ca743e006cdf1039bcd034d8;hb=41641e3b1eea0038ab6984766d2b3bca869be7fa;hpb=d48a304262eb6b96864df11734976b4a57fcc72a diff --git a/src/search.cpp b/src/search.cpp index 95f1332e..097faf90 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -51,12 +51,6 @@ using std::string; using Eval::evaluate; using namespace Search; -// Fast wrapper for common case of pos.gives_check() -#define FAST_GIVES_CHECK(pos, m, ci) \ - ((type_of(m) == NORMAL && ci.dcCandidates == 0) \ - ? (ci.checkSq[type_of(pos.piece_on(from_sq(m)))] & to_sq(m)) \ - : pos.gives_check(m, ci)) - namespace { // Set to true to force running with one thread. Used for debugging @@ -160,10 +154,10 @@ void Search::init() { /// 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. -static size_t perft(Position& pos, Depth depth) { +static uint64_t perft(Position& pos, Depth depth) { StateInfo st; - size_t cnt = 0; + uint64_t cnt = 0; CheckInfo ci(pos); const bool leaf = depth == 2 * ONE_PLY; @@ -176,7 +170,7 @@ static size_t perft(Position& pos, Depth depth) { return cnt; } -size_t Search::perft(Position& pos, Depth depth) { +uint64_t Search::perft(Position& pos, Depth depth) { return depth > ONE_PLY ? ::perft(pos, depth) : MoveList(pos).size(); } @@ -760,7 +754,11 @@ moves_loop: // When in check and at SpNode search starts from here ext = DEPTH_ZERO; captureOrPromotion = pos.capture_or_promotion(move); - givesCheck = FAST_GIVES_CHECK(pos, move, ci); + + givesCheck = type_of(move) == NORMAL && !ci.dcCandidates + ? ci.checkSq[type_of(pos.piece_on(from_sq(move)))] & to_sq(move) + : pos.gives_check(move, ci); + dangerous = givesCheck || type_of(move) != NORMAL || pos.advanced_pawn_push(move); @@ -1140,7 +1138,9 @@ moves_loop: // When in check and at SpNode search starts from here { assert(is_ok(move)); - givesCheck = FAST_GIVES_CHECK(pos, move, ci); + givesCheck = type_of(move) == NORMAL && !ci.dcCandidates + ? ci.checkSq[type_of(pos.piece_on(from_sq(move)))] & to_sq(move) + : pos.gives_check(move, ci); // Futility pruning if ( !PvNode