en passant bugfix
This commit is contained in:
1 parent
00c3be28ba
commit
bc50eff52d
3 files changed
+8
-2
No files matched your search
+1
-1
@@ -346,7 +346,7 @@ void Board::MakeMove(Move move) {
|
|||||||
int targetPiece = GetPieceType(move.MoveTo());
|
int targetPiece = GetPieceType(move.MoveTo());
|
||||||
int direction = attackerColor ? south : north;
|
int direction = attackerColor ? south : north;
|
||||||
|
|
||||||
int newEpTarget = -1;
|
int newEpTarget = noEPTarget;
|
||||||
|
|
||||||
// Removing attacker piece from old position
|
// Removing attacker piece from old position
|
||||||
RemovePiece(attackerPiece, move.MoveFrom(), attackerColor);
|
RemovePiece(attackerPiece, move.MoveFrom(), attackerColor);
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
#include "move.h"
|
#include "move.h"
|
||||||
|
|
||||||
constexpr int nullPieceType = 100;
|
constexpr int nullPieceType = 100;
|
||||||
constexpr int noEPTarget = 100;
|
constexpr int noEPTarget = -1;
|
||||||
|
|
||||||
class Board {
|
class Board {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -481,11 +481,13 @@ static void GenPawnMoves(Board &board, bool color) {
|
|||||||
captures &= pinningRay;
|
captures &= pinningRay;
|
||||||
|
|
||||||
// Checking for en passant
|
// Checking for en passant
|
||||||
|
if (board.enPassantTarget != noEPTarget) {
|
||||||
if (captures.IsSet(board.enPassantTarget)) {
|
if (captures.IsSet(board.enPassantTarget)) {
|
||||||
if (IsLegalEnPassant(board, square)) {
|
if (IsLegalEnPassant(board, square)) {
|
||||||
board.AddMove(Move(square, board.enPassantTarget, epCapture));
|
board.AddMove(Move(square, board.enPassantTarget, epCapture));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Removing own pieces from capture mask
|
// Removing own pieces from capture mask
|
||||||
captures &= board.colors[!color];
|
captures &= board.colors[!color];
|
||||||
@@ -515,12 +517,14 @@ static void GenPawnMoves(Board &board, bool color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checking for en passant
|
// Checking for en passant
|
||||||
|
if (board.enPassantTarget != noEPTarget) {
|
||||||
if (captures.IsSet(board.enPassantTarget)) {
|
if (captures.IsSet(board.enPassantTarget)) {
|
||||||
// Checking if the move gives discovered check to own king
|
// Checking if the move gives discovered check to own king
|
||||||
if (IsLegalEnPassant(board, square)) {
|
if (IsLegalEnPassant(board, square)) {
|
||||||
board.AddMove(Move(square, board.enPassantTarget, epCapture));
|
board.AddMove(Move(square, board.enPassantTarget, epCapture));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Removing own pieces from capture mask
|
// Removing own pieces from capture mask
|
||||||
captures &= board.colors[!color];
|
captures &= board.colors[!color];
|
||||||
@@ -868,6 +872,7 @@ 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;
|
||||||
// Checking for en passant capture
|
// Checking for en passant capture
|
||||||
|
if (board.enPassantTarget != noEPTarget) {
|
||||||
Bitboard attackedSquare = pawnAttacks[color][square]
|
Bitboard attackedSquare = pawnAttacks[color][square]
|
||||||
& Bitboard::GetSquare(board.enPassantTarget);
|
& Bitboard::GetSquare(board.enPassantTarget);
|
||||||
if (attackedSquare) {
|
if (attackedSquare) {
|
||||||
@@ -883,6 +888,7 @@ static void GenCheckEvasions(Board &board, bool color) {
|
|||||||
captureMask.PopBit(targetSquare);
|
captureMask.PopBit(targetSquare);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pushes |= getPieceAttacks(square, type, color, board.occupied) & pushMask;
|
pushes |= getPieceAttacks(square, type, color, board.occupied) & pushMask;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user