From 70607073bccdc249158c84018837a054fa50f445 Mon Sep 17 00:00:00 2001 From: rektdie Date: Mon, 8 Apr 2024 12:16:11 +0200 Subject: [PATCH] added en passant to check evasion --- source/movegen.cpp | 17 ++++++++++------- source/types.h | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/source/movegen.cpp b/source/movegen.cpp index 843609b..02c2769 100644 --- a/source/movegen.cpp +++ b/source/movegen.cpp @@ -344,13 +344,11 @@ static Bitboard SliderRaysToSquare(int attacker, int target) { Bitboard ray; int direction = GetDirection(attacker, target); - - int square = attacker; if (direction) { - while (square <= target) { - ray.SetBit(square); - square += direction; + while (attacker <= target) { + ray.SetBit(attacker); + attacker += direction; } } @@ -473,10 +471,15 @@ static void GenCheckEvasions(Board &board, bool color) { if (type == Pawn) { pushes |= getPawnPushes(square, color, board.occupied) & pushMask; - } else { - pushes |= getPieceAttacks(square, type, color, board.occupied.GetBoard()) & pushMask; + + // Checking for en passant capture + if ((pawnAttacks[color][square] + & Bitboard::GetSquare(board.enPassantTarget)).GetBoard()) { + board.AddMove(Move(square, board.enPassantTarget, epCapture)); + } } + pushes |= getPieceAttacks(square, type, color, board.occupied.GetBoard()) & pushMask; captures |= getPieceAttacks(square, type, color, board.occupied.GetBoard()) & captureMask; while (captures.GetBoard()) { diff --git a/source/types.h b/source/types.h index 08cb954..a8fa307 100644 --- a/source/types.h +++ b/source/types.h @@ -4,7 +4,7 @@ using U64 = uint64_t; -constexpr char StartingFen[] = "8/8/8/8/r2K4/2P5/8zz/b6k w - - 0 1"; +constexpr char StartingFen[] = "8/8/8/2k5/3Pp3/8/8/4K3 b - d3 0 1"; enum COLOR { White,