From 28d8b2689ff577368663154d626e880220301999 Mon Sep 17 00:00:00 2001 From: "rektdie@gmail.com" Date: Tue, 16 Apr 2024 16:24:57 +0200 Subject: [PATCH] bugfix: looking for checkers in isLegalEnPassant didn't start from the king --- source/main.cpp | 2 +- source/movegen.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 8617e01..c481de2 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -9,7 +9,7 @@ int main() { initSliderAttacks(); Board board; - board.SetByFen("r3k2r/Pppp1ppp/1b3nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w kq - 0 1"); + board.SetByFen("rnbq1k1r/pp1Pbppp/2p5/8/2B5/8/PPP1NnPP/RNBQK2R w KQ - 1 8"); Perft(board, 6); return 0; diff --git a/source/movegen.cpp b/source/movegen.cpp index 15cf756..1281913 100644 --- a/source/movegen.cpp +++ b/source/movegen.cpp @@ -440,7 +440,7 @@ static bool IsLegalEnPassant(Board &board, int square) { // Either east or west if (abs(directionToKing) == 1) { - int currentSq = square - directionToKing; + int currentSq = kingSquare.getLS1BIndex() - directionToKing; Bitboard endingFile = directionToKing > 0 ? files[H] : files[A];