--- a/src/chess/rook.c Sun Aug 02 15:19:47 2026 +0200 +++ b/src/chess/rook.c Thu Aug 06 14:45:55 2026 +0200 @@ -58,3 +58,34 @@ return false; } + +size_t rook_moves(GameState *gamestate, Color c, Row r, File f, Move *moves) { + size_t count = 0; + const int directions[4][2] = { + { 1, 0}, + {-1, 0}, + { 0, 1}, + { 0, -1} + }; + + for (size_t i = 0 ; i < 4 ; i++) { + int row = r + directions[i][0]; + int file = f + directions[i][1]; + + while (isidx(row) && isidx(file)) { + moves[count] = (Move){0}; + moves[count].piece = mkpiece(ROOK, c); + moves[count].fromrow = r; + moves[count].fromfile = f; + moves[count].torow = row; + moves[count].tofile = file; + moves[count].capture = piece_at(gamestate, row, file) != 0; + count++; + + row += directions[i][0]; + file += directions[i][1]; + } + } + + return count; +}