src/chess/knight.c

changeset 194
619f07c95894
parent 170
bde99d803caf
child 195
27d02ccb0cef
--- a/src/chess/knight.c	Tue Aug 25 18:35:18 2026 +0200
+++ b/src/chess/knight.c	Tue Aug 25 18:59:18 2026 +0200
@@ -33,13 +33,13 @@
 
 bool knight_chkrules(const Move *move) {
     int dx = abs(move->fromfile - move->tofile);
-    int dy = abs(move->fromrow - move->torow);
+    int dy = abs(move->fromrank - move->torank);
     
     return (dx == 2 && dy == 1) || (dx == 1 && dy == 2);
 }
 
 size_t knight_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 offsets[8][2] = {
@@ -54,17 +54,17 @@
     };
 
     for (size_t i = 0 ; i < 8 ; i++) {
-        int row = r + offsets[i][0];
-        int file = f + offsets[i][1];
+        Rank rank = r + offsets[i][0];
+        File file = f + offsets[i][1];
 
-        if (isidx(row) && isidx(file)) {
+        if (isidx(rank) && isidx(file)) {
             moves[count] = (Move){0};
             moves[count].piece = mkpiece(KNIGHT, 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++;
         }
     }

mercurial