- // which is taken care of later):
- this->restore(u);
-
- if(move_is_castle(m))
- this->undo_castle_move(m);
- else if(move_promotion(m))
- this->undo_promotion_move(m, u);
- else if(move_is_ep(m))
- this->undo_ep_move(m);
- else {
- Color us, them;
- Square from, to;
- PieceType piece, capture;
-
- us = this->side_to_move();
- them = opposite_color(us);
-
- from = move_from(m);
- to = move_to(m);
-
- assert(this->piece_on(from) == EMPTY);
- assert(color_of_piece_on(to) == us);
-
- // Put the piece back at the source square:
- piece = this->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);
-
- // Update material:
- if(capture != PAWN)
- npMaterial[them] += piece_value_midgame(capture);
-
- // Update piece list:
- pieceList[them][capture][pieceCount[them][capture]] = to;
- index[to] = pieceCount[them][capture];
-
- // Update piece count:
- pieceCount[them][capture]++;
- }
- else
- board[to] = EMPTY;
+ // which is taken care of later)
+ restore(u);
+
+ 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);
+
+ // Update material
+ if (capture != PAWN)
+ npMaterial[them] += piece_value_midgame(capture);
+
+ // Update piece list
+ pieceList[them][capture][pieceCount[them][capture]] = to;
+ index[to] = pieceCount[them][capture];
+
+ // Update piece count
+ pieceCount[them][capture]++;
+ } else
+ board[to] = EMPTY;