added en passant to check evasion

This commit is contained in:
rektdie committed 2024-04-08 12:16:11 +02:00
1 parent 70179b953d
commit 70607073bc
2 files changed
+11 -8

No files matched your search

+10 -7
View File
@@ -345,12 +345,10 @@ static Bitboard SliderRaysToSquare(int attacker, int target) {
int direction = GetDirection(attacker, target); int direction = GetDirection(attacker, target);
int square = attacker;
if (direction) { if (direction) {
while (square <= target) { while (attacker <= target) {
ray.SetBit(square); ray.SetBit(attacker);
square += direction; attacker += direction;
} }
} }
@@ -473,10 +471,15 @@ static void GenCheckEvasions(Board &board, bool color) {
if (type == Pawn) { if (type == Pawn) {
pushes |= getPawnPushes(square, color, board.occupied) & pushMask; 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; captures |= getPieceAttacks(square, type, color, board.occupied.GetBoard()) & captureMask;
while (captures.GetBoard()) { while (captures.GetBoard()) {
+1 -1
View File
@@ -4,7 +4,7 @@
using U64 = uint64_t; 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 { enum COLOR {
White, White,