]> git.cworth.org Git - loudgame/blobdiff - loa-board.h
Add support for a 'history' command
[loudgame] / loa-board.h
index 4532e01f156c2d22c67ce7549e3c3f3d437cd517..4a4f690855fdd1541d365c29af262e6b5c0acfab 100644 (file)
@@ -40,6 +40,25 @@ typedef enum {
     LOA_CELL_EMPTY
 } loa_cell_t;
 
+typedef struct {
+    int x1; int y1;
+    int x2; int y2;
+    loa_bool_t is_capture;
+} loa_move_t;
+
+/* Return a string representation of a move. The return value is a
+ * pointer to a static buffer that will be reused from one call to the
+ * next. So the contents should be copied if needed. This function
+ * call is not thread-safe. */
+const char *
+loa_move_to_string (const loa_move_t *move);
+
+/* Initialize an loa_move_t structure based on a string value,
+ * (presumably the result of loa_move_to_string). Returns TRUE if
+ * successful. */
+loa_bool_t
+loa_move_init_from_string (loa_move_t *move, const char *string);
+
 /* The implementation of board_group_size depends on the square of
  * BOARD_SIZE being less than or equal to 64. */
 #define LOA_BOARD_SIZE 8
@@ -58,14 +77,29 @@ typedef struct {
     int diag_grave_pieces[LOA_DIAG_ARRAY_SIZE];
     int diag_acute_pieces[LOA_DIAG_ARRAY_SIZE];
 
+    int num_moves;
+    loa_move_t *moves;
+    int moves_size;
+
     loa_player_t player;
 } loa_board_t;
 
-/* Initialize a board for a new game of Lines of Action. The 12 pieces
+/* Initialize an loa_board_t structure. This function must be called
+ * before passing the board to any other loa_board function. It will
+ * implicitly call loa_board_reset for you. When you are finished
+ * using the board, you should call loa_board_fini. */
+void
+loa_board_init (loa_board_t *board);
+
+/* Free all resources associated with a board. */
+void
+loa_board_fini (loa_board_t *board);
+
+/* Reset board for a new game of Lines of Action. The 12 pieces
  * for black and white will be put in their initial places and black
  * will be set as the current player. */
 void
-loa_board_init (loa_board_t *board);
+loa_board_reset (loa_board_t *board);
 
 /* Does the square at (x,y) belong to a winning group? That is, is
  * there a piece at (x,y) that is 8-way connected to all pieces on the