+int
+dvonn_board_pass (dvonn_board_t *board)
+{
+ /* XXX: Should check here and only allow a pass if there are
+ * no legal moves. */
+
+ dvonn_board_next_player (board);
+
+ return TRUE;
+}
+
+int
+dvonn_board_place (dvonn_board_t *board,
+ int x, int y,
+ char **error)
+{
+ if (board->phase != DVONN_PHASE_PLACEMENT) {
+ *error = "Cannot place outside of placement phase";
+ return FALSE;
+ }
+
+ if (board->cells[x][y].type != DVONN_CELL_EMPTY) {
+ *error = "Cannot place on an occupied space";
+ return FALSE;
+ }
+
+ if (board->moves < 3) {
+ board->cells[x][y].type = DVONN_CELL_RED;
+ board->cells[x][y].contains_red = TRUE;
+ } else if (board->moves % 2) {
+ board->cells[x][y].type = DVONN_CELL_BLACK;
+ } else {
+ board->cells[x][y].type = DVONN_CELL_WHITE;
+ }
+
+ board->cells[x][y].height = 1;
+
+ board->moves++;
+
+ dvonn_board_next_player (board);
+
+ if (board->moves == 49) {
+ board->phase = DVONN_PHASE_MOVEMENT;
+ board->moves = 0;
+ board->player = DVONN_PLAYER_WHITE;
+ }
+
+ return TRUE;
+}
+
+static void
+fill_living(dvonn_board_t *board,
+ int living[DVONN_BOARD_X_SIZE][DVONN_BOARD_Y_SIZE],
+ int x, int y)
+{
+ if (dvonn_board_cell_occupied (board, x, y) && ! living[x][y])
+ {
+ living[x][y] = 1;
+
+ fill_living (board, living, x - 1, y);
+ fill_living (board, living, x + 1, y);
+ fill_living (board, living, x, y - 1);
+ fill_living (board, living, x, y + 1);
+ fill_living (board, living, x + 1, y - 1);
+ fill_living (board, living, x - 1, y + 1);
+ }
+}
+
+static void
+eliminate_disconnected_stacks (dvonn_board_t *board)
+{
+ int x, y;
+ int living[DVONN_BOARD_X_SIZE][DVONN_BOARD_Y_SIZE];
+
+ for (x = 0; x < DVONN_BOARD_X_SIZE; x++)
+ for (y = 0; y < DVONN_BOARD_Y_SIZE; y++)
+ living[x][y] = 0;
+
+ for (x = 0; x < DVONN_BOARD_X_SIZE; x++)
+ for (y = 0; y < DVONN_BOARD_Y_SIZE; y++)
+ if (board->cells[x][y].contains_red)
+ fill_living (board, living, x, y);
+
+ for (x = 0; x < DVONN_BOARD_X_SIZE; x++)
+ for (y = 0; y < DVONN_BOARD_Y_SIZE; y++)
+ if (dvonn_board_cell_occupied (board, x, y) &&
+ ! living[x][y])
+ {
+ board->cells[x][y].type = DVONN_CELL_EMPTY;
+ board->cells[x][y].height = 0;
+ }
+}
+