X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=394f228fb4f59956914ab3d014b199934d245716;hp=ca5a107ea2853df9b3648eeb3f4e56bb23c039b6;hb=ad2a0e356e395038a08324f9ff0afee7fc98b8e9;hpb=d438720a1c8115485ff47eeca3b734cd681d01c4 diff --git a/src/search.cpp b/src/search.cpp index ca5a107e..394f228f 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -108,6 +108,13 @@ namespace { void update_quiet_stats(const Position& pos, Stack* ss, Move move, Move* quiets, int quietsCnt, int bonus); void update_capture_stats(const Position& pos, Move move, Move* captures, int captureCnt, int bonus); + inline bool gives_check(const Position& pos, Move move) { + Color us = pos.side_to_move(); + return type_of(move) == NORMAL && !(pos.blockers_for_king(~us) & pos.pieces(us)) + ? pos.check_squares(type_of(pos.moved_piece(move))) & to_sq(move) + : pos.gives_check(move); + } + // perft() is our utility to verify move generation. All the leaf nodes up // to the given depth are generated and counted, and the sum is returned. template @@ -823,10 +830,7 @@ moves_loop: // When in check, search starts from here extension = DEPTH_ZERO; captureOrPromotion = pos.capture_or_promotion(move); movedPiece = pos.moved_piece(move); - - givesCheck = type_of(move) == NORMAL && !pos.discovered_check_candidates() - ? pos.check_squares(type_of(movedPiece)) & to_sq(move) - : pos.gives_check(move); + givesCheck = gives_check(pos, move); moveCountPruning = depth < 16 * ONE_PLY && moveCount >= FutilityMoveCounts[improving][depth / ONE_PLY]; @@ -1238,9 +1242,7 @@ moves_loop: // When in check, search starts from here { assert(is_ok(move)); - givesCheck = type_of(move) == NORMAL && !pos.discovered_check_candidates() - ? pos.check_squares(type_of(pos.moved_piece(move))) & to_sq(move) - : pos.gives_check(move); + givesCheck = gives_check(pos, move); moveCount++;