src/chess/pawn.c

changeset 195
27d02ccb0cef
parent 194
619f07c95894
--- a/src/chess/pawn.c	Tue Aug 25 18:59:18 2026 +0200
+++ b/src/chess/pawn.c	Tue Aug 25 19:42:15 2026 +0200
@@ -53,8 +53,9 @@
             move->fromfile == move->tofile + 1 ||
             move->fromfile == move->tofile - 1)) {
 
-            return piece_at(gamestate, move->torank, move->tofile) ||
-                enpassant_threat_exists(gamestate, move->fromrank, move->tofile);
+            return piece_at(gamestate, move->tofile, move->torank) ||
+                enpassant_threat_exists(gamestate,
+                    move->tofile, move->fromrank);
         } else {
             return false;
         }
@@ -72,16 +73,16 @@
 bool pawn_isblocked(const GameState *gamestate, const Move *move) {
     if (move->torank == move->fromrank + 1
         || move->torank == move->fromrank - 1) {
-        return piece_at(gamestate, move->torank, move->tofile)
+        return piece_at(gamestate, move->tofile, move->torank)
             && !move->capture;
     } else {
-        return piece_at(gamestate, move->torank, move->tofile) ||
+        return piece_at(gamestate, move->tofile, move->torank) ||
             gamestate->board[(move->fromrank + move->torank) / 2][move->tofile];
     }
 }
 
 size_t pawn_moves(const GameState *gamestate,
-        Color c, Rank r, File f, Move *moves) {
+        Color c, File f, Rank r, Move *moves) {
     (void) gamestate; /* no (theoretical) move depends on the game state */
     size_t count = 0;
     int rankdelta = c == WHITE ? 1 : -1;

mercurial