1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 09:13:08 +00:00

Fix a bug in generate_piece_checks()

We are generating also king moves that give check !

Of course these moves are illegal so are in any case
filtered out in MovePicker. Neverthless we should avoid
to generate them.

Also simplify a bit the code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-09-21 08:47:47 +01:00
parent 746bcb348f
commit aaffcf973e

View file

@ -848,23 +848,20 @@ namespace {
// Direct checks // Direct checks
b = target & ~dc; b = target & ~dc;
if (Piece != KING || b) Bitboard checkSqs = pos.attacks_from<Piece>(ksq) & pos.empty_squares();
if (Piece == KING || !checkSqs)
return mlist;
while (b)
{ {
Bitboard checkSqs = pos.attacks_from<Piece>(ksq) & pos.empty_squares(); Square from = pop_1st_bit(&b);
if (!checkSqs) if ( (Piece == QUEEN && !(QueenPseudoAttacks[from] & checkSqs))
return mlist; || (Piece == ROOK && !(RookPseudoAttacks[from] & checkSqs))
|| (Piece == BISHOP && !(BishopPseudoAttacks[from] & checkSqs)))
continue;
while (b) Bitboard bb = pos.attacks_from<Piece>(from) & checkSqs;
{ SERIALIZE_MOVES(bb);
Square from = pop_1st_bit(&b);
if ( (Piece == QUEEN && !(QueenPseudoAttacks[from] & checkSqs))
|| (Piece == ROOK && !(RookPseudoAttacks[from] & checkSqs))
|| (Piece == BISHOP && !(BishopPseudoAttacks[from] & checkSqs)))
continue;
Bitboard bb = pos.attacks_from<Piece>(from) & checkSqs;
SERIALIZE_MOVES(bb);
}
} }
return mlist; return mlist;
} }