assert(move_is_ok(m));
assert(pinned == pinned_pieces(side_to_move()));
- // Castling moves are checked for legality during move generation.
- if (move_is_castle(m))
- return true;
-
// En passant captures are a tricky special case. Because they are
// rather uncommon, we do it simply by testing whether the king is attacked
// after the move is made
assert(piece_on(king_square(us)) == make_piece(us, KING));
// If the moving piece is a king, check whether the destination
- // square is attacked by the opponent.
+ // square is attacked by the opponent. Castling moves are checked
+ // for legality during move generation.
if (type_of_piece_on(from) == KING)
- return !(attackers_to(move_to(m)) & pieces_of_color(opposite_color(us)));
+ return move_is_castle(m) || !(attackers_to(move_to(m)) & pieces_of_color(opposite_color(us)));
// A non-king move is legal if and only if it is not pinned or it
// is moving along the ray towards or away from the king.
from = move_from(m);
to = move_to(m);
capturedType = type_of_piece_on(to);
-
- // King cannot be recaptured
- if (capturedType == KING)
- return seeValues[capturedType];
-
occupied = occupied_squares();
// Handle en passant moves