-
Notifications
You must be signed in to change notification settings - Fork 0
/
board.hpp
62 lines (45 loc) · 1.38 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
52
53
54
55
56
57
58
59
60
61
62
#ifndef INCLUDE_ROADAGAIN_BOARD
#define INCLUDE_ROADAGAIN_BOARD
#include "point.hpp"
#include "cell.hpp"
#include "cellcolor.hpp"
namespace roadagain
{
class Board
{
public:
Board();
Board(const Board& board);
~Board();
void print(const Point& p = Point(0, 0)) const;
void put(const Cell& cell, bool print_flag = true);
int reverse_num(const Cell& cell) const;
int reverse_num(const Cell& cell, const Point& d) const;
int count_neighbor(const Point& p, const CellColor& stone);
int black() const;
int white() const;
void copy_matrix(CellColor** matrix) const;
CellColor winner() const;
bool in_board(const Point& p) const;
bool empty(const Point& p) const;
bool can_put(const CellColor& stone) const;
bool can_put(const Cell& cell) const;
static const int ROW = 8;
static const int COL = 8;
static const int DEFAULT_STONE = 4;
static const int MAX_PUT = ROW * COL - DEFAULT_STONE;
static const Point START;
static const Point END;
static const int NEIGHBOR = 8;
static const Point D[NEIGHBOR];
private:
void update_counter();
void reverse(const Cell& cell, bool print_flag);
void reverse(const Cell& stone, const Point& d, bool print_flag);
bool can_put(const Cell& stone, const Point& d) const;
CellColor** matrix_;
int black_;
int white_;
};
} // namespace roadagain
#endif