-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboard.h
67 lines (52 loc) · 1.26 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
58
59
60
61
62
63
64
65
66
67
#include <vector>
#include <algorithm>
#include <utility>
#include <stack>
#ifndef BOARD_H
#define BOARD_H
typedef std::pair<int, int> position;
/**
* Class board. It handles the board functions and maintains the board status
* after each move.
**/
class board{
protected:
char bd[3][3];
public:
/**
* An enum
* The various states the board can be in at a point of time. CONTD signifies
* the game is not yet over.
**/
enum {
WIN,
DRAW,
CONTD,
INVALID
};
/**
* Constructor to initilize all values with a ' '
**/
board();
/**
* Check the status of the game at the point of the call.
* @param player The player whose status is to be checked
* @return Value from the enumeration.
**/
int check_status(char player);
/**
* Make a move on the board.
* @param player The player making the move. This could either be a 'X' or a 'O'
* @param pos The position where the player made the move.
* @return The current status of the board after the move is made.
**/
int make_move(char player, position pos);
/**
* Return the value at a position.
* @param pos position whose value is to be returned.
* @return The character at the position pos. ' ' if no player has played the
* box.
**/
char get_position(position pos);
};
#endif //MAIN_H