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 dvonn_bool_t;
38 DVONN_CELL_BLACK = DVONN_PLAYER_BLACK,
39 DVONN_CELL_WHITE = DVONN_PLAYER_WHITE,
46 dvonn_cell_type_t type;
48 dvonn_bool_t contains_red;
51 #define DVONN_BOARD_X_SIZE 11
52 #define DVONN_BOARD_Y_SIZE 5
55 DVONN_PHASE_PLACEMENT,
60 dvonn_cell_t cells[DVONN_BOARD_X_SIZE][DVONN_BOARD_Y_SIZE];
62 dvonn_player_t player;
66 /* Initialize a board for a new game of DVONN. */
68 dvonn_board_init (dvonn_board_t *board);
70 /* Place a piece at (x,y) where (0,0) is at the upper-left corner of
71 * the board. Returns TRUE if the move is legal and is performed. If
72 * the move is not legal this function returns FALSE, no change will
73 * be performed on the board, and *error will be set to a string
74 * describing why the move is illegal.*/
76 dvonn_board_place (dvonn_board_t *board,
80 /* Move a piece from (x1,y1) to (x2,y2) where (0,0) is at the
81 * upper-left corner of the board. Returns TRUE if the move is legal
82 * and is performed. If the move is not legal this function returns
83 * FALSE, no change will be performed on the board, and *error will be
84 * set to a string describing why the move is illegal.*/
86 dvonn_board_move (dvonn_board_t *board,
91 /* Pass rather than moving, allowing the turn to pass to the
92 * opponent. This should only be allowed if there are no legal moves,
93 * but that is not yet enforced. Returns TRUE if the pass succeeds. */
95 dvonn_board_pass (dvonn_board_t *board);
97 /* Is the cell at (x,y) occupied by a piece. Returns FALSE for all
98 * out-of-bounds coordinates. */
100 dvonn_board_cell_occupied (dvonn_board_t *board,
103 /* Is the cell at (x,y) surrounded by other pieces, (such that it is
104 * not legal for a piece at (x,y) to move. */
106 dvonn_board_cell_surrounded (dvonn_board_t *board,