10 for (
int i = 0; i < 3; i++)
11 for (
int j = 0; j < 3; j++)
13 score_x = score_o = 0;
19 for (
int r = 0; r < 3; r++)
23 for (
int col = 0; col < 3; col++)
24 if (
board[0][col] ==
'X' &&
board[1][col] ==
'O' &&
board[2][col] ==
'X')
27 if (
board[0][0] ==
'X' &&
board[1][1] ==
'O' &&
board[2][2] ==
'X') c++;
28 if (
board[0][2] ==
'X' &&
board[1][1] ==
'O' &&
board[2][0] ==
'X') c++;
37 if (x < 0 || x >= 3 || y < 0 || y >= 3)
return false;
38 if (
board[x][y] !=
' ')
return false;
55 if (!
full())
return false;
56 if (p->
get_symbol() ==
'X' && score_x > score_o)
return true;
57 if (p->
get_symbol() ==
'O' && score_o > score_x)
return true;
62 if (!
full())
return false;
63 if (p->
get_symbol() ==
'X' && score_o > score_x)
return true;
64 if (p->
get_symbol() ==
'O' && score_x > score_o)
return true;
69 return full() && score_x == score_o;
int n_moves
Definition BoardGame_Classes.h:45
Board(int rows, int columns)
Definition BoardGame_Classes.h:51
vector< vector< char > > board
Definition BoardGame_Classes.h:44
Represents a single move in a board game.
Definition BoardGame_Classes.h:100
T get_symbol() const
Get the move symbol.
Definition BoardGame_Classes.h:116
int get_y() const
Get column index.
Definition BoardGame_Classes.h:113
int get_x() const
Get row index.
Definition BoardGame_Classes.h:110
Base template for all players (human or AI).
Definition BoardGame_Classes.h:126
T get_symbol() const
Get the player's symbol.
Definition BoardGame_Classes.h:150
SUSBoard()
Definition SUSBoard.h:9
int count_xux()
Definition SUSBoard.h:16
bool full()
Definition SUSBoard.h:50
bool update_board(Move< char > *m) override
Update the board with a new move.
Definition SUSBoard.h:33
vector< vector< char > > get_board_matrix() const
Definition SUSBoard.h:76
bool is_lose(Player< char > *p) override
Check if a player has lost.
Definition SUSBoard.h:61
bool is_draw(Player< char > *p) override
Check if the game ended in a draw.
Definition SUSBoard.h:68
bool game_is_over(Player< char > *p) override
Check if the game is over.
Definition SUSBoard.h:72
bool is_win(Player< char > *p) override
Check if a player has won.
Definition SUSBoard.h:54