- if(move_is_castle(m))
- undo_castle_move(m);
- else if(move_promotion(m))
- undo_promotion_move(m, u);
- else if(move_is_ep(m))
- undo_ep_move(m);
- else {
- Color us, them;
- Square from, to;
- PieceType piece, capture;
-
- us = side_to_move();
- them = opposite_color(us);
-
- from = move_from(m);
- to = move_to(m);
-
- assert(piece_on(from) == EMPTY);
- assert(color_of_piece_on(to) == us);
-
- // Put the piece back at the source square:
- piece = type_of_piece_on(to);
- set_bit(&(byColorBB[us]), from);
- set_bit(&(byTypeBB[piece]), from);
- set_bit(&(byTypeBB[0]), from); // HACK: byTypeBB[0] == occupied squares
- board[from] = piece_of_color_and_type(us, piece);
-
- // Clear the destination square
- clear_bit(&(byColorBB[us]), to);
- clear_bit(&(byTypeBB[piece]), to);
- clear_bit(&(byTypeBB[0]), to); // HACK: byTypeBB[0] == occupied squares
-
- // If the moving piece was a king, update the king square:
- if(piece == KING)
- kingSquare[us] = from;
-
- // Update piece list:
- pieceList[us][piece][index[to]] = from;
- index[from] = index[to];
-
- capture = u.capture;
-
- if(capture) {
- assert(capture != KING);
- // Replace the captured piece:
- set_bit(&(byColorBB[them]), to);
- set_bit(&(byTypeBB[capture]), to);
- set_bit(&(byTypeBB[0]), to);
- board[to] = piece_of_color_and_type(them, capture);
+ if (move_is_castle(m))
+ undo_castle_move(m);
+ else if (move_promotion(m))
+ undo_promotion_move(m, u);
+ else if (move_is_ep(m))
+ undo_ep_move(m);
+ else
+ {
+ Color us, them;
+ Square from, to;
+ PieceType piece, capture;