16 cout << (c == 0 ?
'.' : char(
'0' + c)) <<
" ";
28 do { x = rand() % 3; y = rand() % 3; }
while (p->
get_board_ptr()->get_board_matrix()[x][y] != 0);
29 val = np->isOdd ? (rand() % 5) * 2 + 1 : (rand() % 4) * 2 + 2;
30 cout <<
"\nComputer played " << val <<
" at (" << x <<
"," << y <<
")\n";
36 cout <<
"\n" << p->
get_name() <<
" enter row and column (0-2): ";
38 cout <<
"Enter a " << (np->isOdd ?
"odd" :
"even") <<
" number: ";
41 if (x < 0 || x > 2 || y < 0 || y > 2) { cout <<
"Invalid cell.\n";
continue; }
42 if (np->isOdd && val % 2 == 0) { cout <<
"You must use odd numbers.\n";
continue; }
43 if (!np->isOdd && val % 2 != 0) { cout <<
"You must use even numbers.\n";
continue; }
PlayerType
Represents the type of player in the game.
Definition BoardGame_Classes.h:24
@ COMPUTER
A computer-controlled player.
Definition BoardGame_Classes.h:26
Represents a single move in a board game.
Definition BoardGame_Classes.h:100
Definition Numerical_Player.h:4
Numerical_UI()
Definition Numerical_UI.h:10
Move< int > * get_move(Player< int > *p) override
Ask the user (or AI) to make a move.
Definition Numerical_UI.h:21
void display_board_matrix(const vector< vector< int > > &b) const
Definition Numerical_UI.h:12
Player< int > * create_player(string &n, int symbol, PlayerType t) override
Create a player object based on input name, symbol, and type.
Definition Numerical_UI.h:48
Base template for all players (human or AI).
Definition BoardGame_Classes.h:126
PlayerType get_type() const
Get player type (e.g., 'H' or 'C').
Definition BoardGame_Classes.h:147
Board< T > * get_board_ptr() const
Get a pointer to the game board.
Definition BoardGame_Classes.h:153
string get_name() const
Get the player's name.
Definition BoardGame_Classes.h:144
UI(string message, int cell_display_width)
Definition BoardGame_Classes.h:196