1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00

Fix a performance bug in generate_move_if_legal

Use the pinned argument in pos.move_is_legal()

No functional change, simply use pos.move_is_legal() as
was meant to be.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2008-10-23 21:02:10 +01:00
parent 1ac2f50145
commit 2aebf8eb55

View file

@ -429,7 +429,7 @@ Move generate_move_if_legal(const Position& pos, Move m, Bitboard pinned) {
assert(pos.piece_on(to - pawn_push(us)) == pawn_of_color(them));
// The move is pseudo-legal. If it is legal, return it.
return (pos.move_is_legal(m) ? m : MOVE_NONE);
return (pos.move_is_legal(m, pinned) ? m : MOVE_NONE);
}
// Castling moves
@ -561,12 +561,12 @@ Move generate_move_if_legal(const Position& pos, Move m, Bitboard pinned) {
return MOVE_NONE;
}
// The move is pseudo-legal. Return it if it is legal.
return (pos.move_is_legal(m) ? m : MOVE_NONE);
return (pos.move_is_legal(m, pinned) ? m : MOVE_NONE);
}
// Luckly we can handle all the other pieces in one go
return ( pos.piece_attacks_square(from, to)
&& pos.move_is_legal(m)
&& pos.move_is_legal(m, pinned)
&& !move_promotion(m) ? m : MOVE_NONE);
}