aboutsummaryrefslogtreecommitdiff
path: root/src/board.h
blob: f369743be75310eb183bb4ac3cc0d55d350fa7ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#define BOARD_WIDTH 7
#define BOARD_ROW_BYTES ((BOARD_WIDTH * 2) + 1)
#define BOARD_BYTES BOARD_ROW_BYTES * BOARD_ROW_BYTES


char EMPTY = ' ';

int neighbor_increments[] = {
  - BOARD_ROW_BYTES,
    1,
    BOARD_ROW_BYTES,
  - 1
};


/* structs */
typedef struct {
  char edges[4];
  char center;
} Tile;

/* board */
void initialize_board(char* board);
void print_board(char* board);
void write_board(char* board, char* filename);
void read_board(char* board, char* filename);

/* moves */
int is_allowed_placement(Tile tile, int index, char* board);
int translate_coordinate(int index);
int is_center_index(int index);
int place_tile(Tile tile, int index, char* board, int force);

/* structures */
void traverse_structure(char id, int index, char* board, char* structures);
void create_structure_mask(char* board, char* structures);
int evaluate_structure(int index, char* board, char* structures);