-/// Position::do_ep_move() is a private method used to make an en passant
-/// capture. It is called from the main Position::do_move function.
-
-void Position::do_ep_move(Move m) {
-
- Color us, them;
- Square from, to, capsq;
-
- assert(is_ok());
- assert(move_is_ok(m));
- assert(move_is_ep(m));
-
- us = side_to_move();
- them = opposite_color(us);
- from = move_from(m);
- to = move_to(m);
- capsq = (us == WHITE)? (to - DELTA_N) : (to - DELTA_S);
-
- assert(to == st->epSquare);
- assert(relative_rank(us, to) == RANK_6);
- assert(piece_on(to) == EMPTY);
- assert(piece_on(from) == piece_of_color_and_type(us, PAWN));
- assert(piece_on(capsq) == piece_of_color_and_type(them, PAWN));
-
- // Remove captured piece
- clear_bit(&(byColorBB[them]), capsq);
- clear_bit(&(byTypeBB[PAWN]), capsq);
- clear_bit(&(byTypeBB[0]), capsq); // HACK: byTypeBB[0] == occupied squares
- board[capsq] = EMPTY;
-
- // Remove moving piece from source square
- clear_bit(&(byColorBB[us]), from);
- clear_bit(&(byTypeBB[PAWN]), from);
- clear_bit(&(byTypeBB[0]), from); // HACK: byTypeBB[0] == occupied squares
-
- // Put moving piece on destination square
- set_bit(&(byColorBB[us]), to);
- set_bit(&(byTypeBB[PAWN]), to);
- set_bit(&(byTypeBB[0]), to); // HACK: byTypeBB[0] == occupied squares
- board[to] = board[from];
- board[from] = EMPTY;
-
- // Update material hash key
- st->materialKey ^= zobMaterial[them][PAWN][pieceCount[them][PAWN]];
-
- // Update piece count
- pieceCount[them][PAWN]--;
-
- // Update piece list
- pieceList[us][PAWN][index[from]] = to;
- index[to] = index[from];
- pieceList[them][PAWN][index[capsq]] = pieceList[them][PAWN][pieceCount[them][PAWN]];
- index[pieceList[them][PAWN][index[capsq]]] = index[capsq];
-
- // Update hash key
- st->key ^= zobrist[us][PAWN][from] ^ zobrist[us][PAWN][to];
- st->key ^= zobrist[them][PAWN][capsq];
- st->key ^= zobEp[st->epSquare];
-
- // Update pawn hash key
- st->pawnKey ^= zobrist[us][PAWN][from] ^ zobrist[us][PAWN][to];
- st->pawnKey ^= zobrist[them][PAWN][capsq];
-
- // Update incremental scores
- st->mgValue -= pst<MidGame>(them, PAWN, capsq);
- st->mgValue -= pst<MidGame>(us, PAWN, from);
- st->mgValue += pst<MidGame>(us, PAWN, to);
- st->egValue -= pst<EndGame>(them, PAWN, capsq);
- st->egValue -= pst<EndGame>(us, PAWN, from);
- st->egValue += pst<EndGame>(us, PAWN, to);
-
- // Reset en passant square
- st->epSquare = SQ_NONE;
-
- // Reset rule 50 counter
- st->rule50 = 0;
-
- // Update checkers BB
- st->checkersBB = attacks_to(king_square(them), us);
-}
-
-