From: Marco Costalba Date: Sun, 1 Nov 2009 16:19:04 +0000 (+0100) Subject: Remove castling moves in check generation X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=23de3e16f153f91601e0a6a19b793c54a1ba35cd Remove castling moves in check generation Check generation is used only in qsearch and only at Depth(0), castling moves that give check are very rare overall and even almost not exsistent at Depth(0). So retire this almost never used code that adds a small but consistent slow down in the normal path. Signed-off-by: Marco Costalba --- diff --git a/src/movegen.cpp b/src/movegen.cpp index cab7c243..00e1adf5 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -52,9 +52,6 @@ namespace { EVASION }; - // Functions - bool castling_is_check(const Position&, CastlingSide); - // Helper templates template MoveStack* generate_castle_moves(const Position&, MoveStack*); @@ -190,20 +187,7 @@ MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist, Bi mlist = generate_direct_checks(pos, mlist, us, dc, ksq); mlist = generate_direct_checks(pos, mlist, us, dc, ksq); mlist = generate_direct_checks(pos, mlist, us, dc, ksq); - mlist = generate_direct_checks(pos, mlist, us, dc, ksq); - - // Castling moves that give check. Very rare but nice to have! - if ( pos.can_castle_queenside(us) - && (square_rank(ksq) == square_rank(pos.king_square(us)) || square_file(ksq) == FILE_D) - && castling_is_check(pos, QUEEN_SIDE)) - mlist = generate_castle_moves(pos, mlist); - - if ( pos.can_castle_kingside(us) - && (square_rank(ksq) == square_rank(pos.king_square(us)) || square_file(ksq) == FILE_F) - && castling_is_check(pos, KING_SIDE)) - mlist = generate_castle_moves(pos, mlist); - - return mlist; + return generate_direct_checks(pos, mlist, us, dc, ksq); } @@ -787,17 +771,4 @@ namespace { } return mlist; } - - bool castling_is_check(const Position& pos, CastlingSide side) { - - // After castling opponent king is attacked by the castled rook? - File rookFile = (side == QUEEN_SIDE ? FILE_D : FILE_F); - Color us = pos.side_to_move(); - Square ksq = pos.king_square(us); - Bitboard occ = pos.occupied_squares(); - - clear_bit(&occ, ksq); // Remove our king from the board - Square rsq = make_square(rookFile, square_rank(ksq)); - return bit_is_set(rook_attacks_bb(rsq, occ), pos.king_square(opposite_color(us))); - } }