return 0;
} else {
const Color color = board.get_side();
Color colorOther = color == Color::BLACK ? Color::WHITE : Color::BLACK;
Color colorOther = color == Color::BLACK ? Color::WHITE : Color::BLACK;
const Square source = this->source();
const Square target = this->target();
const Square ntarget =
static_cast<Square>(to_underlying(this->target()) + (color == Color::WHITE ? -8 : +8));
const piece::Type piece = board.get_square_piece_type(source);
if (!is_capture()) {
if (is_promote()) {
piece_remove(board, piece(), color, source);
piece_remove(board, piece, color, source);
piece_set(board, promoted(), color, target);
} else {
piece_move(board, piece(), color, source, target);
piece_move(board, piece, color, source, target);
}
} else {
const piece::Type captured = board.get_square_piece_type(target);
if (is_enpassant()) {
piece_move(board, piece(), color, source, target);
piece_remove(board, captured(), colorOther, ntarget);
piece_move(board, piece, color, source, target);
piece_remove(board, PAWN, colorOther, ntarget);
} else if (is_promote()) {
piece_remove(board, piece(), color, source);
piece_remove(board, captured(), colorOther, target);
piece_remove(board, piece, color, source);
piece_remove(board, captured, colorOther, target);
piece_set(board, promoted(), color, target);
} else {
piece_remove(board, captured(), colorOther, target);
piece_move(board, piece(), color, source, target);
piece_remove(board, captured, colorOther, target);
piece_move(board, piece, color, source, target);
}
}
board.set_enpassant(is_double() ? ntarget : Square::no_sq);
if (is_castle()) {
if (target == Square::g1) piece_move(board, ROOK, Color::WHITE, Square::h1, Square::f1);
if (target == Square::c1) piece_move(board, ROOK, Color::WHITE, Square::a1, Square::d1);
if (target == Square::g8) piece_move(board, ROOK, Color::BLACK, Square::h8, Square::f8);
if (target == Square::c8) piece_move(board, ROOK, Color::BLACK, Square::a8, Square::d8);
if (color == Color::WHITE) {
if (is_castle_king()) piece_move(board, ROOK, Color::WHITE, Square::h1, Square::f1);
if (is_castle_queen()) piece_move(board, ROOK, Color::WHITE, Square::a1, Square::d1);
} else {
if (is_castle_king()) piece_move(board, ROOK, Color::BLACK, Square::h8, Square::f8);
if (is_castle_queen()) piece_move(board, ROOK, Color::BLACK, Square::a8, Square::d8);
}
}
board.xor_hash(Zobrist::key_castle(board.get_castle()));