| 41 return rook_isblocked(gamestate, move); |
41 return rook_isblocked(gamestate, move); |
| 42 } else { |
42 } else { |
| 43 return bishop_isblocked(gamestate, move); |
43 return bishop_isblocked(gamestate, move); |
| 44 } |
44 } |
| 45 } |
45 } |
| |
46 |
| |
47 size_t queen_moves(GameState *gamestate, Color c, Row r, File f, Move *moves) { |
| |
48 size_t count = 0; |
| |
49 const int directions[8][2] = { |
| |
50 { 1, 0}, |
| |
51 {-1, 0}, |
| |
52 { 0, 1}, |
| |
53 { 0, -1}, |
| |
54 { 1, 1}, |
| |
55 { 1, -1}, |
| |
56 {-1, 1}, |
| |
57 {-1, -1} |
| |
58 }; |
| |
59 |
| |
60 for (size_t i = 0 ; i < 8 ; i++) { |
| |
61 int row = r + directions[i][0]; |
| |
62 int file = f + directions[i][1]; |
| |
63 |
| |
64 while (isidx(row) && isidx(file)) { |
| |
65 moves[count] = (Move){0}; |
| |
66 moves[count].piece = mkpiece(QUEEN, c); |
| |
67 moves[count].fromrow = r; |
| |
68 moves[count].fromfile = f; |
| |
69 moves[count].torow = row; |
| |
70 moves[count].tofile = file; |
| |
71 moves[count].capture = piece_at(gamestate, row, file) != 0; |
| |
72 count++; |
| |
73 |
| |
74 row += directions[i][0]; |
| |
75 file += directions[i][1]; |
| |
76 } |
| |
77 } |
| |
78 |
| |
79 return count; |
| |
80 } |