From 1b710b646b628fd7393057992fd634711767f209 Mon Sep 17 00:00:00 2001 From: rektdie Date: Mon, 24 Mar 2025 00:53:02 +0100 Subject: [PATCH] generating rook moves --- source/movegen.tpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/source/movegen.tpp b/source/movegen.tpp index 44161ec..28c31a6 100644 --- a/source/movegen.tpp +++ b/source/movegen.tpp @@ -142,6 +142,46 @@ void GenKnightMoves(Board &board) { } template 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 void GenBishopMoves(Board &board) {