src/chess/rules.c

changeset 169
9962f5d98764
parent 168
663676cfef6e
child 170
bde99d803caf
--- a/src/chess/rules.c	Sun Aug 02 15:19:47 2026 +0200
+++ b/src/chess/rules.c	Thu Aug 06 14:45:55 2026 +0200
@@ -1135,3 +1135,20 @@
     // TODO: implement threefold repetition detection
     return false;
 }
+
+size_t filter_moves_allowed(GameState *gamestate,
+        Color c, Row r, File f, Move *moves, moves_generator_func func) {
+
+    /* worst case: the queen has the most moves */
+    Move candidates[QUEEN_MOVES_MAX];
+    size_t candidatecount = func(gamestate, c, r, f, candidates);
+    size_t count = 0;
+
+    for (size_t i = 0 ; i < candidatecount ; i++) {
+        if (validate_move(gamestate, &candidates[i]) == VALID_MOVE_SEMANTICS) {
+            moves[count++] = candidates[i];
+        }
+    }
+
+    return count;
+}
\ No newline at end of file

mercurial