aboutsummaryrefslogtreecommitdiff
path: root/src/board.c
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-03-31 22:41:21 +0300
committereug-vs <eugene@eug-vs.xyz>2022-03-31 22:45:19 +0300
commit7dbd21f32c633e6c0c7fe9c55accda3bfc9fc88c (patch)
tree933a2df571f4cd782dd40baffcf55d733d590e42 /src/board.c
parent01d7e24b2c32d9350a11afa0e9ef677790c460d6 (diff)
downloadcarcassonne-engine-c-7dbd21f32c633e6c0c7fe9c55accda3bfc9fc88c.tar.gz
refactor: remove unused code
Diffstat (limited to 'src/board.c')
-rw-r--r--src/board.c19
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;