bugfix: capture promotions didnt work as intended
This commit is contained in:
1 parent
9d3de4ecdc
commit
bd2b7c956c
1 file changed
+11
-3
+11
-3
@@ -472,6 +472,8 @@ static void GenPawnMoves(Board &board, bool color) {
|
||||
Bitboard pushes = getPawnPushes(square, color, board.occupied);
|
||||
Bitboard captures = pawnAttacks[color][square];
|
||||
|
||||
Bitboard lastRank = color ? ranks[r_1] : ranks[r_8];
|
||||
|
||||
if (IsPinned(board, square)) {
|
||||
int kingSquare = (board.colors[color] & board.pieces[King]).getLS1BIndex();
|
||||
int directionToKing = GetDirection(square, kingSquare);
|
||||
@@ -507,7 +509,15 @@ static void GenPawnMoves(Board &board, bool color) {
|
||||
while (captures) {
|
||||
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);
|
||||
}
|
||||
@@ -529,8 +539,6 @@ static void GenPawnMoves(Board &board, bool color) {
|
||||
// Removing own pieces from capture mask
|
||||
captures &= board.colors[!color];
|
||||
|
||||
Bitboard lastRank = color ? ranks[r_1] : ranks[r_8];
|
||||
|
||||
while (pushes) {
|
||||
int pushSquare = pushes.getLS1BIndex();
|
||||
|
||||
|
||||
Reference in new issue
Block a user