| 52 |
52 |
| 53 return false; |
53 return false; |
| 54 } |
54 } |
| 55 |
55 |
| 56 size_t bishop_moves(const GameState *gamestate, |
56 size_t bishop_moves(const GameState *gamestate, |
| 57 Color c, Rank r, File f, Move *moves) { |
57 Color c, File f, Rank r, Move *moves) { |
| 58 |
58 |
| 59 size_t count = 0; |
59 size_t count = 0; |
| 60 const int directions[4][2] = { |
60 const int directions[4][2] = { |
| 61 { 1, 1}, |
61 { 1, 1}, |
| 62 { 1, -1}, |
62 { 1, -1}, |
| 73 moves[count].piece = mkpiece(BISHOP, c); |
73 moves[count].piece = mkpiece(BISHOP, c); |
| 74 moves[count].fromrank = r; |
74 moves[count].fromrank = r; |
| 75 moves[count].fromfile = f; |
75 moves[count].fromfile = f; |
| 76 moves[count].torank = rank; |
76 moves[count].torank = rank; |
| 77 moves[count].tofile = file; |
77 moves[count].tofile = file; |
| 78 moves[count].capture = piece_at(gamestate, rank, file) != 0; |
78 moves[count].capture = piece_at(gamestate, file, rank) != 0; |
| 79 count++; |
79 count++; |
| 80 |
80 |
| 81 rank += directions[i][0]; |
81 rank += directions[i][0]; |
| 82 file += directions[i][1]; |
82 file += directions[i][1]; |
| 83 } |
83 } |