-}
-
-
-/// Position::undo_promotion_move() is a private method used to unmake a
-/// promotion move. It is called from the main Position::do_move
-/// function. The UndoInfo object, which has been initialized in
-/// Position::do_move, is used to put back the captured piece (if any).
-
-void Position::undo_promotion_move(Move m, const UndoInfo &u) {
-
- Color us, them;
- Square from, to;
- PieceType capture, promotion;
-
- assert(move_is_ok(m));
- assert(move_promotion(m));
-
- // When we have arrived here, some work has already been done by
- // Position::undo_move. In particular, the side to move has been switched,
- // so the code below is correct.
- us = side_to_move();
- them = opposite_color(us);
- from = move_from(m);
- to = move_to(m);
-
- assert(relative_rank(us, to) == RANK_8);
- assert(piece_on(from) == EMPTY);
-
- // Remove promoted piece
- promotion = move_promotion(m);
- assert(piece_on(to)==piece_of_color_and_type(us, promotion));
- assert(promotion >= KNIGHT && promotion <= QUEEN);
- clear_bit(&(byColorBB[us]), to);
- clear_bit(&(byTypeBB[promotion]), to);
- clear_bit(&(byTypeBB[0]), to); // HACK: byTypeBB[0] == occupied squares
-
- // Insert pawn at source square
- set_bit(&(byColorBB[us]), from);
- set_bit(&(byTypeBB[PAWN]), from);
- set_bit(&(byTypeBB[0]), from); // HACK: byTypeBB[0] == occupied squares
- board[from] = piece_of_color_and_type(us, PAWN);
-
- // Update material
- npMaterial[us] -= piece_value_midgame(promotion);
-
- // Update piece list
- pieceList[us][PAWN][pieceCount[us][PAWN]] = from;
- index[from] = pieceCount[us][PAWN];
- pieceList[us][promotion][index[to]] =
- pieceList[us][promotion][pieceCount[us][promotion] - 1];
- index[pieceList[us][promotion][index[to]]] = index[to];
-
- // Update piece counts
- pieceCount[us][promotion]--;
- pieceCount[us][PAWN]++;
-
- capture = u.capture;
-
- if (capture)
- {
- assert(capture != KING);
-
- // Insert captured piece:
- set_bit(&(byColorBB[them]), to);
- set_bit(&(byTypeBB[capture]), to);
- set_bit(&(byTypeBB[0]), to); // HACK: byTypeBB[0] == occupied squares
- board[to] = piece_of_color_and_type(them, capture);
-
- // Update material. Because the move is a promotion move, we know
- // that the captured piece cannot be a pawn.
- assert(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;
-}
-
-
-/// Position::undo_ep_move() is a private method used to unmake an en passant
-/// capture. It is called from the main Position::undo_move function. Because
-/// the captured piece is always a pawn, we don't need to pass an UndoInfo
-/// object from which to retrieve the captured piece.
-
-void Position::undo_ep_move(Move m) {