generating rook moves

This commit is contained in:
rektdie committed 2025-03-24 00:53:02 +01:00
1 parent 887231df68
commit 1b710b646b
1 file changed
+40
+40
View File
@@ -142,6 +142,46 @@ void GenKnightMoves(Board &board) {
}
template <MovegenMode mode>
void GenRookMoves(Board &board) {
Bitboard rooks = board.colors[board.sideToMove] & board.pieces[Rook];
while (rooks) {
int square = rooks.getLS1BIndex();
Bitboard moves = getRookAttack(square, board.occupied) & ~board.colors[board.sideToMove];
Bitboard captures = moves & board.colors[!board.sideToMove];
moves &= ~captures;
if constexpr (mode == Noisy) {
while (captures) {
int targetSquare = captures.getLS1BIndex();
board.AddMove(Move(square, targetSquare, capture));
captures.PopBit(targetSquare);
}
rooks.PopBit(square);
continue;
}
while (moves) {
int targetSquare = moves.getLS1BIndex();
board.AddMove(Move(square, targetSquare, quiet));
moves.PopBit(targetSquare);
}
while (captures) {
int targetSquare = captures.getLS1BIndex();
board.AddMove(Move(square, targetSquare, capture));
captures.PopBit(targetSquare);
}
rooks.PopBit(square);
}
}
template <MovegenMode mode>
void GenBishopMoves(Board &board) {