fix that en passant captures do not work default tip

Tue, 21 Jul 2026 14:09:55 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 21 Jul 2026 14:09:55 +0200
changeset 151
f1b6a0388d85
parent 150
7d57a252948e

fix that en passant captures do not work

fixes #930

src/chess/rules.c file | annotate | diff | comparison | revisions
--- a/src/chess/rules.c	Sun Jul 19 19:17:04 2026 +0200
+++ b/src/chess/rules.c	Tue Jul 21 14:09:55 2026 +0200
@@ -358,10 +358,15 @@
         return RULES_VIOLATED;
     }
     
-    /* must capture, if and only if destination is occupied */
+    /* must capture, if and only if destination is occupied... */
     if ((mdst(gamestate->board, move) == 0 && move->capture) ||
             (mdst(gamestate->board, move) != 0 && !move->capture)) {
-        return INVALID_MOVE_SYNTAX;
+        /* ... or the capture happens en passant */
+        if (!move->capture || (move->piece & PIECE_MASK) != PAWN ||
+                !(gamestate->board[move->fromrow][move->tofile]
+                  & ENPASSANT_THREAT)) {
+            return INVALID_MOVE_SYNTAX;
+        }
     }
     
     /* validate individual rules */

mercurial