src/chess/rules.h

changeset 182
04c65336777f
parent 181
8bda076d0a16
--- a/src/chess/rules.h	Sat Aug 22 15:15:52 2026 +0200
+++ b/src/chess/rules.h	Sat Aug 22 16:22:05 2026 +0200
@@ -91,19 +91,18 @@
 };
 
 typedef struct {
+    char string[8];
+    struct movetimeval timestamp; /* TODO: remove this from the struct */
+    uint64_t movetime; /* the time for this move in microseconds */
     Piece piece;
     File fromfile;
     Row fromrow;
     File tofile;
     Row torow;
     Piece promotion;
-    uint8_t check; /* must always be set if checkmate is set */
-    uint8_t checkmate;
-    uint8_t capture;
-    uint8_t padding[7]; /* necessary for stable ABI across networks */
-    struct movetimeval timestamp; /* TODO: remove this from the struct */
-    uint64_t movetime; /* the time for this move in microseconds */
-    char string[8];
+    bool check; /* must always be set if checkmate is set */
+    bool checkmate;
+    bool capture;
 } Move;
 
 typedef struct {
@@ -489,7 +488,7 @@
  * evaluating the allowed moves according to the current game state.
  *
  * This function expects correct notation of check and checkmate indicators.
- * For a more lazy evaluation, use eval_move_lazy().
+ * For a more lazy evaluation, use eval_move().
  *
  * For a purely syntactic check, regardless of whether a piece exists that is
  * allowed to move that way, use check_move().
@@ -500,30 +499,42 @@
  * @param move a pointer to object where the move data shall be stored
  * @return status code (see macros in this file for the list of codes)
  */
+int eval_move_strict(const GameState *gamestate,
+    const char *mstr, Color color, Move *move);
+
+/**
+ * Evaluates a move syntactically and stores the move data in the specified
+ * object.
+ *
+ * When short algebraic notation is used, the source position is determined by
+ * evaluating the allowed moves according to the current game state.
+ *
+ * This function automatically corrects missing or incorrect check/checkmate
+ * indicators. Use eval_move_strict() if you want to keep the original notation.
+ *
+ * For a purely syntactic check, regardless of whether a piece exists that is
+ * allowed to move that way, use check_move().
+ *
+ * @param gamestate the current game state
+ * @param mstr the input string to parse
+ * @param color the color of the player to evaluate the move for
+ * @param move a pointer to object where the move data shall be stored
+ * @return status code (see macros in this file for the list of codes)
+ */
 int eval_move(const GameState *gamestate,
     const char *mstr, Color color, Move *move);
 
 /**
- * Evaluates a move syntactically and stores the move data in the specified
- * object.
- *
- * When short algebraic notation is used, the source position is determined by
- * evaluating the allowed moves according to the current game state.
+ * Calculates the move string within the specified move.
  *
- * This function automatically corrects missing or incorrect check/checkmate
- * indicators. Use eval_move() if you want to keep the original notation.
+ * This corrects any missing check / checkmate flags, first.
  *
- * For a purely syntactic check, regardless of whether a piece exists that is
- * allowed to move that way, use check_move().
+ * Do not call this function after eval_move() or eval_move_strict().
  *
  * @param gamestate the current game state
- * @param mstr the input string to parse
- * @param color the color of the player to evaluate the move for
- * @param move a pointer to object where the move data shall be stored
- * @return status code (see macros in this file for the list of codes)
+ * @param move the move data
  */
-int eval_move_lazy(const GameState *gamestate,
-    const char *mstr, Color color, Move *move);
+void format_move(const GameState *gamestate, Move *move);
 
 /**
  * Syntactically checks a move without verifying that a piece exists that is

mercurial