src/chess/bishop.c

changeset 194
619f07c95894
parent 170
bde99d803caf
child 195
27d02ccb0cef
--- a/src/chess/bishop.c	Tue Aug 25 18:35:18 2026 +0200
+++ b/src/chess/bishop.c	Tue Aug 25 18:59:18 2026 +0200
@@ -32,17 +32,17 @@
 #include <stdlib.h>
 
 bool bishop_chkrules(const Move* move) {
-    return abs(move->torow-move->fromrow) == abs(move->tofile-move->fromfile);
+    return abs(move->torank-move->fromrank) == abs(move->tofile-move->fromfile);
 }
 
 bool bishop_isblocked(const GameState *gamestate, const Move *move) {
-    int dy = move->torow > move->fromrow ? 1 : -1;
+    int dy = move->torank > move->fromrank ? 1 : -1;
     int dx = move->tofile > move->fromfile ? 1 : -1;
     
-    uint8_t y = move->fromrow;
-    uint8_t x = move->fromfile;
+    Rank y = move->fromrank;
+    File x = move->fromfile;
     
-    while (x != move->tofile-dx && y != move->torow-dy) {
+    while (x != move->tofile-dx && y != move->torank-dy) {
         x += dx;
         y += dy;
         if (gamestate->board[y][x]) {
@@ -54,7 +54,7 @@
 }
 
 size_t bishop_moves(const GameState *gamestate,
-        Color c, Row r, File f, Move *moves) {
+        Color c, Rank r, File f, Move *moves) {
 
     size_t count = 0;
     const int directions[4][2] = {
@@ -65,20 +65,20 @@
     };
 
     for (size_t i = 0 ; i < 4 ; i++) {
-        int row = r + directions[i][0];
+        int rank = r + directions[i][0];
         int file = f + directions[i][1];
 
-        while (isidx(row) && isidx(file)) {
+        while (isidx(rank) && isidx(file)) {
             moves[count] = (Move){0};
             moves[count].piece = mkpiece(BISHOP, c);
-            moves[count].fromrow = r;
+            moves[count].fromrank = r;
             moves[count].fromfile = f;
-            moves[count].torow = row;
+            moves[count].torank = rank;
             moves[count].tofile = file;
-            moves[count].capture = piece_at(gamestate, row, file) != 0;
+            moves[count].capture = piece_at(gamestate, rank, file) != 0;
             count++;
 
-            row += directions[i][0];
+            rank += directions[i][0];
             file += directions[i][1];
         }
     }

mercurial