-
Notifications
You must be signed in to change notification settings - Fork 0
/
board.h
57 lines (42 loc) · 1.16 KB
/
board.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* Michael Hanna, mwhanna
* CS 152, Spring 2017
* Project 1
*/
#include "pos.h"
void binary_int(unsigned int n);
/*a square, either empty, black, or white*/
enum square {
EMPTY,
BLACK,
WHITE
};
typedef enum square square;
/*a board representation, either done with enums or bits*/
union board_rep {
enum square** cells;
unsigned int* bits;
};
typedef union board_rep board_rep;
/*a tag to store the kind of board representation being used*/
enum type {
CELLS, BITS
};
/*a board with a board representation, tag for the rep, and # rows /cols*/
struct board {
unsigned int nrows, ncols;
enum type type;
board_rep u;
};
typedef struct board board;
/*creates a new nrows by ncols board with the given certain type of rep*/
board* board_new(unsigned int nrows, unsigned int ncols, enum type type);
/*frees the given board*/
void board_free(board* b);
/*prints the given board*/
void board_show(board* b);
/*gets a square from the board given a pos*/
square board_get(board* b, pos p);
/*sets a square at pos p to the given square s*/
void board_set(board* b, pos p, square s);
/*prints a label given an index*/
void print_label(unsigned n);