-
Notifications
You must be signed in to change notification settings - Fork 1
/
Board.hpp
51 lines (38 loc) · 1.15 KB
/
Board.hpp
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
#ifndef BOARD_H
#define BOARD_H
#include <string>
#include <utility>
#include <vector>
#include <Eigen/Core>
#include "Piece.hpp"
using namespace std;
/*
Stores a board, including placed pieces.
*/
class Board
{
public:
Board(string boardfilename = string("gamedata/board"));
bool placePiece(Piece pc, int row, int col);
/*
The state of the board is stored in the array barray
as follows:
Value: Meaning:
0-11 Pieces A-L
12 border/forbidden
13 empty
Add a buffer on the right and lower edges so that
we can place pieces without taking care of the boundaries.
*/
enum {BORDER = 12, EMPTY = 13};
static const int rows = 14;
static const int cols = 20;
static const int buffer = 8;
Matrix<int8_t, rows+buffer, cols+buffer> barray;
/* Keep track of which pieces we have placed. */
bool pieceplaced[12];
bool isFull(); // true if all 12 pieces are placed
Matrix<int8_t, 4, 6> freeSpaces(); // return free spaces
};
ostream& operator<<(ostream& os, const Board& p);
#endif