diff options
Diffstat (limited to 'src/board.c')
-rw-r--r-- | src/board.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/board.c b/src/board.c index fdafd2d..263e205 100644 --- a/src/board.c +++ b/src/board.c @@ -1,17 +1,6 @@ #include <stdio.h> #include "board.h" -void print_board(BoardUnit* board) { - for (int row = 0; row < BOARD_ROW_UNITS; row++) { - for (int i = 0; i < BOARD_ROW_UNITS; i++) { - int index = BOARD_ROW_UNITS * row + i; - if (board[index].feature == EMPTY && is_center_index(index)) printf("*"); - else printf("%c", board[index].feature); - } - printf("\n"); - } -} - void initialize_board(BoardUnit* board) { for (int i = 0; i < BOARD_UNITS; i++) { board[i].feature = EMPTY; @@ -30,7 +19,7 @@ int is_allowed_placement(Tile tile, int index, BoardUnit* board) { int neighbor_count = 0; for (int i = 0; i < 4; i++) { - char neighbor = board[index + neighbor_increments[i]].feature; + char neighbor = board[index + NEIGHBOR_INCREMENTS[i]].feature; if (neighbor != EMPTY) { if (neighbor != tile.edges[i]) return 0; neighbor_count++; @@ -53,7 +42,7 @@ int place_tile(Tile tile, int index, BoardUnit* board, int force) { board[index].feature = tile.center; for (int i = 0; i < 4; i++) { - board[index + neighbor_increments[i]].feature = tile.edges[i]; + board[index + NEIGHBOR_INCREMENTS[i]].feature = tile.edges[i]; } return 1; @@ -62,7 +51,7 @@ int place_tile(Tile tile, int index, BoardUnit* board, int force) { void traverse_structure(int group, int index, BoardUnit* board) { board[index].structure_group = group; for (int i = 0; i < 4; i++) { - int new_unit = index + neighbor_increments[i]; + int new_unit = index + NEIGHBOR_INCREMENTS[i]; if (board[new_unit].feature == board[index].feature && board[new_unit].structure_group == 0) { traverse_structure(group, new_unit, board); } @@ -99,7 +88,7 @@ int evaluate_structure(int index, BoardUnit* board) { int index = translate_coordinate(i * BOARD_WIDTH + j); if (board[index].feature != EMPTY) { // Empty tiles doesn't count for (int k = 0; k < 4; k++) { - if (board[index + neighbor_increments[k]].structure_group == structure_group) { + if (board[index + NEIGHBOR_INCREMENTS[k]].structure_group == structure_group) { printf("Found at tile %i\n", i * BOARD_WIDTH + j); value++; break; |