-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame_state.h
More file actions
36 lines (25 loc) · 840 Bytes
/
game_state.h
File metadata and controls
36 lines (25 loc) · 840 Bytes
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
#ifndef GAMESTATE_H
#define GAMESTATE_H
class GameState
{
public:
GameState();
void reset();
bool position_empty(int position) const;
char get_value(int position) const;
/* Return 'X', 'O' or ' ' depending on the state of the corresponding position.
'X' represents the player making the first move, 'O' the player making
second move and ' ' that the position is empty.*/
void make_move(int position);
void undo_move(int position);
bool three_in_a_row(int position) const;
/* Return true if there is a three in a rown through the given
position and false if not. It is assumed that the given
position is not empty.*/
bool board_full() const;
int get_number_of_empty_positions() const;
private:
char board[9];
int number_of_empty_positions;
};
#endif