[Board] Implement enPassant move handling
This commit is contained in:
14
Board.cpp
14
Board.cpp
@@ -108,13 +108,25 @@ void Board::makeMove(const Move &move) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// en passant
|
handleEnPassant(move, movedPiece);
|
||||||
|
|
||||||
handlePawnDoubleAdvance(move, toBB, movedPiece);
|
handlePawnDoubleAdvance(move, toBB, movedPiece);
|
||||||
|
|
||||||
|
|
||||||
// change turn
|
// change turn
|
||||||
mTurn = !mTurn;
|
mTurn = !mTurn;
|
||||||
}
|
}
|
||||||
|
void Board::handleEnPassant(const Move &move, const Piece &movedPiece) {
|
||||||
|
if (movedPiece.type() == PieceType::Pawn && mEPS.has_value() && move.from().file() != move.to().file()) {
|
||||||
|
auto epBB = indexToBitBoard(Square::fromCoordinates(move.to().file(), move.from().rank())->index());
|
||||||
|
auto capturedPiece = Piece(!mTurn, PieceType::Pawn);
|
||||||
|
|
||||||
|
mPieceBBs[toIndex(capturedPiece.color())] ^= epBB;
|
||||||
|
mPieceBBs[toIndex(capturedPiece.type())] ^= epBB;
|
||||||
|
mOccupiedBB ^= epBB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Board::handlePawnDoubleAdvance(const Move &move, BitBoard bb, const Piece &movedPiece) {
|
void Board::handlePawnDoubleAdvance(const Move &move, BitBoard bb, const Piece &movedPiece) {
|
||||||
if (movedPiece.type() == PieceType::Pawn) {
|
if (movedPiece.type() == PieceType::Pawn) {
|
||||||
auto fromR = move.from().rank();
|
auto fromR = move.from().rank();
|
||||||
|
@@ -128,6 +128,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handlePawnDoubleAdvance(const Move &move, BitBoard bb, const Piece &movedPiece);
|
void handlePawnDoubleAdvance(const Move &move, BitBoard bb, const Piece &movedPiece);
|
||||||
|
void handleEnPassant(const Move &move, const Piece &movedPiece);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &os, const Board &board);
|
std::ostream &operator<<(std::ostream &os, const Board &board);
|
||||||
|
Reference in New Issue
Block a user