+dvonn_bool_t
+dvonn_board_cell_occupied (dvonn_board_t *board,
+ int x, int y)
+{
+ if (x < 0 || x >= DVONN_BOARD_X_SIZE ||
+ y < 0 || y >= DVONN_BOARD_Y_SIZE)
+ {
+ return FALSE;
+ }
+
+ if (board->cells[x][y].type == DVONN_CELL_INVALID ||
+ board->cells[x][y].type == DVONN_CELL_EMPTY)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+dvonn_bool_t
+dvonn_board_cell_surrounded (dvonn_board_t *board,
+ int x, int y)
+{
+ int surround_count;
+
+ surround_count =
+ dvonn_board_cell_occupied (board, x - 1, y) +
+ dvonn_board_cell_occupied (board, x + 1, y) +
+ dvonn_board_cell_occupied (board, x, y - 1) +
+ dvonn_board_cell_occupied (board, x, y + 1) +
+ dvonn_board_cell_occupied (board, x + 1, y - 1) +
+ dvonn_board_cell_occupied (board, x - 1, y + 1);
+
+ return (surround_count == 6);
+}
+