From e02940010a5257fce39695346bcbf536449f94a3 Mon Sep 17 00:00:00 2001 From: "rektdie@gmail.com" Date: Mon, 8 Apr 2024 22:03:13 +0200 Subject: [PATCH] fixed a bug in IsLegalEnpassant function --- source/movegen.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/movegen.cpp b/source/movegen.cpp index 406cd93..aaec457 100644 --- a/source/movegen.cpp +++ b/source/movegen.cpp @@ -400,9 +400,9 @@ static bool IsLegalEnPassant(Board &board, int square) { // Looking for horizontal checks if (!(kingSquare.GetBoard() & files[A])) { - int currentSq = kingSquare.getLS1BIndex() + east; + int currentSq = kingSquare.getLS1BIndex() + west; - while (!Bitboard(files[A]).IsSet(currentSq)) { + while (!Bitboard(files[H]).IsSet(currentSq)) { if (newOccupancy.IsSet(currentSq)) { int attackerColor = board.GetPieceColor(currentSq); int attackerType = board.GetPieceType(currentSq); @@ -411,9 +411,9 @@ static bool IsLegalEnPassant(Board &board, int square) { || attackerType == Bishop || attackerType == Queen)) { return false; } - return true; + break; } - currentSq += east; + currentSq += west; } } @@ -429,7 +429,7 @@ static bool IsLegalEnPassant(Board &board, int square) { || attackerType == Bishop || attackerType == Queen)) { return false; } - return true; + break; } currentSq += east; }