From: Marco Costalba Date: Thu, 7 May 2009 15:01:52 +0000 (+0200) Subject: Better dscovery check condition in generate_pawn_checks() X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=9fbe9af0a09bd88b96955474f294a945b1bb6773 Better dscovery check condition in generate_pawn_checks() Be more strict, is not enough dc bitboard is not empty, but needs to inclde also at least one pawn. No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/movegen.cpp b/src/movegen.cpp index 440dd839..be9309d1 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -65,7 +65,7 @@ namespace { template MoveStack* generate_pawn_noncaptures(const Position& pos, MoveStack* mlist); - template + template MoveStack* generate_pawn_checks(const Position&, Bitboard, Square, MoveStack*); template @@ -88,11 +88,8 @@ namespace { template<> inline MoveStack* generate_piece_checks(const Position& p, MoveStack* m, Color us, Bitboard dc, Square ksq) { - if (us == WHITE) - return generate_pawn_checks(p, dc, ksq, m); - else - return generate_pawn_checks(p, dc, ksq, m); - + return (us == WHITE ? generate_pawn_checks(p, dc, ksq, m) + : generate_pawn_checks(p, dc, ksq, m)); } // Template generate_piece_moves() with specializations and overloads @@ -752,18 +749,25 @@ namespace { } - template + template MoveStack* generate_pawn_checks(const Position& pos, Bitboard dc, Square ksq, MoveStack* mlist) { + // Calculate our parametrized parameters at compile time + const Color Them = (Us == WHITE ? BLACK : WHITE); + const Bitboard TRank8BB = (Us == WHITE ? Rank8BB : Rank1BB); + const Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB); + const SquareDelta TDELTA_N = (Us == WHITE ? DELTA_N : DELTA_S); + Bitboard b1, b2, b3; Bitboard empty = pos.empty_squares(); + Bitboard pawns = pos.pawns(Us); - if (dc != EmptyBoardBB) + if (dc & pawns) { // Pawn moves which gives discovered check. This is possible only if the // pawn is not on the same file as the enemy king, because we don't // generate captures. - b1 = pos.pawns(Us) & ~file_bb(ksq); + b1 = pawns & ~file_bb(ksq); // Discovered checks, single pawn pushes, no promotions b2 = b3 = move_pawns(b1 & dc) & empty & ~TRank8BB; @@ -784,7 +788,7 @@ namespace { // Direct checks. These are possible only for pawns on neighboring files // of the enemy king. - b1 = pos.pawns(Us) & neighboring_files_bb(ksq) & ~dc; + b1 = pawns & neighboring_files_bb(ksq) & ~dc; // Direct checks, single pawn pushes b2 = move_pawns(b1) & empty;