Enpassant fix #6
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:
|
||||||
|
|||||||
+25
-19
@@ -481,9 +481,11 @@ static void GenPawnMoves(Board &board, bool color) {
|
|||||||
captures &= pinningRay;
|
captures &= pinningRay;
|
||||||
|
|
||||||
// Checking for en passant
|
// Checking for en passant
|
||||||
if (captures.IsSet(board.enPassantTarget)) {
|
if (board.enPassantTarget != noEPTarget) {
|
||||||
if (IsLegalEnPassant(board, square)) {
|
if (captures.IsSet(board.enPassantTarget)) {
|
||||||
board.AddMove(Move(square, board.enPassantTarget, epCapture));
|
if (IsLegalEnPassant(board, square)) {
|
||||||
|
board.AddMove(Move(square, board.enPassantTarget, epCapture));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,10 +517,12 @@ static void GenPawnMoves(Board &board, bool color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checking for en passant
|
// Checking for en passant
|
||||||
if (captures.IsSet(board.enPassantTarget)) {
|
if (board.enPassantTarget != noEPTarget) {
|
||||||
// Checking if the move gives discovered check to own king
|
if (captures.IsSet(board.enPassantTarget)) {
|
||||||
if (IsLegalEnPassant(board, square)) {
|
// Checking if the move gives discovered check to own king
|
||||||
board.AddMove(Move(square, board.enPassantTarget, epCapture));
|
if (IsLegalEnPassant(board, square)) {
|
||||||
|
board.AddMove(Move(square, board.enPassantTarget, epCapture));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,19 +872,21 @@ 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
|
||||||
Bitboard attackedSquare = pawnAttacks[color][square]
|
if (board.enPassantTarget != noEPTarget) {
|
||||||
& Bitboard::GetSquare(board.enPassantTarget);
|
Bitboard attackedSquare = pawnAttacks[color][square]
|
||||||
if (attackedSquare) {
|
& Bitboard::GetSquare(board.enPassantTarget);
|
||||||
// Checking if it's legal
|
if (attackedSquare) {
|
||||||
if (IsLegalEnPassant(board, square)) {
|
// Checking if it's legal
|
||||||
int direction = color ? south : north;
|
if (IsLegalEnPassant(board, square)) {
|
||||||
int targetSquare = captureMask.getLS1BIndex() + direction;
|
int direction = color ? south : north;
|
||||||
captureMask.SetBit(targetSquare);
|
int targetSquare = captureMask.getLS1BIndex() + direction;
|
||||||
if ((attackedSquare & pushMask)
|
captureMask.SetBit(targetSquare);
|
||||||
|| (attackedSquare & captureMask)) {
|
if ((attackedSquare & pushMask)
|
||||||
board.AddMove(Move(square, board.enPassantTarget, epCapture));
|
|| (attackedSquare & captureMask)) {
|
||||||
|
board.AddMove(Move(square, board.enPassantTarget, epCapture));
|
||||||
|
}
|
||||||
|
captureMask.PopBit(targetSquare);
|
||||||
}
|
}
|
||||||
captureMask.PopBit(targetSquare);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user