From 41b54eb0c3faa51bfee28d941295545f3519b064 Mon Sep 17 00:00:00 2001 From: "rektdie@gmail.com" Date: Sun, 14 Apr 2024 15:18:39 +0200 Subject: [PATCH] Revert "fixed a bug in previous commit + doublePawnPushes were not working" This reverts commit c97c3acb2766b5953a7163684a37f91bf4f83270. --- source/board.cpp | 23 +++++++---------------- source/main.cpp | 2 +- source/movegen.cpp | 12 ++---------- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/source/board.cpp b/source/board.cpp index 0d24052..3c345dc 100644 --- a/source/board.cpp +++ b/source/board.cpp @@ -291,25 +291,10 @@ void Board::RemovePiece(int piece, int square, bool color) { occupied.PopBit(square); } -// Updates castling rights on capturing (only if needed) -static void UpdateCastlingRights(Board &board, int targetPiece, int targetSquare, int attackerColor) { - if (targetPiece == Rook) { - int queenSideRook = attackerColor ? a1 : a8; - int kingSideRook = attackerColor ? a8 : h8; - - if (targetSquare == queenSideRook) { - board.castlingRights[!attackerColor * 2 + 1] = false; - } else if (targetSquare == kingSideRook) { - board.castlingRights[!attackerColor * 2] = false; - } - } -} - void Board::Promote(int square, int pieceType, int color, bool isCapture) { if (isCapture) { int targetType = GetPieceType(square); RemovePiece(targetType, square, !color); - UpdateCastlingRights(*this, targetType, square, color); } SetPiece(pieceType, square, color); @@ -337,7 +322,13 @@ void Board::MakeMove(Move move) { case capture: RemovePiece(targetPiece, move.MoveTo(), !attackerColor); SetPiece(attackerPiece, move.MoveTo(), attackerColor); - UpdateCastlingRights(*this, targetPiece, move.MoveTo(), attackerColor); + + if (targetPiece == Rook) { + int queenSide = move.MoveTo() % 8 == 0; + + castlingRights[!attackerColor * 2 + queenSide] = false; + } + break; case epCapture: RemovePiece(Pawn, move.MoveTo() - direction, !attackerColor); diff --git a/source/main.cpp b/source/main.cpp index b8294e6..4b969c3 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, 3); return 0; diff --git a/source/movegen.cpp b/source/movegen.cpp index 52d4396..175200a 100644 --- a/source/movegen.cpp +++ b/source/movegen.cpp @@ -538,11 +538,7 @@ static void GenPawnMoves(Board &board, bool color) { board.AddMove(Move(square, pushSquare, rookPromotion)); board.AddMove(Move(square, pushSquare, queenPromotion)); } else { - if (abs(pushSquare - square) == 16) { - board.AddMove(Move(square, pushSquare, doublePawnPush)); - } else { - board.AddMove(Move(square, pushSquare, quiet)); - } + board.AddMove(Move(square, pushSquare, quiet)); } pushes.PopBit(pushSquare); @@ -888,11 +884,7 @@ static void GenCheckEvasions(Board &board, bool color) { while (pushes.GetBoard()) { int pushSquare = pushes.getLS1BIndex(); - if (type == Pawn && abs(pushSquare - square) == 16) { - board.AddMove(Move(square, pushSquare, doublePawnPush)); - } else { - board.AddMove(Move(square, pushSquare, quiet)); - } + board.AddMove(Move(square, pushSquare, quiet)); pushes.PopBit(pushSquare); }