2 * Copyright (C) 2008 Carl Worth
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see http://www.gnu.org/licenses/ .
17 * Author: Carl Worth <cworth@cworth.org>
23 typedef int loa_bool_t;
38 LOA_CELL_BLACK = LOA_PLAYER_BLACK,
39 LOA_CELL_WHITE = LOA_PLAYER_WHITE,
43 /* The implementation of board_group_size depends on the square of
44 * BOARD_SIZE being less than or equal to 64. */
45 #define LOA_BOARD_SIZE 8
46 #define LOA_DIAG_ARRAY_SIZE (2 * LOA_BOARD_SIZE - 1)
49 loa_cell_t cells[LOA_BOARD_SIZE][LOA_BOARD_SIZE];
51 /* Number of black and white pieces */
54 /* Number of pieces (of either color) in each row, column, and
56 int row_pieces[LOA_BOARD_SIZE];
57 int col_pieces[LOA_BOARD_SIZE];
58 int diag_grave_pieces[LOA_DIAG_ARRAY_SIZE];
59 int diag_acute_pieces[LOA_DIAG_ARRAY_SIZE];
64 /* Initialize a board for a new game of Lines of Action. The 12 pieces
65 * for black and white will be put in their initial places and black
66 * will be set as the current player. */
68 loa_board_init (loa_board_t *board);
70 /* Does the square at (x,y) belong to a winning group? That is, is
71 * there a piece at (x,y) that is 8-way connected to all pieces on the
72 * board of the same color. */
74 loa_board_is_won (loa_board_t *board, int x, int y);
76 /* Move a piece from (x1,y1) to (x2,y2) where (0,0) is at the
77 * upper-left corner of the board. Returns TRUE if the move is legal
78 * and is performed. If the move is not legal this function returns
79 * FALSE, no change will be performed on the board, and *error will be
80 * set to a string describing why the move is illegal.*/
82 loa_board_move (loa_board_t *board,
87 /* Execute a 'pass'---changing the player-to-move from the current
88 * player to the opponent. Returns TRUE if the pass is executed. Will
89 * eventually return FALSE if the current player has a legal move that
90 * could be made, but this is not yet implemented.
93 loa_board_pass (loa_board_t *board);
95 /* Allocate a new string showing the state of the current board.
96 * When finsihed, the called should free() the resulting value.
99 loa_board_to_string (loa_board_t *board);