Fix move_is_capture() to detect capture promotions

We miss to account as a capture a promotion capture !

Incredible bug in this critical function that is here
since a long time (b50921fd5c of 21/10/2009 !!)

This patch fixes the bug and readds the faster
move_is_capture_or_promotion() that slightly increases
overall speed.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2011-06-22 23:04:57 +01:00
parent 1c42d15340
commit 6a1707889c
3 changed files with 16 additions and 9 deletions

View File

@@ -189,6 +189,7 @@ public:
bool move_is_pl(const Move m) const;
bool move_gives_check(Move m, const CheckInfo& ci) const;
bool move_is_capture(Move m) const;
bool move_is_capture_or_promotion(Move m) const;
bool move_is_passed_pawn_push(Move m) const;
bool move_attacks_square(Move m, Square s) const;
@@ -534,10 +535,18 @@ inline bool Position::is_chess960() const {
return chess960;
}
inline bool Position::move_is_capture_or_promotion(Move m) const {
assert(m != MOVE_NONE && m != MOVE_NULL);
return move_is_special(m) ? !move_is_castle(m) : !square_is_empty(move_to(m));
}
inline bool Position::move_is_capture(Move m) const {
assert (m != MOVE_NONE && m != MOVE_NULL);
return !move_is_special(m) ? !square_is_empty(move_to(m)) : move_is_ep(m);
assert(m != MOVE_NONE && m != MOVE_NULL);
// Note that castle is coded as "king captures the rook"
return (!square_is_empty(move_to(m)) && !move_is_castle(m)) || move_is_ep(m);
}
inline PieceType Position::captured_piece_type() const {