1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

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 <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-11-01 17:19:04 +01:00
parent 8ebe5075eb
commit 23de3e16f1

View file

@ -52,9 +52,6 @@ namespace {
EVASION
};
// Functions
bool castling_is_check(const Position&, CastlingSide);
// Helper templates
template<CastlingSide Side>
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<KNIGHT>(pos, mlist, us, dc, ksq);
mlist = generate_direct_checks<BISHOP>(pos, mlist, us, dc, ksq);
mlist = generate_direct_checks<ROOK>(pos, mlist, us, dc, ksq);
mlist = generate_direct_checks<QUEEN>(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<QUEEN_SIDE>(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<KING_SIDE>(pos, mlist);
return mlist;
return generate_direct_checks<QUEEN>(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)));
}
}