From a7cf8e0c216ee68487f177b67ed93a79e425634b Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Sun, 2 Feb 2025 23:33:52 +0100 Subject: [PATCH] make_move now handles the setting of en passant targets --- cpp/src/board.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cpp/src/board.cpp b/cpp/src/board.cpp index ae3be04..a2d45da 100644 --- a/cpp/src/board.cpp +++ b/cpp/src/board.cpp @@ -188,6 +188,17 @@ Board Board::make_move(Move move) const { // -- Handle promotion if (move.promoting_to != 0) ret.squares[move.target_square] = move.promoting_to; + + // -- Set en passant target if need + if ((squares[move.source_square] & 0b111) == Piece::Pawn + && std::abs(move.target_square - move.source_square) == 16) { + if (white_to_play) + ret.en_passant_target = move.target_square - 8; + else + ret.en_passant_target = move.target_square + 8; + } else { + ret.en_passant_target = -1; + } return ret; }