bugfix: capture promotions didnt work as intended

This commit is contained in:
rektdie committed 2025-03-09 09:37:39 +01:00
1 parent 9d3de4ecdc
commit bd2b7c956c
1 file changed
+11 -3
+11 -3
View File
@@ -472,6 +472,8 @@ static void GenPawnMoves(Board &board, bool color) {
Bitboard pushes = getPawnPushes(square, color, board.occupied); Bitboard pushes = getPawnPushes(square, color, board.occupied);
Bitboard captures = pawnAttacks[color][square]; Bitboard captures = pawnAttacks[color][square];
Bitboard lastRank = color ? ranks[r_1] : ranks[r_8];
if (IsPinned(board, square)) { if (IsPinned(board, square)) {
int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex(); int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex();
int directionToKing = GetDirection(square, kingSquare); int directionToKing = GetDirection(square, kingSquare);
@@ -507,7 +509,15 @@ static void GenPawnMoves(Board &board, bool color) {
while (captures) { while (captures) {
int targetSquare = captures.getLS1BIndex(); int targetSquare = captures.getLS1BIndex();
board.AddMove(Move(square, targetSquare, capture)); // Checking for promotion
if (lastRank.IsSet(targetSquare)) {
board.AddMove(Move(square, targetSquare, knightPromoCapture));
board.AddMove(Move(square, targetSquare, bishopPromoCapture));
board.AddMove(Move(square, targetSquare, rookPromoCapture));
board.AddMove(Move(square, targetSquare, queenPromoCapture));
} else {
board.AddMove(Move(square, targetSquare, capture));
}
captures.PopBit(targetSquare); captures.PopBit(targetSquare);
} }
@@ -529,8 +539,6 @@ static void GenPawnMoves(Board &board, bool color) {
// Removing own pieces from capture mask // Removing own pieces from capture mask
captures &= board.colors[!color]; captures &= board.colors[!color];
Bitboard lastRank = color ? ranks[r_1] : ranks[r_8];
while (pushes) { while (pushes) {
int pushSquare = pushes.getLS1BIndex(); int pushSquare = pushes.getLS1BIndex();