The structure of move is changed.
Now it is:
Code: Select all
/// A move needs 16 bits to be stored
///
/// bit 0- 5: destination square (from 0 to 63)
/// bit 6-11: origin square (from 0 to 63)
/// bit 12-13: promotion piece type - 2 (from KNIGHT-2 to QUEEN-2)
/// bit 14-15: special move flag: promotion (1), en passant (2), castle (3)
Only fortunately, it works correctly.
Code: Select all
inline bool Position::move_is_capture(Move m) const {
// Move must not be MOVE_NONE !
return (m & (3 << 15)) ? !move_is_castle(m) : !square_is_empty(move_to(m));
}
inline bool Position::move_is_capture_or_promotion(Move m) const {
// Move must not be MOVE_NONE !
return (m & (0x1F << 12)) ? !move_is_castle(m) : !square_is_empty(move_to(m));
}
Code: Select all
inline bool Position::move_is_capture(Move m) const {
return !square_is_empty(move_to(m)) || move_is_ep(m);
}
inline bool Position::move_is_capture_or_promotion(Move m) const {
return move_is_capture(m) || move_is_promotion(m);
}
2. hint
In the perpetual function: Position::pl_move_is_legal() there is a code:
Code: Select all
// Castling moves are checked for legality during move generation.
if (move_is_castle(m))
return true;
Code: Select all
// If the moving piece is a king, check whether the destination
// square is attacked by the opponent.
if (type_of_piece_on(from) == KING)
// Castling moves are checked for legality during move generation.
return move_is_castle(m) ? true : !(attackers_to(move_to(m)) & pieces_of_color(opposite_color(us)));
Code: Select all
// If the moving piece is a king, check whether the destination
// square is attacked by the opponent.
if (type_of_piece_on(from) == KING)
return !(attackers_to(move_to(m)) & pieces_of_color(opposite_color(us)));