OOP A3 Board Games

AUTHOR
Version 35

Table of Contents

Table of contents

Hierarchical Index
Class Hierarchy
This inheritance list is sorted roughly, but not completely, alphabetically:
Board< T > 	pagenum
Board< char > 	pagenum
DiamondTicTacToeBoard 	pagenum
FourBoard 	pagenum
FourInARowBoard 	pagenum
InfinityTicTacToeBoard 	pagenum
MemoryTicTacToeBoard 	pagenum
MisereTicTacToe_Board 	pagenum
ObstaclesTicTacToeBoard 	pagenum
Pyramic_XO_Board 	pagenum
SUSBoard 	pagenum
SUS_Board 	pagenum
TicTacToe4x4_Board 	pagenum
TicTacToe5x5_Board 	pagenum
UltimateTicTacToeBoard 	pagenum
XO_Board 	pagenum
word_Board 	pagenum

Board< int > 	pagenum
NumericalTicTacToeBoard 	pagenum
Numerical_Board 	pagenum

GameManager< T > 	pagenum
Move< T > 	pagenum
Player< T > 	pagenum
Player< char > 	pagenum
DiamondTicTacToe_Player 	pagenum
DiamondTicTacToe_RandomPlayer 	pagenum
FourInARowPlayer 	pagenum
FourInARowRandomPlayer 	pagenum
InfinityTicTacToe_Player 	pagenum
InfinityTicTacToe_RandomPlayer 	pagenum
MemoryTicTacToe_Player 	pagenum
MemoryTicTacToe_RandomPlayer 	pagenum
MisereTicTacToe_Player 	pagenum
MisereTicTacToe_RandomPlayer 	pagenum
ObstaclesTicTacToe_Player 	pagenum
ObstaclesTicTacToe_RandomPlayer 	pagenum
Pyramic_XO_Player 	pagenum
Pyramic_XO_RandomPlayer 	pagenum
SUS_Player 	pagenum
SUS_Random_Player 	pagenum
TicTacToe4x4_Player 	pagenum
TicTacToe5x5_Player 	pagenum
TicTacToe5x5_RandomPlayer 	pagenum
UltimateTicTacToe_Player 	pagenum
UltimateTicTacToe_RandomPlayer 	pagenum
XO_Player 	pagenum
XO_Random_Player 	pagenum
word_Player 	pagenum
word_Random_Player 	pagenum

Player< int > 	pagenum
NumericalTicTacToePlayer 	pagenum
NumericalTicTacToeRandomPlayer 	pagenum
Numerical_Player 	pagenum

UI< T > 	pagenum
UI< char > 	pagenum
DiamondTicTacToe_UI 	pagenum
FourInARowUI 	pagenum
FourUI 	pagenum
InfinityTicTacToe_UI 	pagenum
MemoryTicTacToe_UI 	pagenum
MisereTicTacToe_UI 	pagenum
ObstaclesTicTacToe_UI 	pagenum
Pyramic_XO_UI 	pagenum
SUSUI 	pagenum
SUS_UI 	pagenum
TicTacToe4x4_UI 	pagenum
TicTacToe5x5_UI 	pagenum
UltimateTicTacToe_UI 	pagenum
XO_UI 	pagenum
word_UI 	pagenum

UI< int > 	pagenum
NumericalTicTacToeUI 	pagenum
Numerical_UI 	pagenum

Class Index
Class List
Here are the classes, structs, unions and interfaces with brief descriptions:
Board< T > (Base template for any board used in board games ) 	pagenum
DiamondTicTacToe_Player  	pagenum
DiamondTicTacToe_RandomPlayer  	pagenum
DiamondTicTacToe_UI  	pagenum
DiamondTicTacToeBoard  	pagenum
FourBoard  	pagenum
FourInARowBoard  	pagenum
FourInARowPlayer  	pagenum
FourInARowRandomPlayer  	pagenum
FourInARowUI  	pagenum
FourUI  	pagenum
GameManager< T > (Controls the flow of a board game between two players ) 	pagenum
InfinityTicTacToe_Player  	pagenum
InfinityTicTacToe_RandomPlayer  	pagenum
InfinityTicTacToe_UI  	pagenum
InfinityTicTacToeBoard  	pagenum
MemoryTicTacToe_Player  	pagenum
MemoryTicTacToe_RandomPlayer  	pagenum
MemoryTicTacToe_UI  	pagenum
MemoryTicTacToeBoard  	pagenum
MisereTicTacToe_Board  	pagenum
MisereTicTacToe_Player  	pagenum
MisereTicTacToe_RandomPlayer  	pagenum
MisereTicTacToe_UI  	pagenum
Move< T > (Represents a single move in a board game ) 	pagenum
Numerical_Board  	pagenum
Numerical_Player  	pagenum
Numerical_UI  	pagenum
NumericalTicTacToeBoard  	pagenum
NumericalTicTacToePlayer  	pagenum
NumericalTicTacToeRandomPlayer  	pagenum
NumericalTicTacToeUI  	pagenum
ObstaclesTicTacToe_Player  	pagenum
ObstaclesTicTacToe_RandomPlayer  	pagenum
ObstaclesTicTacToe_UI  	pagenum
ObstaclesTicTacToeBoard  	pagenum
Player< T > (Base template for all players (human or AI) ) 	pagenum
Pyramic_XO_Board  	pagenum
Pyramic_XO_Player  	pagenum
Pyramic_XO_RandomPlayer  	pagenum
Pyramic_XO_UI  	pagenum
SUS_Board  	pagenum
SUS_Player  	pagenum
SUS_Random_Player  	pagenum
SUS_UI  	pagenum
SUSBoard  	pagenum
SUSUI  	pagenum
TicTacToe4x4_Board  	pagenum
TicTacToe4x4_Player  	pagenum
TicTacToe4x4_UI  	pagenum
TicTacToe5x5_Board  	pagenum
TicTacToe5x5_Player  	pagenum
TicTacToe5x5_RandomPlayer  	pagenum
TicTacToe5x5_UI  	pagenum
UI< T > (Base class for handling user interface and input/output ) 	pagenum
UltimateTicTacToe_Player  	pagenum
UltimateTicTacToe_RandomPlayer  	pagenum
UltimateTicTacToe_UI  	pagenum
UltimateTicTacToeBoard  	pagenum
word_Board  	pagenum
word_Player  	pagenum
word_Random_Player  	pagenum
word_UI  	pagenum
XO_Board  	pagenum
XO_Player  	pagenum
XO_Random_Player  	pagenum
XO_UI  	pagenum

File Index
File List
Here is a list of all files with brief descriptions:
BoardGame_Classes.h  	pagenum
diamond.cpp  	pagenum
diamond.h  	pagenum
DiamondTicTacToe.h  	pagenum
FourBoard.h  	pagenum
FourInARow.h  	pagenum
FourUI.h  	pagenum
hide.cpp  	pagenum
hide.h  	pagenum
InfinityTicTacToe.h  	pagenum
inverse.cpp  	pagenum
inverse.h  	pagenum
main.cpp  	pagenum
MemoryTicTacToe.h  	pagenum
MisereTicTacToe.h  	pagenum
Numerical_Board.h  	pagenum
Numerical_Player.h  	pagenum
Numerical_UI.h  	pagenum
NumericalTicTacToe.h  	pagenum
ObstaclesTicTacToe.h  	pagenum
Pyramic_XO.h  	pagenum
SUS.h  	pagenum
SUSBoard.h  	pagenum
SUSUI.h  	pagenum
TicTacToe4x4.h  	pagenum
TicTacToe5x5.h  	pagenum
UltimateTicTacToe.h  	pagenum
wordTic_tac_toe.h  	pagenum
XO.h  	pagenum

Class Documentation
Board< T > Class Template Reference

Base template for any board used in board games. 
#include <BoardGame_Classes.h>
Public Member Functions
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

virtual bool update_board (Move< T > *move)=0
Update the board with a new move. 

virtual bool is_win (Player< T > *)=0
Check if a player has won. 

virtual bool is_lose (Player< T > *)=0
Check if a player has lost. 

virtual bool is_draw (Player< T > *)=0
Check if the game ended in a draw. 

virtual bool game_is_over (Player< T > *)=0
Check if the game is over. 

vector< vector< T > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Protected Attributes
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< T > > board
2D vector for the board 

int n_moves = 0
Number of moves made. 

Detailed Description
template<typename T>
class Board< T >
Base template for any board used in board games. 

Template Parameters
T 	Type of the elements stored on the board (e.g., char, int, string).	
Provides core data (rows, columns, matrix) and virtual methods to be implemented by specific games like Tic-Tac-Toe, Connect4, etc. 

Constructor & Destructor Documentation
template<typename T> Board< T >::Board (int rows, int columns)[inline]

Construct a board with given dimensions. 
template<typename T> virtual Board< T >::~Board ()[inline], [virtual]

Virtual destructor. Frees allocated board memory. 

Member Function Documentation
template<typename T> virtual bool Board< T >::game_is_over (Player< T > * )[pure virtual]

Check if the game is over. 
Implemented in DiamondTicTacToeBoard (p.pagenum), FourBoard (p.pagenum), FourInARowBoard (p.pagenum), InfinityTicTacToeBoard (p.pagenum), MemoryTicTacToeBoard (p.pagenum), MisereTicTacToe_Board (p.pagenum), Numerical_Board (p.pagenum), NumericalTicTacToeBoard (p.pagenum), ObstaclesTicTacToeBoard (p.pagenum), Pyramic_XO_Board (p.pagenum), SUS_Board (p.pagenum), SUSBoard (p.pagenum), TicTacToe4x4_Board (p.pagenum), TicTacToe5x5_Board (p.pagenum), UltimateTicTacToeBoard (p.pagenum), word_Board (p.pagenum), and XO_Board (p.pagenum).
template<typename T> vector< vector< T > > Board< T >::get_board_matrix () const[inline]

Return a copy of the current board as a 2D vector. 
template<typename T> int Board< T >::get_columns () const[inline]

Get number of columns. 
template<typename T> int Board< T >::get_rows () const[inline]

Get number of rows. 
template<typename T> virtual bool Board< T >::is_draw (Player< T > * )[pure virtual]

Check if the game ended in a draw. 
Implemented in DiamondTicTacToeBoard (p.pagenum), FourBoard (p.pagenum), FourInARowBoard (p.pagenum), InfinityTicTacToeBoard (p.pagenum), MemoryTicTacToeBoard (p.pagenum), MisereTicTacToe_Board (p.pagenum), Numerical_Board (p.pagenum), NumericalTicTacToeBoard (p.pagenum), ObstaclesTicTacToeBoard (p.pagenum), Pyramic_XO_Board (p.pagenum), SUS_Board (p.pagenum), SUSBoard (p.pagenum), TicTacToe4x4_Board (p.pagenum), TicTacToe5x5_Board (p.pagenum), UltimateTicTacToeBoard (p.pagenum), word_Board (p.pagenum), and XO_Board (p.pagenum).
template<typename T> virtual bool Board< T >::is_lose (Player< T > * )[pure virtual]

Check if a player has lost. 
Implemented in DiamondTicTacToeBoard (p.pagenum), FourBoard (p.pagenum), FourInARowBoard (p.pagenum), InfinityTicTacToeBoard (p.pagenum), MemoryTicTacToeBoard (p.pagenum), MisereTicTacToe_Board (p.pagenum), Numerical_Board (p.pagenum), NumericalTicTacToeBoard (p.pagenum), ObstaclesTicTacToeBoard (p.pagenum), Pyramic_XO_Board (p.pagenum), SUS_Board (p.pagenum), SUSBoard (p.pagenum), TicTacToe4x4_Board (p.pagenum), TicTacToe5x5_Board (p.pagenum), UltimateTicTacToeBoard (p.pagenum), word_Board (p.pagenum), and XO_Board (p.pagenum).
template<typename T> virtual bool Board< T >::is_win (Player< T > * )[pure virtual]

Check if a player has won. 
Implemented in DiamondTicTacToeBoard (p.pagenum), FourBoard (p.pagenum), FourInARowBoard (p.pagenum), InfinityTicTacToeBoard (p.pagenum), MemoryTicTacToeBoard (p.pagenum), MisereTicTacToe_Board (p.pagenum), Numerical_Board (p.pagenum), NumericalTicTacToeBoard (p.pagenum), ObstaclesTicTacToeBoard (p.pagenum), Pyramic_XO_Board (p.pagenum), SUS_Board (p.pagenum), SUSBoard (p.pagenum), TicTacToe4x4_Board (p.pagenum), TicTacToe5x5_Board (p.pagenum), UltimateTicTacToeBoard (p.pagenum), word_Board (p.pagenum), and XO_Board (p.pagenum).
template<typename T> virtual bool Board< T >::update_board (Move< T > * move)[pure virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implemented in DiamondTicTacToeBoard (p.pagenum), FourBoard (p.pagenum), FourInARowBoard (p.pagenum), InfinityTicTacToeBoard (p.pagenum), MemoryTicTacToeBoard (p.pagenum), MisereTicTacToe_Board (p.pagenum), Numerical_Board (p.pagenum), NumericalTicTacToeBoard (p.pagenum), ObstaclesTicTacToeBoard (p.pagenum), Pyramic_XO_Board (p.pagenum), SUS_Board (p.pagenum), SUSBoard (p.pagenum), TicTacToe4x4_Board (p.pagenum), TicTacToe5x5_Board (p.pagenum), UltimateTicTacToeBoard (p.pagenum), word_Board (p.pagenum), and XO_Board (p.pagenum).

Member Data Documentation
template<typename T> vector<vector<T> > Board< T >::board[protected]

2D vector for the board 
template<typename T> int Board< T >::columns[protected]

Number of columns. 
template<typename T> int Board< T >::n_moves = 0[protected]

Number of moves made. 
template<typename T> int Board< T >::rows[protected]

Number of rows. 

The documentation for this class was generated from the following file:
BoardGame_Classes.h

DiamondTicTacToe_Player Class Reference

#include <DiamondTicTacToe.h>
Inheritance diagram for DiamondTicTacToe_Player:
IMAGE
Public Member Functions
DiamondTicTacToe_Player (string name, char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
DiamondTicTacToe_Player::DiamondTicTacToe_Player (string name, char symbol)[inline]

The documentation for this class was generated from the following file:
DiamondTicTacToe.h

DiamondTicTacToe_RandomPlayer Class Reference

#include <DiamondTicTacToe.h>
Inheritance diagram for DiamondTicTacToe_RandomPlayer:
IMAGE
Public Member Functions
DiamondTicTacToe_RandomPlayer (char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
DiamondTicTacToe_RandomPlayer::DiamondTicTacToe_RandomPlayer (char symbol)[inline]

The documentation for this class was generated from the following file:
DiamondTicTacToe.h

DiamondTicTacToe_UI Class Reference

#include <DiamondTicTacToe.h>
Inheritance diagram for DiamondTicTacToe_UI:
IMAGE
Public Member Functions
DiamondTicTacToe_UI ()
Move< char > * get_move (Player< char > *player) override
Ask the user (or AI) to make a move. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

virtual Player< char > * create_player (string &name, char symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
DiamondTicTacToe_UI::DiamondTicTacToe_UI ()[inline]

Member Function Documentation
Move< char > * DiamondTicTacToe_UI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
DiamondTicTacToe.h

DiamondTicTacToeBoard Class Reference

#include <DiamondTicTacToe.h>
Inheritance diagram for DiamondTicTacToeBoard:
IMAGE
Public Member Functions
DiamondTicTacToeBoard ()
bool update_board (Move< char > *move) override
Update the board with a new move. 

bool is_win (Player< char > *player) override
Check if a player has won. 

bool is_lose (Player< char > *player) override
Check if a player has lost. 

bool is_draw (Player< char > *player) override
Check if the game ended in a draw. 

bool game_is_over (Player< char > *player) override
Check if the game is over. 

Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
DiamondTicTacToeBoard::DiamondTicTacToeBoard ()[inline]

Member Function Documentation
bool DiamondTicTacToeBoard::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
bool DiamondTicTacToeBoard::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool DiamondTicTacToeBoard::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool DiamondTicTacToeBoard::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool DiamondTicTacToeBoard::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
DiamondTicTacToe.h

FourBoard Class Reference

#include <FourBoard.h>
Inheritance diagram for FourBoard:
IMAGE
Public Member Functions
FourBoard ()
bool update_board (Move< char > *m) override
Update the board with a new move. 

bool is_win (Player< char > *p) override
Check if a player has won. 

bool is_draw (Player< char > *p) override
Check if the game ended in a draw. 

bool is_lose (Player< char > *p) override
Check if a player has lost. 

bool game_is_over (Player< char > *p) override
Check if the game is over. 

Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
FourBoard::FourBoard ()[inline]

Member Function Documentation
bool FourBoard::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
bool FourBoard::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool FourBoard::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool FourBoard::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool FourBoard::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
FourBoard.h

FourInARowBoard Class Reference

#include <FourInARow.h>
Inheritance diagram for FourInARowBoard:
IMAGE
Public Member Functions
FourInARowBoard ()
bool update_board (Move< char > *move) override
Update the board with a new move. 

bool is_win (Player< char > *player) override
Check if a player has won. 

bool is_lose (Player< char > *player) override
Check if a player has lost. 

bool is_draw (Player< char > *player) override
Check if the game ended in a draw. 

bool game_is_over (Player< char > *player) override
Check if the game is over. 

Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
FourInARowBoard::FourInARowBoard ()[inline]

Member Function Documentation
bool FourInARowBoard::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
bool FourInARowBoard::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool FourInARowBoard::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool FourInARowBoard::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool FourInARowBoard::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
FourInARow.h

FourInARowPlayer Class Reference

#include <FourInARow.h>
Inheritance diagram for FourInARowPlayer:
IMAGE
Public Member Functions
FourInARowPlayer (string name, char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
FourInARowPlayer::FourInARowPlayer (string name, char symbol)[inline]

The documentation for this class was generated from the following file:
FourInARow.h

FourInARowRandomPlayer Class Reference

#include <FourInARow.h>
Inheritance diagram for FourInARowRandomPlayer:
IMAGE
Public Member Functions
FourInARowRandomPlayer (char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
FourInARowRandomPlayer::FourInARowRandomPlayer (char symbol)[inline]

The documentation for this class was generated from the following file:
FourInARow.h

FourInARowUI Class Reference

#include <FourInARow.h>
Inheritance diagram for FourInARowUI:
IMAGE
Public Member Functions
FourInARowUI ()
Move< char > * get_move (Player< char > *player) override
Ask the user (or AI) to make a move. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

virtual Player< char > * create_player (string &name, char symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
FourInARowUI::FourInARowUI ()[inline]

Member Function Documentation
Move< char > * FourInARowUI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
FourInARow.h

FourUI Class Reference

#include <FourUI.h>
Inheritance diagram for FourUI:
IMAGE
Public Member Functions
FourUI ()
void print_board (const vector< vector< char > > &b)
Move< char > * get_move (Player< char > *p) override
Ask the user (or AI) to make a move. 

Player< char > * create_player (string &name, char symbol, PlayerType type) override
Create a player object based on input name, symbol, and type. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
FourUI::FourUI ()[inline]

Member Function Documentation
Player< char > * FourUI::create_player (string & name, char symbol, PlayerType type)[inline], [override], [virtual]

Create a player object based on input name, symbol, and type. 
Implements UI< char > (p.pagenum).
Move< char > * FourUI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).
void FourUI::print_board (const vector< vector< char > > & b)[inline]

The documentation for this class was generated from the following file:
FourUI.h

GameManager< T > Class Template Reference

Controls the flow of a board game between two players. 
#include <BoardGame_Classes.h>
Public Member Functions
GameManager (Board< T > *b, Player< T > *p[2], UI< T > *u)
Construct a game manager with board, players, and UI. 

void run ()
Run the main game loop until someone wins or the game ends. 

Detailed Description
template<typename T>
class GameManager< T >
Controls the flow of a board game between two players. 

Template Parameters
T 	Type of symbol used on the board. 	

Constructor & Destructor Documentation
template<typename T> GameManager< T >::GameManager (Board< T > * b, Player< T > * p[2], UI< T > * u)[inline]

Construct a game manager with board, players, and UI. 

Member Function Documentation
template<typename T> void GameManager< T >::run ()[inline]

Run the main game loop until someone wins or the game ends. 

The documentation for this class was generated from the following file:
BoardGame_Classes.h

InfinityTicTacToe_Player Class Reference

#include <InfinityTicTacToe.h>
Inheritance diagram for InfinityTicTacToe_Player:
IMAGE
Public Member Functions
InfinityTicTacToe_Player (string name, char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
InfinityTicTacToe_Player::InfinityTicTacToe_Player (string name, char symbol)[inline]

The documentation for this class was generated from the following file:
InfinityTicTacToe.h

InfinityTicTacToe_RandomPlayer Class Reference

#include <InfinityTicTacToe.h>
Inheritance diagram for InfinityTicTacToe_RandomPlayer:
IMAGE
Public Member Functions
InfinityTicTacToe_RandomPlayer (char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
InfinityTicTacToe_RandomPlayer::InfinityTicTacToe_RandomPlayer (char symbol)[inline]

The documentation for this class was generated from the following file:
InfinityTicTacToe.h

InfinityTicTacToe_UI Class Reference

#include <InfinityTicTacToe.h>
Inheritance diagram for InfinityTicTacToe_UI:
IMAGE
Public Member Functions
InfinityTicTacToe_UI ()
Move< char > * get_move (Player< char > *player) override
Ask the user (or AI) to make a move. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

virtual Player< char > * create_player (string &name, char symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
InfinityTicTacToe_UI::InfinityTicTacToe_UI ()[inline]

Member Function Documentation
Move< char > * InfinityTicTacToe_UI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
InfinityTicTacToe.h

InfinityTicTacToeBoard Class Reference

#include <InfinityTicTacToe.h>
Inheritance diagram for InfinityTicTacToeBoard:
IMAGE
Public Member Functions
InfinityTicTacToeBoard ()
bool update_board (Move< char > *move) override
Update the board with a new move. 

bool is_win (Player< char > *player) override
Check if a player has won. 

bool is_lose (Player< char > *player) override
Check if a player has lost. 

bool is_draw (Player< char > *player) override
Check if the game ended in a draw. 

bool game_is_over (Player< char > *player) override
Check if the game is over. 

Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
InfinityTicTacToeBoard::InfinityTicTacToeBoard ()[inline]

Member Function Documentation
bool InfinityTicTacToeBoard::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
bool InfinityTicTacToeBoard::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool InfinityTicTacToeBoard::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool InfinityTicTacToeBoard::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool InfinityTicTacToeBoard::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
InfinityTicTacToe.h

MemoryTicTacToe_Player Class Reference

#include <MemoryTicTacToe.h>
Inheritance diagram for MemoryTicTacToe_Player:
IMAGE
Public Member Functions
MemoryTicTacToe_Player (string name, char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
MemoryTicTacToe_Player::MemoryTicTacToe_Player (string name, char symbol)[inline]

The documentation for this class was generated from the following file:
MemoryTicTacToe.h

MemoryTicTacToe_RandomPlayer Class Reference

#include <MemoryTicTacToe.h>
Inheritance diagram for MemoryTicTacToe_RandomPlayer:
IMAGE
Public Member Functions
MemoryTicTacToe_RandomPlayer (char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
MemoryTicTacToe_RandomPlayer::MemoryTicTacToe_RandomPlayer (char symbol)[inline]

The documentation for this class was generated from the following file:
MemoryTicTacToe.h

MemoryTicTacToe_UI Class Reference

#include <MemoryTicTacToe.h>
Inheritance diagram for MemoryTicTacToe_UI:
IMAGE
Public Member Functions
MemoryTicTacToe_UI ()
Move< char > * get_move (Player< char > *player) override
Ask the user (or AI) to make a move. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

virtual Player< char > * create_player (string &name, char symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
MemoryTicTacToe_UI::MemoryTicTacToe_UI ()[inline]

Member Function Documentation
Move< char > * MemoryTicTacToe_UI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
MemoryTicTacToe.h

MemoryTicTacToeBoard Class Reference

#include <MemoryTicTacToe.h>
Inheritance diagram for MemoryTicTacToeBoard:
IMAGE
Public Member Functions
MemoryTicTacToeBoard ()
bool update_board (Move< char > *move) override
Update the board with a new move. 

bool is_win (Player< char > *player) override
Check if a player has won. 

bool is_lose (Player< char > *player) override
Check if a player has lost. 

bool is_draw (Player< char > *player) override
Check if the game ended in a draw. 

bool game_is_over (Player< char > *player) override
Check if the game is over. 

Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
MemoryTicTacToeBoard::MemoryTicTacToeBoard ()[inline]

Member Function Documentation
bool MemoryTicTacToeBoard::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
bool MemoryTicTacToeBoard::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool MemoryTicTacToeBoard::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool MemoryTicTacToeBoard::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool MemoryTicTacToeBoard::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
MemoryTicTacToe.h

MisereTicTacToe_Board Class Reference

#include <MisereTicTacToe.h>
Inheritance diagram for MisereTicTacToe_Board:
IMAGE
Public Member Functions
MisereTicTacToe_Board ()
bool update_board (Move< char > *move) override
Update the board with a new move. 

bool is_win (Player< char > *player) override
Check if a player has won. 

bool is_lose (Player< char > *player) override
Check if a player has lost. 

bool is_draw (Player< char > *player) override
Check if the game ended in a draw. 

bool game_is_over (Player< char > *player) override
Check if the game is over. 

Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
MisereTicTacToe_Board::MisereTicTacToe_Board ()[inline]

Member Function Documentation
bool MisereTicTacToe_Board::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
bool MisereTicTacToe_Board::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool MisereTicTacToe_Board::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool MisereTicTacToe_Board::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool MisereTicTacToe_Board::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
MisereTicTacToe.h

MisereTicTacToe_Player Class Reference

#include <MisereTicTacToe.h>
Inheritance diagram for MisereTicTacToe_Player:
IMAGE
Public Member Functions
MisereTicTacToe_Player (string name, char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
MisereTicTacToe_Player::MisereTicTacToe_Player (string name, char symbol)[inline]

The documentation for this class was generated from the following file:
MisereTicTacToe.h

MisereTicTacToe_RandomPlayer Class Reference

#include <MisereTicTacToe.h>
Inheritance diagram for MisereTicTacToe_RandomPlayer:
IMAGE
Public Member Functions
MisereTicTacToe_RandomPlayer (char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
MisereTicTacToe_RandomPlayer::MisereTicTacToe_RandomPlayer (char symbol)[inline]

The documentation for this class was generated from the following file:
MisereTicTacToe.h

MisereTicTacToe_UI Class Reference

#include <MisereTicTacToe.h>
Inheritance diagram for MisereTicTacToe_UI:
IMAGE
Public Member Functions
MisereTicTacToe_UI ()
Move< char > * get_move (Player< char > *player) override
Ask the user (or AI) to make a move. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

virtual Player< char > * create_player (string &name, char symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
MisereTicTacToe_UI::MisereTicTacToe_UI ()[inline]

Member Function Documentation
Move< char > * MisereTicTacToe_UI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
MisereTicTacToe.h

Move< T > Class Template Reference

Represents a single move in a board game. 
#include <BoardGame_Classes.h>
Public Member Functions
Move (int x, int y, T symbol)
Construct a move at (x, y) using a symbol. 

int get_x () const
Get row index. 

int get_y () const
Get column index. 

T get_symbol () const
Get the move symbol. 

Detailed Description
template<typename T>
class Move< T >
Represents a single move in a board game. 

Template Parameters
T 	Type of symbol placed on the board (e.g., char, int). 	

Constructor & Destructor Documentation
template<typename T> Move< T >::Move (int x, int y, T symbol)[inline]

Construct a move at (x, y) using a symbol. 

Member Function Documentation
template<typename T> T Move< T >::get_symbol () const[inline]

Get the move symbol. 
template<typename T> int Move< T >::get_x () const[inline]

Get row index. 
template<typename T> int Move< T >::get_y () const[inline]

Get column index. 

The documentation for this class was generated from the following file:
BoardGame_Classes.h

Numerical_Board Class Reference

#include <Numerical_Board.h>
Inheritance diagram for Numerical_Board:
IMAGE
Public Member Functions
Numerical_Board ()
bool update_board (Move< int > *m) override
Update the board with a new move. 

bool is_win (Player< int > *p) override
Check if a player has won. 

bool is_draw (Player< int > *p) override
Check if the game ended in a draw. 

bool is_lose (Player< int > *p) override
Check if a player has lost. 

bool game_is_over (Player< int > *p) override
Check if the game is over. 

Public Member Functions inherited from Board< int >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< int > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< int >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< int > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
Numerical_Board::Numerical_Board ()[inline]

Member Function Documentation
bool Numerical_Board::game_is_over (Player< int > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< int > (p.pagenum).
bool Numerical_Board::is_draw (Player< int > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< int > (p.pagenum).
bool Numerical_Board::is_lose (Player< int > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< int > (p.pagenum).
bool Numerical_Board::is_win (Player< int > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< int > (p.pagenum).
bool Numerical_Board::update_board (Move< int > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< int > (p.pagenum).

The documentation for this class was generated from the following file:
Numerical_Board.h

Numerical_Player Class Reference

#include <Numerical_Player.h>
Inheritance diagram for Numerical_Player:
IMAGE
Public Member Functions
Numerical_Player (string n, bool odd, PlayerType t)
Public Member Functions inherited from Player< int >
Player (string n, int s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

int get_symbol () const
Get the player's symbol. 

Board< int > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< int > *b)
Assign the board pointer for the player. 

Public Attributes
bool isOdd
Additional Inherited Members
Protected Attributes inherited from Player< int >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

int symbol
Player’s symbol on board. 

Board< int > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
Numerical_Player::Numerical_Player (string n, bool odd, PlayerType t)[inline]

Member Data Documentation
bool Numerical_Player::isOdd

The documentation for this class was generated from the following file:
Numerical_Player.h

Numerical_UI Class Reference

#include <Numerical_UI.h>
Inheritance diagram for Numerical_UI:
IMAGE
Public Member Functions
Numerical_UI ()
void display_board_matrix (const vector< vector< int > > &b) const
Move< int > * get_move (Player< int > *p) override
Ask the user (or AI) to make a move. 

Player< int > * create_player (string &n, int symbol, PlayerType t) override
Create a player object based on input name, symbol, and type. 

Public Member Functions inherited from UI< int >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< int > ** setup_players ()
Set up players for the game. 

void display_board_matrix (const vector< vector< int > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< int >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< int >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
Numerical_UI::Numerical_UI ()[inline]

Member Function Documentation
Player< int > * Numerical_UI::create_player (string & name, int symbol, PlayerType type)[inline], [override], [virtual]

Create a player object based on input name, symbol, and type. 
Implements UI< int > (p.pagenum).
void Numerical_UI::display_board_matrix (const vector< vector< int > > & b) const[inline]
Move< int > * Numerical_UI::get_move (Player< int > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< int > (p.pagenum).

The documentation for this class was generated from the following file:
Numerical_UI.h

NumericalTicTacToeBoard Class Reference

#include <NumericalTicTacToe.h>
Inheritance diagram for NumericalTicTacToeBoard:
IMAGE
Public Member Functions
NumericalTicTacToeBoard ()
bool update_board (Move< int > *move) override
Update the board with a new move. 

bool is_win (Player< int > *player) override
Check if a player has won. 

bool is_lose (Player< int > *player) override
Check if a player has lost. 

bool is_draw (Player< int > *player) override
Check if the game ended in a draw. 

bool game_is_over (Player< int > *player) override
Check if the game is over. 

Public Member Functions inherited from Board< int >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< int > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< int >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< int > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
NumericalTicTacToeBoard::NumericalTicTacToeBoard ()[inline]

Member Function Documentation
bool NumericalTicTacToeBoard::game_is_over (Player< int > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< int > (p.pagenum).
bool NumericalTicTacToeBoard::is_draw (Player< int > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< int > (p.pagenum).
bool NumericalTicTacToeBoard::is_lose (Player< int > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< int > (p.pagenum).
bool NumericalTicTacToeBoard::is_win (Player< int > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< int > (p.pagenum).
bool NumericalTicTacToeBoard::update_board (Move< int > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< int > (p.pagenum).

The documentation for this class was generated from the following file:
NumericalTicTacToe.h

NumericalTicTacToePlayer Class Reference

#include <NumericalTicTacToe.h>
Inheritance diagram for NumericalTicTacToePlayer:
IMAGE
Public Member Functions
NumericalTicTacToePlayer (string name, int symbol)
Public Member Functions inherited from Player< int >
Player (string n, int s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

int get_symbol () const
Get the player's symbol. 

Board< int > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< int > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< int >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

int symbol
Player’s symbol on board. 

Board< int > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
NumericalTicTacToePlayer::NumericalTicTacToePlayer (string name, int symbol)[inline]

The documentation for this class was generated from the following file:
NumericalTicTacToe.h

NumericalTicTacToeRandomPlayer Class Reference

#include <NumericalTicTacToe.h>
Inheritance diagram for NumericalTicTacToeRandomPlayer:
IMAGE
Public Member Functions
NumericalTicTacToeRandomPlayer (int symbol)
Public Member Functions inherited from Player< int >
Player (string n, int s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

int get_symbol () const
Get the player's symbol. 

Board< int > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< int > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< int >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

int symbol
Player’s symbol on board. 

Board< int > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
NumericalTicTacToeRandomPlayer::NumericalTicTacToeRandomPlayer (int symbol)[inline]

The documentation for this class was generated from the following file:
NumericalTicTacToe.h

NumericalTicTacToeUI Class Reference

#include <NumericalTicTacToe.h>
Inheritance diagram for NumericalTicTacToeUI:
IMAGE
Public Member Functions
NumericalTicTacToeUI ()
Move< int > * get_move (Player< int > *player) override
Ask the user (or AI) to make a move. 

Public Member Functions inherited from UI< int >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< int > ** setup_players ()
Set up players for the game. 

virtual Player< int > * create_player (string &name, int symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< int > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< int >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< int >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
NumericalTicTacToeUI::NumericalTicTacToeUI ()[inline]

Member Function Documentation
Move< int > * NumericalTicTacToeUI::get_move (Player< int > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< int > (p.pagenum).

The documentation for this class was generated from the following file:
NumericalTicTacToe.h

ObstaclesTicTacToe_Player Class Reference

#include <ObstaclesTicTacToe.h>
Inheritance diagram for ObstaclesTicTacToe_Player:
IMAGE
Public Member Functions
ObstaclesTicTacToe_Player (string name, char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
ObstaclesTicTacToe_Player::ObstaclesTicTacToe_Player (string name, char symbol)[inline]

The documentation for this class was generated from the following file:
ObstaclesTicTacToe.h

ObstaclesTicTacToe_RandomPlayer Class Reference

#include <ObstaclesTicTacToe.h>
Inheritance diagram for ObstaclesTicTacToe_RandomPlayer:
IMAGE
Public Member Functions
ObstaclesTicTacToe_RandomPlayer (char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
ObstaclesTicTacToe_RandomPlayer::ObstaclesTicTacToe_RandomPlayer (char symbol)[inline]

The documentation for this class was generated from the following file:
ObstaclesTicTacToe.h

ObstaclesTicTacToe_UI Class Reference

#include <ObstaclesTicTacToe.h>
Inheritance diagram for ObstaclesTicTacToe_UI:
IMAGE
Public Member Functions
ObstaclesTicTacToe_UI ()
Move< char > * get_move (Player< char > *player) override
Ask the user (or AI) to make a move. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

virtual Player< char > * create_player (string &name, char symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
ObstaclesTicTacToe_UI::ObstaclesTicTacToe_UI ()[inline]

Member Function Documentation
Move< char > * ObstaclesTicTacToe_UI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
ObstaclesTicTacToe.h

ObstaclesTicTacToeBoard Class Reference

#include <ObstaclesTicTacToe.h>
Inheritance diagram for ObstaclesTicTacToeBoard:
IMAGE
Public Member Functions
ObstaclesTicTacToeBoard ()
bool update_board (Move< char > *move) override
Update the board with a new move. 

bool is_win (Player< char > *player) override
Check if a player has won. 

bool is_lose (Player< char > *player) override
Check if a player has lost. 

bool is_draw (Player< char > *player) override
Check if the game ended in a draw. 

bool game_is_over (Player< char > *player) override
Check if the game is over. 

Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
ObstaclesTicTacToeBoard::ObstaclesTicTacToeBoard ()[inline]

Member Function Documentation
bool ObstaclesTicTacToeBoard::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
bool ObstaclesTicTacToeBoard::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool ObstaclesTicTacToeBoard::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool ObstaclesTicTacToeBoard::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool ObstaclesTicTacToeBoard::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
ObstaclesTicTacToe.h

Player< T > Class Template Reference

Base template for all players (human or AI). 
#include <BoardGame_Classes.h>
Public Member Functions
Player (string n, T s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

T get_symbol () const
Get the player's symbol. 

Board< T > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< T > *b)
Assign the board pointer for the player. 

Protected Attributes
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

T symbol
Player’s symbol on board. 

Board< T > * boardPtr
Pointer to the game board. 

Detailed Description
template<typename T>
class Player< T >
Base template for all players (human or AI). 

Template Parameters
T 	Type of symbol used by the player. 	

Constructor & Destructor Documentation
template<typename T> Player< T >::Player (string n, T s, PlayerType t)[inline]

Construct a player with name, symbol, and type. 
template<typename T> virtual Player< T >::~Player ()[inline], [virtual]

Member Function Documentation
template<typename T> Board< T > * Player< T >::get_board_ptr () const[inline]

Get a pointer to the game board. 
template<typename T> string Player< T >::get_name () const[inline]

Get the player's name. 
template<typename T> T Player< T >::get_symbol () const[inline]

Get the player's symbol. 
template<typename T> PlayerType Player< T >::get_type () const[inline]

Get player type (e.g., 'H' or 'C'). 
template<typename T> void Player< T >::set_board_ptr (Board< T > * b)[inline]

Assign the board pointer for the player. 

Member Data Documentation
template<typename T> Board<T>* Player< T >::boardPtr[protected]

Pointer to the game board. 
template<typename T> string Player< T >::name[protected]

Player name. 
template<typename T> T Player< T >::symbol[protected]

Player’s symbol on board. 
template<typename T> PlayerType Player< T >::type[protected]

Player type (e.g., HUMAN or COMPUTER). 

The documentation for this class was generated from the following file:
BoardGame_Classes.h

Pyramic_XO_Board Class Reference

#include <Pyramic_XO.h>
Inheritance diagram for Pyramic_XO_Board:
IMAGE
Public Member Functions
Pyramic_XO_Board ()
bool update_board (Move< char > *move) override
Update the board with a new move. 

bool is_win (Player< char > *player) override
Check if a player has won. 

bool is_lose (Player< char > *player) override
Check if a player has lost. 

bool is_draw (Player< char > *player) override
Check if the game ended in a draw. 

bool game_is_over (Player< char > *player) override
Check if the game is over. 

Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
Pyramic_XO_Board::Pyramic_XO_Board ()[inline]

Member Function Documentation
bool Pyramic_XO_Board::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
bool Pyramic_XO_Board::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool Pyramic_XO_Board::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool Pyramic_XO_Board::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool Pyramic_XO_Board::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
Pyramic_XO.h

Pyramic_XO_Player Class Reference

#include <Pyramic_XO.h>
Inheritance diagram for Pyramic_XO_Player:
IMAGE
Public Member Functions
Pyramic_XO_Player (string name, char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
Pyramic_XO_Player::Pyramic_XO_Player (string name, char symbol)[inline]

The documentation for this class was generated from the following file:
Pyramic_XO.h

Pyramic_XO_RandomPlayer Class Reference

#include <Pyramic_XO.h>
Inheritance diagram for Pyramic_XO_RandomPlayer:
IMAGE
Public Member Functions
Pyramic_XO_RandomPlayer (char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
Pyramic_XO_RandomPlayer::Pyramic_XO_RandomPlayer (char symbol)[inline]

The documentation for this class was generated from the following file:
Pyramic_XO.h

Pyramic_XO_UI Class Reference

#include <Pyramic_XO.h>
Inheritance diagram for Pyramic_XO_UI:
IMAGE
Public Member Functions
Pyramic_XO_UI ()
Move< char > * get_move (Player< char > *player) override
Ask the user (or AI) to make a move. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

virtual Player< char > * create_player (string &name, char symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
Pyramic_XO_UI::Pyramic_XO_UI ()[inline]

Member Function Documentation
Move< char > * Pyramic_XO_UI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
Pyramic_XO.h

SUS_Board Class Reference

#include <SUS.h>
Inheritance diagram for SUS_Board:
IMAGE
Public Member Functions
SUS_Board ()
bool update_board (Move< char > *move) override
Update the board with a new move. 

bool is_win (Player< char > *player) override
Check if a player has won. 

bool is_lose (Player< char > *player) override
Check if a player has lost. 

bool is_draw (Player< char > *player) override
Check if the game ended in a draw. 

bool game_is_over (Player< char > *player) override
Check if the game is over. 

pair< int, int > get_scores ()
Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
SUS_Board::SUS_Board ()[inline]

Member Function Documentation
bool SUS_Board::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
pair< int, int > SUS_Board::get_scores ()[inline]
bool SUS_Board::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool SUS_Board::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool SUS_Board::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool SUS_Board::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
SUS.h

SUS_Player Class Reference

#include <SUS.h>
Inheritance diagram for SUS_Player:
IMAGE
Public Member Functions
SUS_Player (string name, char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
SUS_Player::SUS_Player (string name, char symbol)[inline]

The documentation for this class was generated from the following file:
SUS.h

SUS_Random_Player Class Reference

#include <SUS.h>
Inheritance diagram for SUS_Random_Player:
IMAGE
Public Member Functions
SUS_Random_Player (char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
SUS_Random_Player::SUS_Random_Player (char symbol)[inline]

The documentation for this class was generated from the following file:
SUS.h

SUS_UI Class Reference

#include <SUS.h>
Inheritance diagram for SUS_UI:
IMAGE
Public Member Functions
SUS_UI ()
Move< char > * get_move (Player< char > *player) override
Ask the user (or AI) to make a move. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

virtual Player< char > * create_player (string &name, char symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
SUS_UI::SUS_UI ()[inline]

Member Function Documentation
Move< char > * SUS_UI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
SUS.h

SUSBoard Class Reference

#include <SUSBoard.h>
Inheritance diagram for SUSBoard:
IMAGE
Public Member Functions
SUSBoard ()
int count_xux ()
bool update_board (Move< char > *m) override
Update the board with a new move. 

bool full ()
bool is_win (Player< char > *p) override
Check if a player has won. 

bool is_lose (Player< char > *p) override
Check if a player has lost. 

bool is_draw (Player< char > *p) override
Check if the game ended in a draw. 

bool game_is_over (Player< char > *p) override
Check if the game is over. 

vector< vector< char > > get_board_matrix () const
Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
SUSBoard::SUSBoard ()[inline]

Member Function Documentation
int SUSBoard::count_xux ()[inline]
bool SUSBoard::full ()[inline]
bool SUSBoard::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
vector< vector< char > > SUSBoard::get_board_matrix () const[inline]
bool SUSBoard::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool SUSBoard::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool SUSBoard::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool SUSBoard::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
SUSBoard.h

SUSUI Class Reference

#include <SUSUI.h>
Inheritance diagram for SUSUI:
IMAGE
Public Member Functions
SUSUI ()
Move< char > * get_move (Player< char > *p) override
Ask the user (or AI) to make a move. 

Player< char > * create_player (string &name, char symbol, PlayerType type) override
Create a player object based on input name, symbol, and type. 

void display_message (string s)
Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
SUSUI::SUSUI ()[inline]

Member Function Documentation
Player< char > * SUSUI::create_player (string & name, char symbol, PlayerType type)[inline], [override], [virtual]

Create a player object based on input name, symbol, and type. 
Implements UI< char > (p.pagenum).
void SUSUI::display_message (string s)[inline]
Move< char > * SUSUI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
SUSUI.h

TicTacToe4x4_Board Class Reference

#include <TicTacToe4x4.h>
Inheritance diagram for TicTacToe4x4_Board:
IMAGE
Public Member Functions
TicTacToe4x4_Board ()
bool update_board (Move< char > *move) override
Update the board with a new move. 

bool is_win (Player< char > *player) override
Check if a player has won. 

bool is_draw (Player< char > *player) override
Check if the game ended in a draw. 

bool is_lose (Player< char > *player) override
Check if a player has lost. 

bool game_is_over (Player< char > *player) override
Check if the game is over. 

Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
TicTacToe4x4_Board::TicTacToe4x4_Board ()

Member Function Documentation
bool TicTacToe4x4_Board::game_is_over (Player< char > * )[override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
bool TicTacToe4x4_Board::is_draw (Player< char > * )[override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool TicTacToe4x4_Board::is_lose (Player< char > * )[override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool TicTacToe4x4_Board::is_win (Player< char > * )[override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool TicTacToe4x4_Board::update_board (Move< char > * move)[override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
TicTacToe4x4.h

TicTacToe4x4_Player Class Reference

#include <TicTacToe4x4.h>
Inheritance diagram for TicTacToe4x4_Player:
IMAGE
Public Member Functions
TicTacToe4x4_Player (string name, char symbol, PlayerType type)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
TicTacToe4x4_Player::TicTacToe4x4_Player (string name, char symbol, PlayerType type)[inline]

The documentation for this class was generated from the following file:
TicTacToe4x4.h

TicTacToe4x4_UI Class Reference

#include <TicTacToe4x4.h>
Inheritance diagram for TicTacToe4x4_UI:
IMAGE
Public Member Functions
TicTacToe4x4_UI ()
Move< char > * get_move (Player< char > *p) override
Ask the user (or AI) to make a move. 

Player< char > * create_player (string &name, char symbol, PlayerType type) override
Create a player object based on input name, symbol, and type. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
TicTacToe4x4_UI::TicTacToe4x4_UI ()[inline]

Member Function Documentation
Player< char > * TicTacToe4x4_UI::create_player (string & name, char symbol, PlayerType type)[inline], [override], [virtual]

Create a player object based on input name, symbol, and type. 
Implements UI< char > (p.pagenum).
Move< char > * TicTacToe4x4_UI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
TicTacToe4x4.h

TicTacToe5x5_Board Class Reference

#include <TicTacToe5x5.h>
Inheritance diagram for TicTacToe5x5_Board:
IMAGE
Public Member Functions
TicTacToe5x5_Board ()
bool update_board (Move< char > *move) override
Update the board with a new move. 

bool is_win (Player< char > *player) override
Check if a player has won. 

bool is_lose (Player< char > *player) override
Check if a player has lost. 

bool is_draw (Player< char > *player) override
Check if the game ended in a draw. 

bool game_is_over (Player< char > *player) override
Check if the game is over. 

Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
TicTacToe5x5_Board::TicTacToe5x5_Board ()[inline]

Member Function Documentation
bool TicTacToe5x5_Board::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
bool TicTacToe5x5_Board::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool TicTacToe5x5_Board::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool TicTacToe5x5_Board::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool TicTacToe5x5_Board::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
TicTacToe5x5.h

TicTacToe5x5_Player Class Reference

#include <TicTacToe5x5.h>
Inheritance diagram for TicTacToe5x5_Player:
IMAGE
Public Member Functions
TicTacToe5x5_Player (string name, char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
TicTacToe5x5_Player::TicTacToe5x5_Player (string name, char symbol)[inline]

The documentation for this class was generated from the following file:
TicTacToe5x5.h

TicTacToe5x5_RandomPlayer Class Reference

#include <TicTacToe5x5.h>
Inheritance diagram for TicTacToe5x5_RandomPlayer:
IMAGE
Public Member Functions
TicTacToe5x5_RandomPlayer (char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
TicTacToe5x5_RandomPlayer::TicTacToe5x5_RandomPlayer (char symbol)[inline]

The documentation for this class was generated from the following file:
TicTacToe5x5.h

TicTacToe5x5_UI Class Reference

#include <TicTacToe5x5.h>
Inheritance diagram for TicTacToe5x5_UI:
IMAGE
Public Member Functions
TicTacToe5x5_UI ()
Move< char > * get_move (Player< char > *player) override
Ask the user (or AI) to make a move. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

virtual Player< char > * create_player (string &name, char symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
TicTacToe5x5_UI::TicTacToe5x5_UI ()[inline]

Member Function Documentation
Move< char > * TicTacToe5x5_UI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
TicTacToe5x5.h

UI< T > Class Template Reference

Base class for handling user interface and input/output. 
#include <BoardGame_Classes.h>
Public Member Functions
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Move< T > * get_move (Player< T > *)=0
Ask the user (or AI) to make a move. 

virtual Player< T > ** setup_players ()
Set up players for the game. 

virtual Player< T > * create_player (string &name, T symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< T > > &matrix) const
Display the current board matrix in formatted form. 

Protected Member Functions
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes
int cell_width
Width of each displayed board cell. 

Detailed Description
template<typename T>
class UI< T >
Base class for handling user interface and input/output. 

Template Parameters
T 	The type of symbol used on the board. 	

Constructor & Destructor Documentation
template<typename T> UI< T >::UI (string message, int cell_display_width)[inline]

Construct the UI and display a welcome message. 
template<typename T> virtual UI< T >::~UI ()[inline], [virtual]

Member Function Documentation
template<typename T> virtual Player< T > * UI< T >::create_player (string & name, T symbol, PlayerType type)[pure virtual]

Create a player object based on input name, symbol, and type. 
Implemented in FourUI (p.pagenum), Numerical_UI (p.pagenum), SUSUI (p.pagenum), and TicTacToe4x4_UI (p.pagenum).
template<typename T> void UI< T >::display_board_matrix (const vector< vector< T > > & matrix) const[inline]

Display the current board matrix in formatted form. 
template<typename T> void UI< T >::display_message (string message)[inline]

Display any message to the user. 
template<typename T> virtual Move< T > * UI< T >::get_move (Player< T > * )[pure virtual]

Ask the user (or AI) to make a move. 
Implemented in DiamondTicTacToe_UI (p.pagenum), FourInARowUI (p.pagenum), FourUI (p.pagenum), InfinityTicTacToe_UI (p.pagenum), MemoryTicTacToe_UI (p.pagenum), MisereTicTacToe_UI (p.pagenum), Numerical_UI (p.pagenum), NumericalTicTacToeUI (p.pagenum), ObstaclesTicTacToe_UI (p.pagenum), Pyramic_XO_UI (p.pagenum), SUS_UI (p.pagenum), SUSUI (p.pagenum), TicTacToe4x4_UI (p.pagenum), TicTacToe5x5_UI (p.pagenum), UltimateTicTacToe_UI (p.pagenum), word_UI (p.pagenum), and XO_UI (p.pagenum).
template<typename T> string UI< T >::get_player_name (string player_label)[inline], [protected]

Ask the user for the player's name. 
template<typename T> PlayerType UI< T >::get_player_type_choice (string player_label, const vector< string > & options)[inline], [protected]

Ask the user to choose the player type from a list. 
template<typename T> Player< T > ** UI< T >::setup_players ()[virtual]

Set up players for the game. 
Default implementation of setting up two players. 

Member Data Documentation
template<typename T> int UI< T >::cell_width[protected]

Width of each displayed board cell. 

The documentation for this class was generated from the following file:
BoardGame_Classes.h

UltimateTicTacToe_Player Class Reference

#include <UltimateTicTacToe.h>
Inheritance diagram for UltimateTicTacToe_Player:
IMAGE
Public Member Functions
UltimateTicTacToe_Player (string name, char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
UltimateTicTacToe_Player::UltimateTicTacToe_Player (string name, char symbol)[inline]

The documentation for this class was generated from the following file:
UltimateTicTacToe.h

UltimateTicTacToe_RandomPlayer Class Reference

#include <UltimateTicTacToe.h>
Inheritance diagram for UltimateTicTacToe_RandomPlayer:
IMAGE
Public Member Functions
UltimateTicTacToe_RandomPlayer (char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
UltimateTicTacToe_RandomPlayer::UltimateTicTacToe_RandomPlayer (char symbol)[inline]

The documentation for this class was generated from the following file:
UltimateTicTacToe.h

UltimateTicTacToe_UI Class Reference

#include <UltimateTicTacToe.h>
Inheritance diagram for UltimateTicTacToe_UI:
IMAGE
Public Member Functions
UltimateTicTacToe_UI ()
Move< char > * get_move (Player< char > *player) override
Ask the user (or AI) to make a move. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

virtual Player< char > * create_player (string &name, char symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
UltimateTicTacToe_UI::UltimateTicTacToe_UI ()[inline]

Member Function Documentation
Move< char > * UltimateTicTacToe_UI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
UltimateTicTacToe.h

UltimateTicTacToeBoard Class Reference

#include <UltimateTicTacToe.h>
Inheritance diagram for UltimateTicTacToeBoard:
IMAGE
Public Member Functions
UltimateTicTacToeBoard ()
bool update_board (Move< char > *move) override
Update the board with a new move. 

bool is_win (Player< char > *player) override
Check if a player has won. 

bool is_lose (Player< char > *player) override
Check if a player has lost. 

bool is_draw (Player< char > *player) override
Check if the game ended in a draw. 

bool game_is_over (Player< char > *player) override
Check if the game is over. 

Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
UltimateTicTacToeBoard::UltimateTicTacToeBoard ()[inline]

Member Function Documentation
bool UltimateTicTacToeBoard::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
bool UltimateTicTacToeBoard::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool UltimateTicTacToeBoard::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool UltimateTicTacToeBoard::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool UltimateTicTacToeBoard::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
UltimateTicTacToe.h

word_Board Class Reference

#include <wordTic_tac_toe.h>
Inheritance diagram for word_Board:
IMAGE
Public Member Functions
word_Board ()
bool update_board (Move< char > *move) override
Update the board with a new move. 

bool is_win (Player< char > *player) override
Check if a player has won. 

bool is_lose (Player< char > *player) override
Check if a player has lost. 

bool is_draw (Player< char > *player) override
Check if the game ended in a draw. 

bool game_is_over (Player< char > *player) override
Check if the game is over. 

Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
word_Board::word_Board ()[inline]

Member Function Documentation
bool word_Board::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
bool word_Board::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool word_Board::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool word_Board::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool word_Board::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
wordTic_tac_toe.h

word_Player Class Reference

#include <wordTic_tac_toe.h>
Inheritance diagram for word_Player:
IMAGE
Public Member Functions
word_Player (string name, char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
word_Player::word_Player (string name, char symbol)[inline]

The documentation for this class was generated from the following file:
wordTic_tac_toe.h

word_Random_Player Class Reference

#include <wordTic_tac_toe.h>
Inheritance diagram for word_Random_Player:
IMAGE
Public Member Functions
word_Random_Player (char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
word_Random_Player::word_Random_Player (char symbol)[inline]

The documentation for this class was generated from the following file:
wordTic_tac_toe.h

word_UI Class Reference

#include <wordTic_tac_toe.h>
Inheritance diagram for word_UI:
IMAGE
Public Member Functions
word_UI ()
Move< char > * get_move (Player< char > *player) override
Ask the user (or AI) to make a move. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

virtual Player< char > * create_player (string &name, char symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
word_UI::word_UI ()[inline]

Member Function Documentation
Move< char > * word_UI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
wordTic_tac_toe.h

XO_Board Class Reference

#include <XO.h>
Inheritance diagram for XO_Board:
IMAGE
Public Member Functions
XO_Board ()
bool update_board (Move< char > *move) override
Update the board with a new move. 

bool is_win (Player< char > *player) override
Check if a player has won. 

bool is_lose (Player< char > *player) override
Check if a player has lost. 

bool is_draw (Player< char > *player) override
Check if the game ended in a draw. 

bool game_is_over (Player< char > *player) override
Check if the game is over. 

Public Member Functions inherited from Board< char >
Board (int rows, int columns)
Construct a board with given dimensions. 

virtual ~Board ()
Virtual destructor. Frees allocated board memory. 

vector< vector< char > > get_board_matrix () const
Return a copy of the current board as a 2D vector. 

int get_rows () const
Get number of rows. 

int get_columns () const
Get number of columns. 

Additional Inherited Members
Protected Attributes inherited from Board< char >
int rows
Number of rows. 

int columns
Number of columns. 

vector< vector< char > > board
2D vector for the board 

int n_moves
Number of moves made. 

Constructor & Destructor Documentation
XO_Board::XO_Board ()[inline]

Member Function Documentation
bool XO_Board::game_is_over (Player< char > * )[inline], [override], [virtual]

Check if the game is over. 
Implements Board< char > (p.pagenum).
bool XO_Board::is_draw (Player< char > * )[inline], [override], [virtual]

Check if the game ended in a draw. 
Implements Board< char > (p.pagenum).
bool XO_Board::is_lose (Player< char > * )[inline], [override], [virtual]

Check if a player has lost. 
Implements Board< char > (p.pagenum).
bool XO_Board::is_win (Player< char > * )[inline], [override], [virtual]

Check if a player has won. 
Implements Board< char > (p.pagenum).
bool XO_Board::update_board (Move< char > * move)[inline], [override], [virtual]

Update the board with a new move. 

Parameters
move 	The move object containing position and symbol. 	
Returns
true if the move is valid and applied, false otherwise. 
Implements Board< char > (p.pagenum).

The documentation for this class was generated from the following file:
XO.h

XO_Player Class Reference

#include <XO.h>
Inheritance diagram for XO_Player:
IMAGE
Public Member Functions
XO_Player (string name, char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
XO_Player::XO_Player (string name, char symbol)[inline]

The documentation for this class was generated from the following file:
XO.h

XO_Random_Player Class Reference

#include <XO.h>
Inheritance diagram for XO_Random_Player:
IMAGE
Public Member Functions
XO_Random_Player (char symbol)
Public Member Functions inherited from Player< char >
Player (string n, char s, PlayerType t)
Construct a player with name, symbol, and type. 

virtual ~Player ()
string get_name () const
Get the player's name. 

PlayerType get_type () const
Get player type (e.g., 'H' or 'C'). 

char get_symbol () const
Get the player's symbol. 

Board< char > * get_board_ptr () const
Get a pointer to the game board. 

void set_board_ptr (Board< char > *b)
Assign the board pointer for the player. 

Additional Inherited Members
Protected Attributes inherited from Player< char >
string name
Player name. 

PlayerType type
Player type (e.g., HUMAN or COMPUTER). 

char symbol
Player’s symbol on board. 

Board< char > * boardPtr
Pointer to the game board. 

Constructor & Destructor Documentation
XO_Random_Player::XO_Random_Player (char symbol)[inline]

The documentation for this class was generated from the following file:
XO.h

XO_UI Class Reference

#include <XO.h>
Inheritance diagram for XO_UI:
IMAGE
Public Member Functions
XO_UI ()
Move< char > * get_move (Player< char > *player) override
Ask the user (or AI) to make a move. 

Public Member Functions inherited from UI< char >
UI (string message, int cell_display_width)
Construct the UI and display a welcome message. 

virtual ~UI ()
void display_message (string message)
Display any message to the user. 

virtual Player< char > ** setup_players ()
Set up players for the game. 

virtual Player< char > * create_player (string &name, char symbol, PlayerType type)=0
Create a player object based on input name, symbol, and type. 

void display_board_matrix (const vector< vector< char > > &matrix) const
Display the current board matrix in formatted form. 

Additional Inherited Members
Protected Member Functions inherited from UI< char >
string get_player_name (string player_label)
Ask the user for the player's name. 

PlayerType get_player_type_choice (string player_label, const vector< string > &options)
Ask the user to choose the player type from a list. 

Protected Attributes inherited from UI< char >
int cell_width
Width of each displayed board cell. 

Constructor & Destructor Documentation
XO_UI::XO_UI ()[inline]

Member Function Documentation
Move< char > * XO_UI::get_move (Player< char > * )[inline], [override], [virtual]

Ask the user (or AI) to make a move. 
Implements UI< char > (p.pagenum).

The documentation for this class was generated from the following file:
XO.h
File Documentation
BoardGame_Classes.h File Reference
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
Classes
class Board< T >Base template for any board used in board games. 
class Move< T >Represents a single move in a board game. 
class Player< T >Base template for all players (human or AI). 
class UI< T >Base class for handling user interface and input/output. 
class GameManager< T >Controls the flow of a board game between two players. 
Enumerations
enum class PlayerType { HUMAN, COMPUTER, AI, RANDOM }
Represents the type of player in the game. 

Enumeration Type Documentation
enum class PlayerType[strong]

Represents the type of player in the game. 

Enumerator:
HUMAN	A human player. 
	
COMPUTER	A computer-controlled player. 
	
AI	An AI player. 
	
RANDOM	A Random player. 

BoardGame_Classes.h
Go to the documentation of this file.

1 #ifndef _BOARDGAME_CLASSES_H
2 #define _BOARDGAME_CLASSES_H
3 
4 #include <string>
5 #include <vector>
6 #include <iostream>
7 #include <iomanip>
8 using namespace std;
9 
11 // Forward declarations
13 
14 template <typename T> class Player;
15 template <typename T> class Move;
16 
18 // Class declarations
20 
24 enum class PlayerType {
25     HUMAN,     
26     COMPUTER,  
27     AI,        
28     RANDOM     
29 };
30 
39 template <typename T>
40 class Board {
41 protected:
42     int rows;        
43     int columns;     
44     vector<vector<T>> board; 
45     int n_moves = 0; 
46 
47 public:
51     Board(int rows, int columns)
52         : rows(rows), columns(columns), board(rows, vector<T>(columns)) {
53     }
54 
58     virtual ~Board() {}
59 
65     virtual bool update_board(Move<T>* move) = 0;
66 
68     virtual bool is_win(Player<T>*) = 0;
69 
71     virtual bool is_lose(Player<T>*) = 0;
72 
74     virtual bool is_draw(Player<T>*) = 0;
75 
77     virtual bool game_is_over(Player<T>*) = 0;
78 
82     vector<vector<T>> get_board_matrix() const {
83         return board;
84     }
85 
87     int get_rows() const { return rows; }
88 
90     int get_columns() const { return columns; }
91 };
92 
93 //-----------------------------------------------------
99 template <typename T>
100 class Move {
101     int x;      
102     int y;      
103     T symbol;   
104 
105 public:
107     Move(int x, int y, T symbol) : x(x), y(y), symbol(symbol) {}
108 
110     int get_x() const { return x; }
111 
113     int get_y() const { return y; }
114 
116     T get_symbol() const { return symbol; }
117 };
118 
119 //-----------------------------------------------------
125 template <typename T>
126 class Player {
127 protected:
128     string name;         
129     PlayerType type;     
130     T symbol;            
131     Board<T>* boardPtr;  
132 
133 public:
137     Player(string n, T s, PlayerType t)
138         : name(n), symbol(s), type(t), boardPtr(nullptr) {
139     }
140 
141     virtual ~Player() {}
142 
144     string get_name() const { return name; }
145 
147     PlayerType get_type() const { return type; }
148 
150     T get_symbol() const { return symbol; }
151 
153     Board<T>* get_board_ptr() const { return boardPtr; }
154 
156     void set_board_ptr(Board<T>* b) { boardPtr = b; }
157 };
158 
159 //-----------------------------------------------------
165 template <typename T>
166 class UI {
167 protected:
168     int cell_width; 
169 
173     string get_player_name(string player_label) {
174         string name;
175         cout << "Enter " << player_label << " name: ";
176         getline(cin >> ws, name);
177         return name;
178     }
179 
183     PlayerType get_player_type_choice(string player_label, const vector<string>& options) {
184         cout << "Choose " << player_label << " type:\n";
185         for (size_t i = 0; i < options.size(); ++i)
186             cout << i + 1 << ". " << options[i] << "\n";
187         int choice;
188         cin >> choice;
189         return (choice == 2) ? PlayerType::COMPUTER : PlayerType::HUMAN;
190     }
191 
192 public:
196     UI(string message, int cell_display_width)
197         : cell_width(cell_display_width) {
198         cout << message << endl;
199     }
200 
201     virtual ~UI() {}
202 
204     void display_message(string message) { cout << message << "\n"; }
205 
209     virtual Move<T>* get_move(Player<T>*) = 0;
210 
214     virtual Player<T>** setup_players();
215 
219     virtual Player<T>* create_player(string& name, T symbol, PlayerType type) = 0;
220 
224     void display_board_matrix(const vector<vector<T>>& matrix) const {
225         if (matrix.empty() || matrix[0].empty()) return;
226 
227         int rows = matrix.size();
228         int cols = matrix[0].size();
229 
230         cout << "\n    ";
231         for (int j = 0; j < cols; ++j)
232             cout << setw(cell_width + 1) << j;
233         cout << "\n   " << string((cell_width + 2) * cols, '-') << "\n";
234 
235         for (int i = 0; i < rows; ++i) {
236             cout << setw(2) << i << " |";
237             for (int j = 0; j < cols; ++j)
238                 cout << setw(cell_width) << matrix[i][j] << " |";
239             cout << "\n   " << string((cell_width + 2) * cols, '-') << "\n";
240         }
241         cout << endl;
242     }
243 };
244 
245 //-----------------------------------------------------
251 template <typename T>
252 class GameManager {
253     Board<T>* boardPtr;    
254     Player<T>* players[2]; 
255     UI<T>* ui;             
256 
257 public:
261     GameManager(Board<T>* b, Player<T>* p[2], UI<T>* u)
262         : boardPtr(b), ui(u) {
263         players[0] = p[0];
264         players[1] = p[1];
265         players[0]->set_board_ptr(b);
266         players[1]->set_board_ptr(b);
267     }
268 
272     void run() {
273         ui->display_board_matrix(boardPtr->get_board_matrix());
274         Player<T>* currentPlayer = players[0];
275 
276         while (true) {
277             for (int i : {0, 1}) {
278                 currentPlayer = players[i];
279                 Move<T>* move = ui->get_move(currentPlayer);
280 
281                 while (!boardPtr->update_board(move))
282                     move = ui->get_move(currentPlayer);
283 
284                 ui->display_board_matrix(boardPtr->get_board_matrix());
285 
286                 if (boardPtr->is_win(currentPlayer)) {
287                     ui->display_message(currentPlayer->get_name() + " wins!");
288                     return;
289                 }
290                 if (boardPtr->is_lose(currentPlayer)) {
291                     ui->display_message(players[1 - i]->get_name() + " wins!");
292                     return;
293                 }
294                 if (boardPtr->is_draw(currentPlayer)) {
295                     ui->display_message("Draw!");
296                     return;
297                 }
298             }
299         }
300     }
301 };
302 
303 //-----------------------------------------------------
307 template <typename T>
308 Player<T>** UI<T>::setup_players() {
309     Player<T>** players = new Player<T>*[2];
310     vector<string> type_options = { "Human", "Computer" };
311 
312     string nameX = get_player_name("Player X");
313     PlayerType typeX = get_player_type_choice("Player X", type_options);
314     players[0] = create_player(nameX, static_cast<T>('X'), typeX);
315 
316     string nameO = get_player_name("Player O");
317     PlayerType typeO = get_player_type_choice("Player O", type_options);
318     players[1] = create_player(nameO, static_cast<T>('O'), typeO);
319 
320     return players;
321 }
322 
323 #endif // _BOARDGAME_CLASSES_H#pragma once

diamond.cpp File Reference
#include <iostream>
#include <iomanip>
#include <cctype>
#include "diamond.h"

diamond.h File Reference
#include "D:\Desktop\CU\CS213 OOP\A3 Games\Project35\BoardGame_Classes.h"

diamond.h
Go to the documentation of this file.

1 
9 
10 #ifndef DIAMOND_H
11 #define DIAMOND_H
12 
13 #include "D:\Desktop\CU\CS213 OOP\A3 Games\Project35\BoardGame_Classes.h"
14 using namespace std;
15 
26 class diamond_board : public Board<char> {
27 private:
28     char blank_symbol = '.'; 
29     char blocked_symbol = '#';
30 
31 public:
35     diamond_board();
36 
42     bool update_board(Move<char>* move)override;
43 
49     bool is_win(Player<char>* player)override;
50 
56     bool is_lose(Player<char>*)override { return false; };
57 
63     bool is_draw(Player<char>* player)override;
64 
70     bool game_is_over(Player<char>* player)override;
71 };
72 
73 
83 class diamond_ui : public UI<char> {
84 public:
90     diamond_ui();
91 
95     ~diamond_ui() {};
96 
104     Player<char>* create_player(string& name, char symbol, PlayerType type);
105 
111     virtual Move<char>* get_move(Player<char>* player);
112 };
113 
114 #endif // XO_CLASSES_H

DiamondTicTacToe.h File Reference
#include "BoardGame_Classes.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
Classes
class DiamondTicTacToeBoardclass DiamondTicTacToe_Player
class DiamondTicTacToe_RandomPlayer
class DiamondTicTacToe_UI

DiamondTicTacToe.h
Go to the documentation of this file.

1 #ifndef DIAMONDTICTACTOE_H
2 #define DIAMONDTICTACTOE_H
3 
4 #include "BoardGame_Classes.h"
5 #include <iostream>
6 #include <cstdlib>
7 #include <ctime>
8 using namespace std;
9 
10 // Diamond Tic Tac Toe Board
11 class DiamondTicTacToeBoard : public Board<char> {
12 private:
13     bool is_valid_position(int x, int y) {
14         // Diamond shape positions
15         int center = 2;
16         int distance = abs(x - center) + abs(y - center);
17         return (distance <= 2);
18     }
19 
20     bool check_three_in_row(char symbol) {
21         // Check all possible three in a row
22         // This is simplified - actual implementation should check all possible lines
23         for (int i = 0; i < 5; i++) {
24             for (int j = 0; j < 3; j++) {
25                 if (board[i][j] == symbol && board[i][j + 1] == symbol && board[i][j + 2] == symbol)
26                     return true;
27             }
28         }
29         return false;
30     }
31 
32     bool check_four_in_row(char symbol) {
33         // Check all possible four in a row
34         for (int i = 0; i < 5; i++) {
35             for (int j = 0; j < 2; j++) {
36                 if (board[i][j] == symbol && board[i][j + 1] == symbol &&
37                     board[i][j + 2] == symbol && board[i][j + 3] == symbol)
38                     return true;
39             }
40         }
41         return false;
42     }
43 
44 public:
45     DiamondTicTacToeBoard() : Board(5, 5) {
46         for (int i = 0; i < 5; i++) {
47             for (int j = 0; j < 5; j++) {
48                 if (is_valid_position(i, j)) {
49                     board[i][j] = ' ';
50                 }
51                 else {
52                     board[i][j] = '#'; // Invalid cell
53                 }
54             }
55         }
56     }
57 
58     bool update_board(Move<char>* move) override {
59         int x = move->get_x();
60         int y = move->get_y();
61         char symbol = move->get_symbol();
62 
63         if (!is_valid_position(x, y)) {
64             cout << "Invalid position! Not in diamond shape.\n";
65             return false;
66         }
67 
68         if (board[x][y] != ' ') {
69             cout << "Cell already occupied!\n";
70             return false;
71         }
72 
73         board[x][y] = symbol;
74         n_moves++;
75         return true;
76     }
77 
78     bool is_win(Player<char>* player) override {
79         char symbol = player->get_symbol();
80         return check_three_in_row(symbol) && check_four_in_row(symbol);
81     }
82 
83     bool is_lose(Player<char>* player) override {
84         return false;
85     }
86 
87     bool is_draw(Player<char>* player) override {
88         // Count valid cells
89         int valid_cells = 0;
90         int filled_cells = 0;
91 
92         for (int i = 0; i < 5; i++) {
93             for (int j = 0; j < 5; j++) {
94                 if (board[i][j] != '#') {
95                     valid_cells++;
96                     if (board[i][j] != ' ') {
97                         filled_cells++;
98                     }
99                 }
100             }
101         }
102 
103         return (filled_cells == valid_cells && !is_win(player));
104     }
105 
106     bool game_is_over(Player<char>* player) override {
107         return is_win(player) || is_draw(player);
108     }
109 };
110 
111 // Diamond Player
112 class DiamondTicTacToe_Player : public Player<char> {
113 public:
114     DiamondTicTacToe_Player(string name, char symbol) : Player(name, symbol, PlayerType::HUMAN) {}
115 };
116 
117 // Diamond Random Player
118 class DiamondTicTacToe_RandomPlayer : public Player<char> {
119 public:
120     DiamondTicTacToe_RandomPlayer(char symbol) : Player("Random Computer", symbol, PlayerType::COMPUTER) {
121         srand(time(0));
122     }
123 };
124 
125 // Diamond UI
126 class DiamondTicTacToe_UI : public UI<char> {
127 public:
128     DiamondTicTacToe_UI() : UI("Welcome to Diamond Tic-Tac-Toe!", 3) {}
129 
130     Move<char>* get_move(Player<char>* player) override {
131         if (player->get_type() == PlayerType::HUMAN) {
132             int x, y;
133             cout << player->get_name() << " (" << player->get_symbol()
134                 << "), enter your move (row and column 0-4, in diamond shape): ";
135             cin >> x >> y;
136             return new Move<char>(x, y, player->get_symbol());
137         }
138         else {
139             int x, y;
140             do {
141                 x = rand() % 5;
142                 y = rand() % 5;
143             } while ((abs(x - 2) + abs(y - 2)) > 2); // Ensure diamond shape
144 
145             cout << player->get_name() << " chooses position (" << x << ", " << y << ")\n";
146             return new Move<char>(x, y, player->get_symbol());
147         }
148     }
149 };
150 
151 #endif // DIAMONDTICTACTOE_H

FourBoard.h File Reference
#include "BoardGame_Classes.h"
#include <vector>
Classes
class FourBoard

FourBoard.h
Go to the documentation of this file.

1 #pragma once
2 #include "BoardGame_Classes.h"
3 #include <vector>
4 
5 class FourBoard : public Board<char> {
6 public:
7     FourBoard() : Board<char>(6, 7) {
8         board = vector<vector<char>>(6, vector<char>(7, ' '));
9     }
10 
11     // Update: move->get_y() is the column chosen. We drop to lowest empty row.
12     bool update_board(Move<char>* m) override {
13         int col = m->get_y();
14         char sym = m->get_symbol();
15 
16         if (col < 0 || col >= columns) return false;
17 
18         // find lowest empty row (largest row index)
19         for (int r = rows - 1; r >= 0; --r) {
20             if (board[r][col] == ' ') {
21                 board[r][col] = sym;
22                 n_moves++;
23                 return true;
24             }
25         }
26         // column full
27         return false;
28     }
29 
30     bool is_win(Player<char>* p) override {
31         char sym = p->get_symbol();
32         // check 4-in-a-row in all directions
33         // horizontal
34         for (int r = 0; r < rows; ++r) {
35             for (int c = 0; c + 3 < columns; ++c) {
36                 if (board[r][c] == sym && board[r][c + 1] == sym && board[r][c + 2] == sym && board[r][c + 3] == sym)
37                     return true;
38             }
39         }
40         // vertical
41         for (int c = 0; c < columns; ++c) {
42             for (int r = 0; r + 3 < rows; ++r) {
43                 if (board[r][c] == sym && board[r + 1][c] == sym && board[r + 2][c] == sym && board[r + 3][c] == sym)
44                     return true;
45             }
46         }
47         // diagonal down-right
48         for (int r = 0; r + 3 < rows; ++r) {
49             for (int c = 0; c + 3 < columns; ++c) {
50                 if (board[r][c] == sym && board[r + 1][c + 1] == sym && board[r + 2][c + 2] == sym && board[r + 3][c + 3] == sym)
51                     return true;
52             }
53         }
54         // diagonal up-right
55         for (int r = 3; r < rows; ++r) {
56             for (int c = 0; c + 3 < columns; ++c) {
57                 if (board[r][c] == sym && board[r - 1][c + 1] == sym && board[r - 2][c + 2] == sym && board[r - 3][c + 3] == sym)
58                     return true;
59             }
60         }
61         return false;
62     }
63 
64     bool is_draw(Player<char>* p) override {
65         // draw if board full and no winner
66         for (int r = 0; r < rows; ++r)
67             for (int c = 0; c < columns; ++c)
68                 if (board[r][c] == ' ')
69                     return false;
70         return true;
71     }
72 
73     bool is_lose(Player<char>* p) override { return false; }
74 
75     bool game_is_over(Player<char>* p) override {
76         return is_win(p) || is_draw(p);
77     }
78 };

FourInARow.h File Reference
#include "BoardGame_Classes.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
Classes
class FourInARowBoardclass FourInARowPlayer
class FourInARowRandomPlayer
class FourInARowUI

FourInARow.h
Go to the documentation of this file.

1 #ifndef FOURINAROW_H
2 #define FOURINAROW_H
3 
4 #include "BoardGame_Classes.h"
5 #include <iostream>
6 #include <cstdlib>
7 #include <ctime>
8 using namespace std;
9 
10 // Four in a Row Board
11 class FourInARowBoard : public Board<char> {
12 private:
13     int get_lowest_empty_row(int col) {
14         for (int row = 0; row < 6; row++) {
15             if (board[row][col] == ' ') {
16                 return row;
17             }
18         }
19         return -1;
20     }
21 
22 public:
23     FourInARowBoard() : Board(6, 7) {
24         for (int i = 0; i < 6; i++) {
25             for (int j = 0; j < 7; j++) {
26                 board[i][j] = ' ';
27             }
28         }
29     }
30 
31     bool update_board(Move<char>* move) override {
32         int col = move->get_y();
33         char symbol = move->get_symbol();
34 
35         if (col < 0 || col >= 7) {
36             cout << "Invalid column! Choose 0-6.\n";
37             return false;
38         }
39 
40         int row = get_lowest_empty_row(col);
41         if (row == -1) {
42             cout << "Column " << col << " is full!\n";
43             return false;
44         }
45 
46         board[row][col] = symbol;
47         n_moves++;
48         return true;
49     }
50 
51     bool is_win(Player<char>* player) override {
52         char symbol = player->get_symbol();
53 
54         // Horizontal
55         for (int row = 0; row < 6; row++) {
56             for (int col = 0; col < 4; col++) {
57                 if (board[row][col] == symbol &&
58                     board[row][col + 1] == symbol &&
59                     board[row][col + 2] == symbol &&
60                     board[row][col + 3] == symbol)
61                     return true;
62             }
63         }
64 
65         // Vertical
66         for (int col = 0; col < 7; col++) {
67             for (int row = 0; row < 3; row++) {
68                 if (board[row][col] == symbol &&
69                     board[row + 1][col] == symbol &&
70                     board[row + 2][col] == symbol &&
71                     board[row + 3][col] == symbol)
72                     return true;
73             }
74         }
75 
76         // Diagonal down-right
77         for (int row = 0; row < 3; row++) {
78             for (int col = 0; col < 4; col++) {
79                 if (board[row][col] == symbol &&
80                     board[row + 1][col + 1] == symbol &&
81                     board[row + 2][col + 2] == symbol &&
82                     board[row + 3][col + 3] == symbol)
83                     return true;
84             }
85         }
86 
87         // Diagonal down-left
88         for (int row = 0; row < 3; row++) {
89             for (int col = 3; col < 7; col++) {
90                 if (board[row][col] == symbol &&
91                     board[row + 1][col - 1] == symbol &&
92                     board[row + 2][col - 2] == symbol &&
93                     board[row + 3][col - 3] == symbol)
94                     return true;
95             }
96         }
97 
98         return false;
99     }
100 
101     bool is_lose(Player<char>* player) override {
102         return false;
103     }
104 
105     bool is_draw(Player<char>* player) override {
106         for (int col = 0; col < 7; col++) {
107             if (board[5][col] == ' ') {
108                 return false;
109             }
110         }
111         return !is_win(player);
112     }
113 
114     bool game_is_over(Player<char>* player) override {
115         return is_win(player) || is_draw(player);
116     }
117 };
118 
119 // Four in a Row Player
120 class FourInARowPlayer : public Player<char> {
121 public:
122     FourInARowPlayer(string name, char symbol) : Player(name, symbol, PlayerType::HUMAN) {}
123 };
124 
125 // Four in a Row Random Player
126 class FourInARowRandomPlayer : public Player<char> {
127 public:
128     FourInARowRandomPlayer(char symbol) : Player("Random Computer", symbol, PlayerType::COMPUTER) {
129         srand(time(0));
130     }
131 };
132 
133 // Four in a Row UI
134 class FourInARowUI : public UI<char> {
135 public:
136     FourInARowUI() : UI("Welcome to Four-in-a-Row!", 3) {}
137 
138     Move<char>* get_move(Player<char>* player) override {
139         if (player->get_type() == PlayerType::HUMAN) {
140             int col;
141             cout << player->get_name() << " (" << player->get_symbol()
142                 << "), enter column (0-6): ";
143             cin >> col;
144             return new Move<char>(0, col, player->get_symbol());
145         }
146         else {
147             int col = rand() % 7;
148             cout << player->get_name() << " chooses column " << col << "\n";
149             return new Move<char>(0, col, player->get_symbol());
150         }
151     }
152 };
153 
154 #endif // FOURINAROW_H

FourUI.h File Reference
#include "BoardGame_Classes.h"
#include "FourBoard.h"
#include <iostream>
#include <random>
#include <chrono>
Classes
class FourUI

FourUI.h
Go to the documentation of this file.

1 #pragma once
2 #include "BoardGame_Classes.h"
3 #include "FourBoard.h"
4 #include <iostream>
5 #include <random>
6 #include <chrono>
7 class FourUI : public UI<char> {
8 public:
9     FourUI() : UI("Four-in-a-row (6x7)", 2) {}
10     void print_board(const vector<vector<char>>& b) {
11         cout << "\nColumns: ";
12         for (int c = 0; c < (int)b[0].size(); ++c) cout << c << ' ';
13         cout << "\n---------------------\n";
14         for (int r = 0; r < (int)b.size(); ++r) {
15             for (int c = 0; c < (int)b[r].size(); ++c) {
16                 char ch = b[r][c];
17                 cout << (ch == ' ' ? '.' : ch) << ' ';
18             }
19             cout << '\n';
20         }
21         cout << endl;
22     }
23     Move<char>* get_move(Player<char>* p) override {
24         FourBoard* bptr = dynamic_cast<FourBoard*>(p->get_board_ptr());
25         if (!bptr) {
26             int r, c; char s;
27             cin >> r >> c >> s;
28             return new Move<char>(r, c, s);
29         }
30 
31         auto matrix = bptr->get_board_matrix();
32         print_board(matrix);
33 
34         if (p->get_type() == PlayerType::COMPUTER) {
35 
36             vector<int> validCols;
37             for (int c = 0; c < bptr->get_columns(); ++c) {
38                 if (matrix[0][c] == ' ') validCols.push_back(c);
39             }
40             if (validCols.empty()) return new Move<char>(0, 0, p->get_symbol());
41             static std::mt19937 rng((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
42             std::uniform_int_distribution<int> dist(0, (int)validCols.size() - 1);
43             int col = validCols[dist(rng)];
44             cout << "Computer " << p->get_name() << " plays column " << col << '\n';
45             return new Move<char>(0, col, p->get_symbol()); 
46         }
47 
48         while (true) {
49             int col;
50             cout << p->get_name() << " enter column (0-" << (bptr->get_columns() - 1) << "): ";
51             if (!(cin >> col)) { cin.clear(); string garbage; getline(cin, garbage); cout << "Invalid input\n"; continue; }
52             if (col < 0 || col >= bptr->get_columns()) { cout << "Column out of range\n"; continue; }
53             if (matrix[0][col] != ' ') { cout << "Column full. Choose another.\n"; continue; }
54             return new Move<char>(0, col, p->get_symbol());
55         }
56     }
57 
58     Player<char>* create_player(string& name, char symbol, PlayerType type) override {
59         return new Player<char>(name, symbol, type);
60     }
61 };

hide.cpp File Reference
#include <iostream>
#include <iomanip>
#include <cctype>
#include "hide.h"

hide.h File Reference
#include "D:\Desktop\CU\CS213 OOP\A3 Games\Project35\BoardGame_Classes.h"
#include <deque>
#include <iostream>

hide.h
Go to the documentation of this file.

1 
9 
10 #ifndef HIDE_H
11 #define HIDE_H
12 
13 #include "D:\Desktop\CU\CS213 OOP\A3 Games\Project35\BoardGame_Classes.h"
14 #include <deque>
15 #include <iostream>
16 using namespace std;
17 
28 class hide_board : public Board<char> {
29 private:
30     char blank_symbol = '.'; 
31     deque<pair<int, int>> history;   // Ø­Ù�Ø¸ ØªØ±ØªÙŠØ¨ Ø§Ù„Ø­Ø±ÙƒØ§Øª (Ø£Ù‚Ø¯Ù… Ù�ÙŠ front)
32     int visible_window = 6;
33 public:
37     hide_board();
38 
44     bool update_board(Move<char>* move);
45 
51     bool is_win(Player<char>* player);
52 
58     bool is_lose(Player<char>*) { return false; };
59 
65     bool is_draw(Player<char>* player);
66 
72     bool game_is_over(Player<char>* player);
73 };
74 
75 
85 class hide_ui : public UI<char> {
86 public:
92     hide_ui();
93 
97     ~hide_ui() {};
98 
106     Player<char>* create_player(string& name, char symbol, PlayerType type);
107 
113     virtual Move<char>* get_move(Player<char>* player);
114 };
115 
116 #endif // XO_CLASSES_H

InfinityTicTacToe.h File Reference
#include "BoardGame_Classes.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <queue>
Classes
class InfinityTicTacToeBoardclass InfinityTicTacToe_Player
class InfinityTicTacToe_RandomPlayer
class InfinityTicTacToe_UI

InfinityTicTacToe.h
Go to the documentation of this file.

1 #ifndef INFINITYTICTACTOE_H
2 #define INFINITYTICTACTOE_H
3 
4 #include "BoardGame_Classes.h"
5 #include <iostream>
6 #include <cstdlib>
7 #include <ctime>
8 #include <queue>
9 using namespace std;
10 
11 // Infinity Tic Tac Toe Board
12 class InfinityTicTacToeBoard : public Board<char> {
13 private:
14     queue<pair<int, int>> move_history;
15 
16     void remove_oldest_move() {
17         if (move_history.empty()) return;
18 
19         auto oldest = move_history.front();
20         move_history.pop();
21         board[oldest.first][oldest.second] = ' ';
22         n_moves--;
23     }
24 
25 public:
26     InfinityTicTacToeBoard() : Board(3, 3) {
27         for (int i = 0; i < 3; i++) {
28             for (int j = 0; j < 3; j++) {
29                 board[i][j] = ' ';
30             }
31         }
32     }
33 
34     bool update_board(Move<char>* move) override {
35         int x = move->get_x();
36         int y = move->get_y();
37         char symbol = move->get_symbol();
38 
39         if (x < 0 || x >= 3 || y < 0 || y >= 3) {
40             cout << "Invalid position! Use 0-2.\n";
41             return false;
42         }
43 
44         if (board[x][y] != ' ') {
45             cout << "Cell already occupied!\n";
46             return false;
47         }
48 
49         board[x][y] = symbol;
50         move_history.push({ x, y });
51         n_moves++;
52 
53         // Remove oldest move every 3 moves
54         if (n_moves > 3) {
55             remove_oldest_move();
56         }
57 
58         return true;
59     }
60 
61     bool is_win(Player<char>* player) override {
62         char symbol = player->get_symbol();
63 
64         // Check rows
65         for (int i = 0; i < 3; i++) {
66             if (board[i][0] == symbol && board[i][1] == symbol && board[i][2] == symbol)
67                 return true;
68         }
69 
70         // Check columns
71         for (int j = 0; j < 3; j++) {
72             if (board[0][j] == symbol && board[1][j] == symbol && board[2][j] == symbol)
73                 return true;
74         }
75 
76         // Check diagonals
77         if (board[0][0] == symbol && board[1][1] == symbol && board[2][2] == symbol)
78             return true;
79         if (board[0][2] == symbol && board[1][1] == symbol && board[2][0] == symbol)
80             return true;
81 
82         return false;
83     }
84 
85     bool is_lose(Player<char>* player) override {
86         return false;
87     }
88 
89     bool is_draw(Player<char>* player) override {
90         // Infinity mode - technically no draw unless we want to limit
91         return false;
92     }
93 
94     bool game_is_over(Player<char>* player) override {
95         return is_win(player);
96     }
97 };
98 
99 // Infinity Player
100 class InfinityTicTacToe_Player : public Player<char> {
101 public:
102     InfinityTicTacToe_Player(string name, char symbol) : Player(name, symbol, PlayerType::HUMAN) {}
103 };
104 
105 // Infinity Random Player
106 class InfinityTicTacToe_RandomPlayer : public Player<char> {
107 public:
108     InfinityTicTacToe_RandomPlayer(char symbol) : Player("Random Computer", symbol, PlayerType::COMPUTER) {
109         srand(time(0));
110     }
111 };
112 
113 // Infinity UI
114 class InfinityTicTacToe_UI : public UI<char> {
115 public:
116     InfinityTicTacToe_UI() : UI("Welcome to Infinity Tic-Tac-Toe! (Oldest moves disappear)", 3) {}
117 
118     Move<char>* get_move(Player<char>* player) override {
119         if (player->get_type() == PlayerType::HUMAN) {
120             int x, y;
121             cout << player->get_name() << " (" << player->get_symbol()
122                 << "), enter your move (row and column 0-2): ";
123             cin >> x >> y;
124             return new Move<char>(x, y, player->get_symbol());
125         }
126         else {
127             int x = rand() % 3;
128             int y = rand() % 3;
129             cout << player->get_name() << " chooses position (" << x << ", " << y << ")\n";
130             return new Move<char>(x, y, player->get_symbol());
131         }
132     }
133 };
134 
135 #endif // INFINITYTICTACTOE_H

inverse.cpp File Reference
#include <iostream>
#include <iomanip>
#include <cctype>
#include "inverse.h"

inverse.h File Reference
#include "D:\Desktop\CU\CS213 OOP\A3 Games\Project35\BoardGame_Classes.h"

inverse.h
Go to the documentation of this file.

1 /***
2  /* @file XO_Classes.h
3  /* @brief Defines the X-O (Tic-Tac-Toe) specific classes that extend the generic board game framework.
4  /*
5  /* This file provides:
6  /* - `X_O_Board`: A specialized board class for the Tic-Tac-Toe game.
7  /* - `XO_UI`: A user interface class tailored to X-O game setup and player interaction.
8  /*/
9 
10 #ifndef INVERSE_H
11 #define INVERSE_H
12 
13 #include "D:\Desktop\CU\CS213 OOP\A3 Games\Project35\BoardGame_Classes.h"
14 using namespace std;
15 
26 class inverse_board : public Board<char> {
27 private:
28     char blank_symbol = '.'; 
29 
30 public:
34     inverse_board();
35 
41     bool update_board(Move<char>* move);
42 
48     bool is_win(Player<char>* player) { return false; };
49 
55     bool is_lose(Player<char>*);
56 
62     bool is_draw(Player<char>* player);
63 
69     bool game_is_over(Player<char>* player);
70 };
71 
72 
82 class inverse_ui : public UI<char> {
83 public:
89     inverse_ui();
90 
94     ~inverse_ui() {};
95 
103     Player<char>* create_player(string& name, char symbol, PlayerType type);
104 
110     virtual Move<char>* get_move(Player<char>* player);
111 };
112 
113 #endif // INVERSE_H

main.cpp File Reference
#include "XO.h"
#include "SUS.h"
#include "FourInARow.h"
#include "TicTacToe5x5.h"
#include "wordTic_tac_toe.h"
#include "MisereTicTacToe.h"
#include "DiamondTicTacToe.h"
#include "TicTacToe4x4.h"
#include "Pyramic_XO.h"
#include "NumericalTicTacToe.h"
#include "ObstaclesTicTacToe.h"
#include "InfinityTicTacToe.h"
#include "UltimateTicTacToe.h"
#include "MemoryTicTacToe.h"
#include <iostream>
Functions
void create_and_run_char_game (int choice)
void create_and_run_int_game ()
int main ()

Function Documentation
void create_and_run_char_game (int choice)
void create_and_run_int_game ()
int main ()

MemoryTicTacToe.h File Reference
#include "BoardGame_Classes.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
Classes
class MemoryTicTacToeBoardclass MemoryTicTacToe_Player
class MemoryTicTacToe_RandomPlayer
class MemoryTicTacToe_UI

MemoryTicTacToe.h
Go to the documentation of this file.

1 #ifndef MEMORYTICTACTOE_H
2 #define MEMORYTICTACTOE_H
3 
4 #include "BoardGame_Classes.h"
5 #include <iostream>
6 #include <cstdlib>
7 #include <ctime>
8 using namespace std;
9 
10 // Memory Tic Tac Toe Board
11 class MemoryTicTacToeBoard : public Board<char> {
12 private:
13     char hidden_board[3][3]; // Actual board with hidden marks
14 
15     void reveal_all() {
16         for (int i = 0; i < 3; i++) {
17             for (int j = 0; j < 3; j++) {
18                 board[i][j] = hidden_board[i][j];
19             }
20         }
21     }
22 
23 public:
24     MemoryTicTacToeBoard() : Board(3, 3) {
25         for (int i = 0; i < 3; i++) {
26             for (int j = 0; j < 3; j++) {
27                 board[i][j] = '?'; // Hidden symbol
28                 hidden_board[i][j] = ' ';
29             }
30         }
31     }
32 
33     bool update_board(Move<char>* move) override {
34         int x = move->get_x();
35         int y = move->get_y();
36         char symbol = move->get_symbol();
37 
38         if (x < 0 || x >= 3 || y < 0 || y >= 3) {
39             cout << "Invalid position! Use 0-2.\n";
40             return false;
41         }
42 
43         if (hidden_board[x][y] != ' ') {
44             cout << "Cell already occupied!\n";
45             return false;
46         }
47 
48         hidden_board[x][y] = symbol;
49         n_moves++;
50 
51         // Keep board hidden
52         board[x][y] = '?';
53 
54         return true;
55     }
56 
57     bool is_win(Player<char>* player) override {
58         char symbol = player->get_symbol();
59 
60         // Check hidden board
61         // Rows
62         for (int i = 0; i < 3; i++) {
63             if (hidden_board[i][0] == symbol && hidden_board[i][1] == symbol && hidden_board[i][2] == symbol)
64                 return true;
65         }
66 
67         // Columns
68         for (int j = 0; j < 3; j++) {
69             if (hidden_board[0][j] == symbol && hidden_board[1][j] == symbol && hidden_board[2][j] == symbol)
70                 return true;
71         }
72 
73         // Diagonals
74         if (hidden_board[0][0] == symbol && hidden_board[1][1] == symbol && hidden_board[2][2] == symbol)
75             return true;
76         if (hidden_board[0][2] == symbol && hidden_board[1][1] == symbol && hidden_board[2][0] == symbol)
77             return true;
78 
79         return false;
80     }
81 
82     bool is_lose(Player<char>* player) override {
83         return false;
84     }
85 
86     bool is_draw(Player<char>* player) override {
87         // Check if board is full
88         for (int i = 0; i < 3; i++) {
89             for (int j = 0; j < 3; j++) {
90                 if (hidden_board[i][j] == ' ') {
91                     return false;
92                 }
93             }
94         }
95         return !is_win(player);
96     }
97 
98     bool game_is_over(Player<char>* player) override {
99         bool over = is_win(player) || is_draw(player);
100         if (over) {
101             reveal_all();
102         }
103         return over;
104     }
105 };
106 
107 // Memory Player
108 class MemoryTicTacToe_Player : public Player<char> {
109 public:
110     MemoryTicTacToe_Player(string name, char symbol) : Player(name, symbol, PlayerType::HUMAN) {}
111 };
112 
113 // Memory Random Player
114 class MemoryTicTacToe_RandomPlayer : public Player<char> {
115 public:
116     MemoryTicTacToe_RandomPlayer(char symbol) : Player("Random Computer", symbol, PlayerType::COMPUTER) {
117         srand(time(0));
118     }
119 };
120 
121 // Memory UI
122 class MemoryTicTacToe_UI : public UI<char> {
123 public:
124     MemoryTicTacToe_UI() : UI("Welcome to Memory Tic-Tac-Toe! (Marks are hidden)", 3) {}
125 
126     Move<char>* get_move(Player<char>* player) override {
127         if (player->get_type() == PlayerType::HUMAN) {
128             int x, y;
129             cout << player->get_name() << " (" << player->get_symbol()
130                 << "), enter your move (row and column 0-2): ";
131             cin >> x >> y;
132             return new Move<char>(x, y, player->get_symbol());
133         }
134         else {
135             int x = rand() % 3;
136             int y = rand() % 3;
137             cout << player->get_name() << " chooses position (" << x << ", " << y << ")\n";
138             return new Move<char>(x, y, player->get_symbol());
139         }
140     }
141 };
142 
143 #endif // MEMORYTICTACTOE_H

MisereTicTacToe.h File Reference
#include "BoardGame_Classes.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
Classes
class MisereTicTacToe_Boardclass MisereTicTacToe_Player
class MisereTicTacToe_RandomPlayer
class MisereTicTacToe_UI

MisereTicTacToe.h
Go to the documentation of this file.

1 #ifndef MISERETICTACTOE_H
2 #define MISERETICTACTOE_H
3 
4 #include "BoardGame_Classes.h"
5 #include <iostream>
6 #include <cstdlib>
7 #include <ctime>
8 using namespace std;
9 
10 // Misï¿½re Tic Tac Toe Board
11 class MisereTicTacToe_Board : public Board<char> {
12 public:
13     MisereTicTacToe_Board() : Board(3, 3) {
14         for (int i = 0; i < 3; i++) {
15             for (int j = 0; j < 3; j++) {
16                 board[i][j] = ' ';
17             }
18         }
19     }
20 
21     bool update_board(Move<char>* move) override {
22         int x = move->get_x();
23         int y = move->get_y();
24         char symbol = move->get_symbol();
25 
26         if (x < 0 || x >= 3 || y < 0 || y >= 3) {
27             cout << "Invalid position! Use 0-2.\n";
28             return false;
29         }
30 
31         if (board[x][y] != ' ') {
32             cout << "Cell already occupied!\n";
33             return false;
34         }
35 
36         board[x][y] = symbol;
37         n_moves++;
38         return true;
39     }
40 
41     bool is_win(Player<char>* player) override {
42         // In Misere, if you get three in a row, you LOSE
43         // So this should check if opponent wins
44         return false;
45     }
46 
47     bool is_lose(Player<char>* player) override {
48         char symbol = player->get_symbol();
49 
50         // Check if player has three in a row (they lose)
51         // Rows
52         for (int i = 0; i < 3; i++) {
53             if (board[i][0] == symbol && board[i][1] == symbol && board[i][2] == symbol)
54                 return true;
55         }
56 
57         // Columns
58         for (int j = 0; j < 3; j++) {
59             if (board[0][j] == symbol && board[1][j] == symbol && board[2][j] == symbol)
60                 return true;
61         }
62 
63         // Diagonals
64         if (board[0][0] == symbol && board[1][1] == symbol && board[2][2] == symbol)
65             return true;
66         if (board[0][2] == symbol && board[1][1] == symbol && board[2][0] == symbol)
67             return true;
68 
69         return false;
70     }
71 
72     bool is_draw(Player<char>* player) override {
73         return (n_moves == 9 && !is_lose(player));
74     }
75 
76     bool game_is_over(Player<char>* player) override {
77         return is_lose(player) || is_draw(player);
78     }
79 };
80 
81 // Misere Player
82 class MisereTicTacToe_Player : public Player<char> {
83 public:
84     MisereTicTacToe_Player(string name, char symbol) : Player(name, symbol, PlayerType::HUMAN) {}
85 };
86 
87 // Misere Random Player
88 class MisereTicTacToe_RandomPlayer : public Player<char> {
89 public:
90     MisereTicTacToe_RandomPlayer(char symbol) : Player("Random Computer", symbol, PlayerType::COMPUTER) {
91         srand(time(0));
92     }
93 };
94 
95 // Misere UI
96 class MisereTicTacToe_UI : public UI<char> {
97 public:
98     MisereTicTacToe_UI() : UI("Welcome to Misere Tic-Tac-Toe! (Avoid 3 in a row)", 3) {}
99 
100     Move<char>* get_move(Player<char>* player) override {
101         if (player->get_type() == PlayerType::HUMAN) {
102             int x, y;
103             cout << player->get_name() << " (" << player->get_symbol()
104                 << "), enter your move (row and column 0-2): ";
105             cin >> x >> y;
106             return new Move<char>(x, y, player->get_symbol());
107         }
108         else {
109             int x = rand() % 3;
110             int y = rand() % 3;
111             cout << player->get_name() << " chooses position (" << x << ", " << y << ")\n";
112             return new Move<char>(x, y, player->get_symbol());
113         }
114     }
115 };
116 
117 #endif // MISERETICTACTOE_H
118 

Numerical_Board.h File Reference
#include "BoardGame_Classes.h"
Classes
class Numerical_Board

Numerical_Board.h
Go to the documentation of this file.

1 #pragma once
2 #include "BoardGame_Classes.h"
3 
4 class Numerical_Board : public Board<int> {
5 public:
6     Numerical_Board() : Board(3, 3) {
7         for (auto& r : board) fill(r.begin(), r.end(), 0);
8     }
9 
10     bool update_board(Move<int>* m) override {
11         int x = m->get_x(), y = m->get_y(), val = m->get_symbol();
12         if (x < 0 || x >= 3 || y < 0 || y >= 3 || board[x][y] != 0)
13             return false;
14         board[x][y] = val;
15         return true;
16     }
17 
18     bool is_win(Player<int>* p) override {
19         for (int i = 0; i < 3; i++) {
20             if (board[i][0] + board[i][1] + board[i][2] == 15) return true;
21             if (board[0][i] + board[1][i] + board[2][i] == 15) return true;
22         }
23         if (board[0][0] + board[1][1] + board[2][2] == 15) return true;
24         if (board[0][2] + board[1][1] + board[2][0] == 15) return true;
25         return false;
26     }
27 
28     bool is_draw(Player<int>* p) override {
29         for (auto& r : board)
30             for (int c : r)
31                 if (c == 0) return false;
32         return !is_win(p);
33     }
34 
35     bool is_lose(Player<int>* p) override { return false; }
36 
37     bool game_is_over(Player<int>* p) override {
38         return is_win(p) || is_draw(p);
39     }
40 };

Numerical_Player.h File Reference
#include "BoardGame_Classes.h"
Classes
class Numerical_Player

Numerical_Player.h
Go to the documentation of this file.

1 #pragma once
2 #include "BoardGame_Classes.h"
3 
4 class Numerical_Player : public Player<int> {
5 public:
6     bool isOdd;
7     Numerical_Player(string n, bool odd, PlayerType t)
8         : Player<int>(n, 0, t), isOdd(odd) {}
9 };
10 

Numerical_UI.h File Reference
#include "BoardGame_Classes.h"
#include "Numerical_Player.h"
#include "Numerical_Board.h"
#include <cstdlib>
#include <ctime>
Classes
class Numerical_UI

Numerical_UI.h
Go to the documentation of this file.

1 #pragma once
2 #include "BoardGame_Classes.h"
3 #include "Numerical_Player.h"
4 #include "Numerical_Board.h"
5 #include <cstdlib>
6 #include <ctime>
7 
8 class Numerical_UI : public UI<int> {
9 public:
10     Numerical_UI() : UI<int>("Numerical Tic Tac Toe", 2) {}
11 
12     void display_board_matrix(const vector<vector<int>>& b) const {
13         cout << "\nBoard:\n";
14         for (auto& r : b) {
15             for (int c : r)
16                 cout << (c == 0 ? '.' : char('0' + c)) << " ";
17             cout << endl;
18         }
19     }
20 
21     Move<int>* get_move(Player<int>* p) override {
22         auto np = (Numerical_Player*)p;
23         int x, y, val;
24 
25         // Computer move
26         if (p->get_type() == PlayerType::COMPUTER) {
27             srand(time(0));
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";
31             return new Move<int>(x, y, val);
32         }
33 
34         // Human move
35         while (true) {
36             cout << "\n" << p->get_name() << " enter row and column (0-2): ";
37             cin >> x >> y;
38             cout << "Enter a " << (np->isOdd ? "odd" : "even") << " number: ";
39             cin >> val;
40 
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; }
44             return new Move<int>(x, y, val);
45         }
46     }
47 
48     Player<int>* create_player(string& n, int symbol, PlayerType t) override {
49         return new Numerical_Player(n, true, t);
50     }
51 };
52 
53 
54 

NumericalTicTacToe.h File Reference
#include "BoardGame_Classes.h"
#include <iostream>
#include <set>
#include <cstdlib>
#include <ctime>
Classes
class NumericalTicTacToeBoardclass NumericalTicTacToePlayer
class NumericalTicTacToeRandomPlayer
class NumericalTicTacToeUI

NumericalTicTacToe.h
Go to the documentation of this file.

1 #ifndef NUMERICALTICTACTOE_H
2 #define NUMERICALTICTACTOE_H
3 
4 #include "BoardGame_Classes.h"
5 #include <iostream>
6 #include <set>
7 #include <cstdlib>
8 #include <ctime>
9 using namespace std;
10 
11 // Numerical Tic Tac Toe Board
12 class NumericalTicTacToeBoard : public Board<int> {
13 private:
14     set<int> used_numbers;
15 
16     bool check_sum(int a, int b, int c) {
17         return (a + b + c == 15);
18     }
19 
20 public:
21     NumericalTicTacToeBoard() : Board(3, 3) {
22         for (int i = 0; i < 3; i++) {
23             for (int j = 0; j < 3; j++) {
24                 board[i][j] = 0;
25             }
26         }
27     }
28 
29     bool update_board(Move<int>* move) override {
30         int x = move->get_x();
31         int y = move->get_y();
32         int number = move->get_symbol();
33 
34         if (x < 0 || x >= 3 || y < 0 || y >= 3) {
35             cout << "Invalid position! Use 0-2.\n";
36             return false;
37         }
38 
39         if (board[x][y] != 0) {
40             cout << "Cell already occupied!\n";
41             return false;
42         }
43 
44         if (number < 1 || number > 9) {
45             cout << "Number must be 1-9!\n";
46             return false;
47         }
48 
49         if (used_numbers.find(number) != used_numbers.end()) {
50             cout << "Number " << number << " already used!\n";
51             return false;
52         }
53 
54         // Check parity: Player 1 (odd moves) uses odd numbers, Player 2 uses even
55         if ((n_moves % 2 == 0 && number % 2 == 0) ||
56             (n_moves % 2 == 1 && number % 2 == 1)) {
57             cout << "Wrong number type! Player " << (n_moves % 2 == 0 ? "1" : "2")
58                 << " must use " << (n_moves % 2 == 0 ? "odd" : "even") << " number.\n";
59             return false;
60         }
61 
62         board[x][y] = number;
63         used_numbers.insert(number);
64         n_moves++;
65         return true;
66     }
67 
68     bool is_win(Player<int>* player) override {
69         // Check rows
70         for (int i = 0; i < 3; i++) {
71             if (check_sum(board[i][0], board[i][1], board[i][2]))
72                 return true;
73         }
74 
75         // Check columns
76         for (int j = 0; j < 3; j++) {
77             if (check_sum(board[0][j], board[1][j], board[2][j]))
78                 return true;
79         }
80 
81         // Check diagonals
82         if (check_sum(board[0][0], board[1][1], board[2][2]) ||
83             check_sum(board[0][2], board[1][1], board[2][0]))
84             return true;
85 
86         return false;
87     }
88 
89     bool is_lose(Player<int>* player) override {
90         return false;
91     }
92 
93     bool is_draw(Player<int>* player) override {
94         return (n_moves == 9 && !is_win(player));
95     }
96 
97     bool game_is_over(Player<int>* player) override {
98         return is_win(player) || is_draw(player);
99     }
100 };
101 
102 // Numerical Player
103 class NumericalTicTacToePlayer : public Player<int> {
104 public:
105     NumericalTicTacToePlayer(string name, int symbol) : Player(name, symbol, PlayerType::HUMAN) {}
106 };
107 
108 // Numerical Random Player
109 class NumericalTicTacToeRandomPlayer : public Player<int> {
110 public:
111     NumericalTicTacToeRandomPlayer(int symbol) : Player("Random Computer", symbol, PlayerType::COMPUTER) {
112         srand(time(0));
113     }
114 };
115 
116 // Numerical UI
117 class NumericalTicTacToeUI : public UI<int> {
118 public:
119     NumericalTicTacToeUI() : UI("Welcome to Numerical Tic-Tac-Toe!", 3) {}
120 
121     Move<int>* get_move(Player<int>* player) override {
122         if (player->get_type() == PlayerType::HUMAN) {
123             int x, y, number;
124             cout << player->get_name() << " ("
125                 << (player->get_symbol() == 1 ? "Odd" : "Even")
126                 << " numbers), enter your move (row, column, and number): ";
127             cin >> x >> y >> number;
128             return new Move<int>(x, y, number);
129         }
130         else {
131             int x = rand() % 3;
132             int y = rand() % 3;
133             int number;
134 
135             // Generate appropriate number based on turn
136             if (player->get_symbol() == 1) { // Odd numbers
137                 number = (rand() % 5) * 2 + 1; // 1, 3, 5, 7, 9
138             }
139             else { // Even numbers
140                 number = (rand() % 4) * 2 + 2; // 2, 4, 6, 8
141             }
142 
143             cout << player->get_name() << " chooses position (" << x << ", " << y
144                 << ") with number " << number << "\n";
145             return new Move<int>(x, y, number);
146         }
147     }
148 };
149 
150 #endif // NUMERICALTICTACTOE_H
151 

ObstaclesTicTacToe.h File Reference
#include "BoardGame_Classes.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>
Classes
class ObstaclesTicTacToeBoardclass ObstaclesTicTacToe_Player
class ObstaclesTicTacToe_RandomPlayer
class ObstaclesTicTacToe_UI

ObstaclesTicTacToe.h
Go to the documentation of this file.

1 #ifndef OBSTACLESTICTACTOE_H
2 #define OBSTACLESTICTACTOE_H
3 
4 #include "BoardGame_Classes.h"
5 #include <iostream>
6 #include <cstdlib>
7 #include <ctime>
8 #include <vector>
9 using namespace std;
10 
11 // Obstacles Tic Tac Toe Board
12 class ObstaclesTicTacToeBoard : public Board<char> {
13 private:
14     vector<pair<int, int>> obstacles;
15     int moves_since_last_obstacle = 0;
16 
17     void add_random_obstacle() {
18         int x, y;
19         do {
20             x = rand() % 6;
21             y = rand() % 6;
22         } while (board[x][y] != ' ' || is_obstacle(x, y));
23 
24         obstacles.push_back({ x, y });
25         board[x][y] = '#'; // Obstacle symbol
26     }
27 
28     bool is_obstacle(int x, int y) {
29         for (auto& obs : obstacles) {
30             if (obs.first == x && obs.second == y)
31                 return true;
32         }
33         return false;
34     }
35 
36 public:
37     ObstaclesTicTacToeBoard() : Board(6, 6) {
38         for (int i = 0; i < 6; i++) {
39             for (int j = 0; j < 6; j++) {
40                 board[i][j] = ' ';
41             }
42         }
43         srand(time(0));
44     }
45 
46     bool update_board(Move<char>* move) override {
47         int x = move->get_x();
48         int y = move->get_y();
49         char symbol = move->get_symbol();
50 
51         if (x < 0 || x >= 6 || y < 0 || y >= 6) {
52             cout << "Invalid position! Use 0-5.\n";
53             return false;
54         }
55 
56         if (is_obstacle(x, y)) {
57             cout << "Cell is an obstacle!\n";
58             return false;
59         }
60 
61         if (board[x][y] != ' ') {
62             cout << "Cell already occupied!\n";
63             return false;
64         }
65 
66         board[x][y] = symbol;
67         n_moves++;
68         moves_since_last_obstacle++;
69 
70         // Add obstacles every 2 moves
71         if (moves_since_last_obstacle >= 2) {
72             for (int i = 0; i < 2; i++) {
73                 add_random_obstacle();
74             }
75             moves_since_last_obstacle = 0;
76             cout << "Two new obstacles added!\n";
77         }
78 
79         return true;
80     }
81 
82     bool is_win(Player<char>* player) override {
83         char symbol = player->get_symbol();
84 
85         // Check 4 in a row
86         // Horizontal
87         for (int i = 0; i < 6; i++) {
88             for (int j = 0; j < 3; j++) {
89                 if (board[i][j] == symbol && board[i][j + 1] == symbol &&
90                     board[i][j + 2] == symbol && board[i][j + 3] == symbol)
91                     return true;
92             }
93         }
94 
95         // Vertical
96         for (int j = 0; j < 6; j++) {
97             for (int i = 0; i < 3; i++) {
98                 if (board[i][j] == symbol && board[i + 1][j] == symbol &&
99                     board[i + 2][j] == symbol && board[i + 3][j] == symbol)
100                     return true;
101             }
102         }
103 
104         // Diagonals
105         for (int i = 0; i < 3; i++) {
106             for (int j = 0; j < 3; j++) {
107                 if (board[i][j] == symbol && board[i + 1][j + 1] == symbol &&
108                     board[i + 2][j + 2] == symbol && board[i + 3][j + 3] == symbol)
109                     return true;
110             }
111         }
112 
113         for (int i = 0; i < 3; i++) {
114             for (int j = 3; j < 6; j++) {
115                 if (board[i][j] == symbol && board[i + 1][j - 1] == symbol &&
116                     board[i + 2][j - 2] == symbol && board[i + 3][j - 3] == symbol)
117                     return true;
118             }
119         }
120 
121         return false;
122     }
123 
124     bool is_lose(Player<char>* player) override {
125         return false;
126     }
127 
128     bool is_draw(Player<char>* player) override {
129         // Check if board is full (no empty cells except obstacles)
130         for (int i = 0; i < 6; i++) {
131             for (int j = 0; j < 6; j++) {
132                 if (board[i][j] == ' ') {
133                     return false;
134                 }
135             }
136         }
137         return !is_win(player);
138     }
139 
140     bool game_is_over(Player<char>* player) override {
141         return is_win(player) || is_draw(player);
142     }
143 };
144 
145 // Obstacles Player
146 class ObstaclesTicTacToe_Player : public Player<char> {
147 public:
148     ObstaclesTicTacToe_Player(string name, char symbol) : Player(name, symbol, PlayerType::HUMAN) {}
149 };
150 
151 // Obstacles Random Player
152 class ObstaclesTicTacToe_RandomPlayer : public Player<char> {
153 public:
154     ObstaclesTicTacToe_RandomPlayer(char symbol) : Player("Random Computer", symbol, PlayerType::COMPUTER) {
155         srand(time(0));
156     }
157 };
158 
159 // Obstacles UI
160 class ObstaclesTicTacToe_UI : public UI<char> {
161 public:
162     ObstaclesTicTacToe_UI() : UI("Welcome to Obstacles Tic-Tac-Toe! (4 in a row, obstacles appear)", 3) {}
163 
164     Move<char>* get_move(Player<char>* player) override {
165         if (player->get_type() == PlayerType::HUMAN) {
166             int x, y;
167             cout << player->get_name() << " (" << player->get_symbol()
168                 << "), enter your move (row and column 0-5): ";
169             cin >> x >> y;
170             return new Move<char>(x, y, player->get_symbol());
171         }
172         else {
173             int x = rand() % 6;
174             int y = rand() % 6;
175             cout << player->get_name() << " chooses position (" << x << ", " << y << ")\n";
176             return new Move<char>(x, y, player->get_symbol());
177         }
178     }
179 };
180 
181 #endif // OBSTACLESTICTACTOE_H

Pyramic_XO.h File Reference
#include "BoardGame_Classes.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
Classes
class Pyramic_XO_Boardclass Pyramic_XO_Player
class Pyramic_XO_RandomPlayer
class Pyramic_XO_UI

Pyramic_XO.h
Go to the documentation of this file.

1 #ifndef PYRAMIC_XO_H
2 #define PYRAMIC_XO_H
3 
4 #include "BoardGame_Classes.h"
5 #include <iostream>
6 #include <cstdlib>
7 #include <ctime>
8 using namespace std;
9 
10 // Pyramid Tic Tac Toe Board
11 class Pyramic_XO_Board : public Board<char> {
12 private:
13     bool is_valid_position(int x, int y) {
14         if (x < 0 || x >= 3 || y < 0 || y >= 5) return false;
15         int start = (5 - (2 * x + 1)) / 2;
16         int end = start + (2 * x + 1);
17         return (y >= start && y < end);
18     }
19 
20 public:
21     Pyramic_XO_Board() : Board(3, 5) {
22         for (int i = 0; i < 3; i++) {
23             for (int j = 0; j < 5; j++) {
24                 if (is_valid_position(i, j)) {
25                     board[i][j] = '.';
26                 }
27                 else {
28                     board[i][j] = '#'; // Invalid position
29                 }
30             }
31         }
32     }
33 
34     bool update_board(Move<char>* move) override {
35         int x = move->get_x();
36         int y = move->get_y();
37         char symbol = move->get_symbol();
38 
39         if (!is_valid_position(x, y)) {
40             cout << "Invalid position! Not in pyramid shape.\n";
41             return false;
42         }
43 
44         if (board[x][y] != '.') {
45             cout << "Cell already occupied!\n";
46             return false;
47         }
48 
49         board[x][y] = symbol;
50         n_moves++;
51         return true;
52     }
53 
54     bool is_win(Player<char>* player) override {
55         char symbol = player->get_symbol();
56 
57         // Check center column
58         if (board[0][2] == symbol && board[1][2] == symbol && board[2][2] == symbol)
59             return true;
60 
61         // Check rows
62         for (int i = 0; i < 3; i++) {
63             int start = (5 - (2 * i + 1)) / 2;
64             int end = start + (2 * i + 1);
65             for (int j = start; j <= end - 3; j++) {
66                 if (board[i][j] == symbol && board[i][j + 1] == symbol && board[i][j + 2] == symbol)
67                     return true;
68             }
69         }
70 
71         // Check diagonals
72         if (board[0][2] == symbol && board[1][1] == symbol && board[2][0] == symbol)
73             return true;
74         if (board[0][2] == symbol && board[1][3] == symbol && board[2][4] == symbol)
75             return true;
76 
77         return false;
78     }
79 
80     bool is_lose(Player<char>* player) override {
81         return false;
82     }
83 
84     bool is_draw(Player<char>* player) override {
85         // Count valid cells (9 in pyramid)
86         int valid_cells = 0;
87         int filled_cells = 0;
88 
89         for (int i = 0; i < 3; i++) {
90             for (int j = 0; j < 5; j++) {
91                 if (board[i][j] != '#') {
92                     valid_cells++;
93                     if (board[i][j] != '.') {
94                         filled_cells++;
95                     }
96                 }
97             }
98         }
99 
100         return (filled_cells == valid_cells && !is_win(player));
101     }
102 
103     bool game_is_over(Player<char>* player) override {
104         return is_win(player) || is_draw(player);
105     }
106 };
107 
108 // Pyramid Player
109 class Pyramic_XO_Player : public Player<char> {
110 public:
111     Pyramic_XO_Player(string name, char symbol) : Player(name, symbol, PlayerType::HUMAN) {}
112 };
113 
114 // Pyramid Random Player
115 class Pyramic_XO_RandomPlayer : public Player<char> {
116 public:
117     Pyramic_XO_RandomPlayer(char symbol) : Player("Random Computer", symbol, PlayerType::COMPUTER) {
118         srand(time(0));
119     }
120 };
121 
122 // Pyramid UI
123 class Pyramic_XO_UI : public UI<char> {
124 public:
125     Pyramic_XO_UI() : UI("Welcome to Pyramid Tic-Tac-Toe!", 3) {}
126 
127     Move<char>* get_move(Player<char>* player) override {
128         if (player->get_type() == PlayerType::HUMAN) {
129             int x, y;
130             cout << player->get_name() << " (" << player->get_symbol()
131                 << "), enter your move (row 0-2, column 0-4 in pyramid shape): ";
132             cin >> x >> y;
133             return new Move<char>(x, y, player->get_symbol());
134         }
135         else {
136             int x, y;
137             do {
138                 x = rand() % 3;
139                 y = rand() % 5;
140             } while (!is_valid_pyramid_position(x, y));
141 
142             cout << player->get_name() << " chooses position (" << x << ", " << y << ")\n";
143             return new Move<char>(x, y, player->get_symbol());
144         }
145     }
146 
147 private:
148     bool is_valid_pyramid_position(int x, int y) {
149         int start = (5 - (2 * x + 1)) / 2;
150         int end = start + (2 * x + 1);
151         return (x >= 0 && x < 3 && y >= start && y < end);
152     }
153 };
154 
155 #endif // PYRAMIC_XO_H

SUS.h File Reference
#include "BoardGame_Classes.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
Classes
class SUS_Boardclass SUS_Player
class SUS_Random_Player
class SUS_UI

SUS.h
Go to the documentation of this file.

1 #ifndef SUS_H
2 #define SUS_H
3 
4 #include "BoardGame_Classes.h"
5 #include <iostream>
6 #include <cstdlib>
7 #include <ctime>
8 using namespace std;
9 
10 // SUS Board
11 class SUS_Board : public Board<char> {
12 private:
13     int count_SUS_sequences(char symbol) {
14         int count = 0;
15         string target = "SUS";
16 
17         // Check rows
18         for (int i = 0; i < 3; i++) {
19             string row;
20             for (int j = 0; j < 3; j++) row += board[i][j];
21             if (row == target) count++;
22         }
23 
24         // Check columns
25         for (int j = 0; j < 3; j++) {
26             string col;
27             for (int i = 0; i < 3; i++) col += board[i][j];
28             if (col == target) count++;
29         }
30 
31         // Check diagonals
32         string diag1 = string(1, board[0][0]) + string(1, board[1][1]) + string(1, board[2][2]);
33         string diag2 = string(1, board[0][2]) + string(1, board[1][1]) + string(1, board[2][0]);
34         if (diag1 == target) count++;
35         if (diag2 == target) count++;
36 
37         return count;
38     }
39 
40 public:
41     SUS_Board() : Board(3, 3) {
42         for (int i = 0; i < 3; i++) {
43             for (int j = 0; j < 3; j++) {
44                 board[i][j] = ' ';
45             }
46         }
47     }
48 
49     bool update_board(Move<char>* move) override {
50         int x = move->get_x();
51         int y = move->get_y();
52         char symbol = move->get_symbol();
53 
54         if (x < 0 || x >= 3 || y < 0 || y >= 3) {
55             cout << "Invalid position! Use 0-2.\n";
56             return false;
57         }
58 
59         if (board[x][y] != ' ') {
60             cout << "Cell already occupied!\n";
61             return false;
62         }
63 
64         if (symbol != 'S' && symbol != 'U') {
65             cout << "Invalid symbol! Use only S or U.\n";
66             return false;
67         }
68 
69         board[x][y] = symbol;
70         n_moves++;
71         return true;
72     }
73 
74     bool is_win(Player<char>* player) override {
75         // Game doesn't have immediate win condition
76         return false;
77     }
78 
79     bool is_lose(Player<char>* player) override {
80         return false;
81     }
82 
83     bool is_draw(Player<char>* player) override {
84         return (n_moves == 9);
85     }
86 
87     bool game_is_over(Player<char>* player) override {
88         return is_draw(player);
89     }
90 
91     pair<int, int> get_scores() {
92         int x_score = count_SUS_sequences('X');
93         int o_score = count_SUS_sequences('O');
94         return make_pair(x_score, o_score);
95     }
96 };
97 
98 // SUS Player
99 class SUS_Player : public Player<char> {
100 public:
101     SUS_Player(string name, char symbol) : Player(name, symbol, PlayerType::HUMAN) {}
102 };
103 
104 // SUS Random Player
105 class SUS_Random_Player : public Player<char> {
106 public:
107     SUS_Random_Player(char symbol) : Player("Random Computer", symbol, PlayerType::COMPUTER) {
108         srand(time(0));
109     }
110 };
111 
112 // SUS UI
113 class SUS_UI : public UI<char> {
114 public:
115     SUS_UI() : UI("Welcome to SUS Game!", 3) {}
116 
117     Move<char>* get_move(Player<char>* player) override {
118         if (player->get_type() == PlayerType::HUMAN) {
119             int x, y;
120             char symbol;
121             cout << player->get_name() << " (" << player->get_symbol()
122                 << "), enter your move (row, column, and S/U): ";
123             cin >> x >> y >> symbol;
124             symbol = toupper(symbol);
125             return new Move<char>(x, y, symbol);
126         }
127         else {
128             int x = rand() % 3;
129             int y = rand() % 3;
130             char symbol = (rand() % 2 == 0) ? 'S' : 'U';
131             cout << player->get_name() << " chooses position (" << x << ", " << y
132                 << ") with symbol " << symbol << "\n";
133             return new Move<char>(x, y, symbol);
134         }
135     }
136 };
137 
138 #endif // SUS_H
139 

SUSBoard.h File Reference
#include "BoardGame_Classes.h"
Classes
class SUSBoard

SUSBoard.h
Go to the documentation of this file.

1 #pragma once
2 #include "BoardGame_Classes.h"
3 
4 class SUSBoard : public Board<char> {
5 private:
6     int score_x, score_o;
7 
8 public:
9     SUSBoard() : Board<char>(3, 3) {
10         for (int i = 0; i < 3; i++)
11             for (int j = 0; j < 3; j++)
12                 board[i][j] = ' ';
13         score_x = score_o = 0;
14     }
15 
16     int count_xux() {
17         int c = 0;
18 
19         for (int r = 0; r < 3; r++)
20             if (board[r][0] == 'X' && board[r][1] == 'O' && board[r][2] == 'X')
21                 c++;
22 
23         for (int col = 0; col < 3; col++)
24             if (board[0][col] == 'X' && board[1][col] == 'O' && board[2][col] == 'X')
25                 c++;
26 
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++;
29 
30         return c;
31     }
32 
33     bool update_board(Move<char>* m) override {
34         int x = m->get_x(), y = m->get_y();
35         char sym = m->get_symbol();
36 
37         if (x < 0 || x >= 3 || y < 0 || y >= 3) return false;
38         if (board[x][y] != ' ') return false;
39 
40         board[x][y] = sym;
41 
42         int s = count_xux();
43         score_x = s;
44         score_o = s;
45 
46         n_moves++;
47         return true;
48     }
49 
50     bool full() {
51         return n_moves == 9;
52     }
53 
54     bool is_win(Player<char>* p) override {
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;
58         return false;
59     }
60 
61     bool is_lose(Player<char>* p) override {
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;
65         return false;
66     }
67 
68     bool is_draw(Player<char>* p) override {
69         return full() && score_x == score_o;
70     }
71 
72     bool game_is_over(Player<char>* p) override {
73         return full();
74     }
75 
76     vector<vector<char>> get_board_matrix() const {
77         return board;
78     }
79 
80 };
81 
82 
83 
84 

SUSUI.h File Reference
#include "BoardGame_Classes.h"
#include <iostream>
Classes
class SUSUI

SUSUI.h
Go to the documentation of this file.

1 #pragma once
2 #include "BoardGame_Classes.h"
3 #include <iostream>
4 using namespace std;
5 
6 class SUSUI : public UI<char> {
7 public:
8 
9 
10     //SUSUI() : UI<char>(3) {}
11     SUSUI() : UI<char>("SUS Game", 3) {}  //constructo
12     Move<char>* get_move(Player<char>* p) override {
13         int x, y;
14         //Added Computer Log
15         if (p->get_type() == PlayerType::COMPUTER) {
16             // Computer move logic
17             srand(static_cast<unsigned int>(time(0)));
18             auto board_matrix = p->get_board_ptr()->get_board_matrix();
19             do {
20                 x = rand() % 3;
21                 y = rand() % 3;
22             } while (board_matrix[x][y] != ' ');
23             cout << "\nComputer played at (" << x << "," << y << ")\n";
24             return new Move<char>(x, y, p->get_symbol());
25         }
26         else {
27             // Human move
28             cout << p->get_name() << " (" << p->get_symbol() << ") enter x y (0-2): ";
29             cin >> x >> y;
30             return new Move<char>(x, y, p->get_symbol());
31         }
32     }
33 
34 
35 
36     // Added BY AO
37     Player<char>* create_player(string& name, char symbol, PlayerType type) override {
38         cout << "Creating " << (type == PlayerType::HUMAN ? "human" : "computer")
39             << " player: " << name << " (" << symbol << ")\n";
40         return new Player<char>(name, symbol, type);
41     }
42 
43     void display_message(string s) {
44         cout << s << endl;
45     }
46 };
47 
48 

TicTacToe4x4.h File Reference
#include "BoardGame_Classes.h"
#include <cstdlib>
#include <ctime>
Classes
class TicTacToe4x4_Boardclass TicTacToe4x4_Player
class TicTacToe4x4_UI

TicTacToe4x4.h
Go to the documentation of this file.

1 #ifndef TICTACTOE4X4_H
2 #define TICTACTOE4X4_H
3 
4 #include "BoardGame_Classes.h"
5 #include <cstdlib>
6 #include <ctime>
7 
8 class TicTacToe4x4_Board : public Board<char> {
9 public:
10     TicTacToe4x4_Board();
11     bool update_board(Move<char>* move) override;
12     bool is_win(Player<char>* player) override;
13     bool is_draw(Player<char>* player) override;
14     bool is_lose(Player<char>* player) override;
15     bool game_is_over(Player<char>* player) override;
16 };
17 
18 class TicTacToe4x4_Player : public Player<char> {
19 public:
20     TicTacToe4x4_Player(string name, char symbol, PlayerType type)
21         : Player<char>(name, symbol, type) {}
22 };
23 
24 class TicTacToe4x4_UI : public UI<char> {
25 public:
26     TicTacToe4x4_UI() : UI<char>("4x4 TicTacToe", 3) {}
27 
28     Move<char>* get_move(Player<char>* p) override {
29         int x, y;
30 
31         // Computer move
32         if (p->get_type() == PlayerType::COMPUTER) {
33             srand(time(0));
34             auto board_matrix = p->get_board_ptr()->get_board_matrix();
35 
36             // find an empty cell
37             do {
38                 x = rand() % 4;
39                 y = rand() % 4;
40             } while (board_matrix[x][y] != ' ');
41 
42             cout << "\nComputer played at (" << x << "," << y << ")\n";
43             return new Move<char>(x, y, p->get_symbol());
44         }
45 
46         // Human move
47         while (true) {
48             cout << "\n" << p->get_name() << " enter row and column [0-3]: ";
49             cin >> x >> y;
50 
51             if (x < 0 || x > 3 || y < 0 || y > 3) {
52                 cout << "Invalid cell. Please enter values between 0-3.\n";
53                 continue;
54             }
55 
56             auto board_matrix = p->get_board_ptr()->get_board_matrix();
57             if (board_matrix[x][y] != ' ') {
58                 cout << "Box already occupied. Choose another Box.\n";
59                 continue;
60             }
61 
62             return new Move<char>(x, y, p->get_symbol());
63         }
64     }
65 
66     Player<char>* create_player(string& name, char symbol, PlayerType type) override {
67         return new TicTacToe4x4_Player(name, symbol, type);
68     }
69 };
70 
71 // Implementation
72 TicTacToe4x4_Board::TicTacToe4x4_Board() : Board(4, 4) {
73     // Initialize empty board
74     for (auto& row : board) {
75         for (auto& cell : row) {
76             cell = ' ';
77         }
78     }
79     n_moves = 0;
80 }
81 
82 bool TicTacToe4x4_Board::update_board(Move<char>* move) {
83     int x = move->get_x();
84     int y = move->get_y();
85     char symbol = move->get_symbol();
86 
87     // Check if move is valid
88     if (x < 0 || x >= rows || y < 0 || y >= columns) {
89         return false;
90     }
91 
92     if (board[x][y] != ' ') {
93         return false;
94     }
95 
96     board[x][y] = symbol;
97     n_moves++;
98     return true;
99 }
100 
101 bool TicTacToe4x4_Board::is_win(Player<char>* player) {
102     char symbol = player->get_symbol();
103 
104     // Check rows
105     for (int i = 0; i < 4; i++) {
106         if (board[i][0] == symbol && board[i][1] == symbol &&
107             board[i][2] == symbol && board[i][3] == symbol) {
108             return true;
109         }
110     }
111 
112     // Check columns
113     for (int j = 0; j < 4; j++) {
114         if (board[0][j] == symbol && board[1][j] == symbol &&
115             board[2][j] == symbol && board[3][j] == symbol) {
116             return true;
117         }
118     }
119 
120     // Check diagonals
121     if (board[0][0] == symbol && board[1][1] == symbol &&
122         board[2][2] == symbol && board[3][3] == symbol) {
123         return true;
124     }
125     if (board[0][3] == symbol && board[1][2] == symbol &&
126         board[2][1] == symbol && board[3][0] == symbol) {
127         return true;
128     }
129 
130     return false;
131 }
132 
133 bool TicTacToe4x4_Board::is_draw(Player<char>* player) {
134     // Check if board is full and no win
135     for (int i = 0; i < rows; i++) {
136         for (int j = 0; j < columns; j++) {
137             if (board[i][j] == ' ') {
138                 return false;
139             }
140         }
141     }
142     return !is_win(player);
143 }
144 
145 bool TicTacToe4x4_Board::is_lose(Player<char>* player) {
146     return false;
147 }
148 
149 bool TicTacToe4x4_Board::game_is_over(Player<char>* player) {
150     return is_win(player) || is_draw(player);
151 }
152 
153 #endif // TICTACTOE4X4_H

TicTacToe5x5.h File Reference
#include "BoardGame_Classes.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
Classes
class TicTacToe5x5_Boardclass TicTacToe5x5_Player
class TicTacToe5x5_RandomPlayer
class TicTacToe5x5_UI

TicTacToe5x5.h
Go to the documentation of this file.

1 #ifndef TICTACTOE5X5_H
2 #define TICTACTOE5X5_H
3 
4 #include "BoardGame_Classes.h"
5 #include <iostream>
6 #include <cstdlib>
7 #include <ctime>
8 using namespace std;
9 
10 // 5x5 Tic Tac Toe Board
11 class TicTacToe5x5_Board : public Board<char> {
12 private:
13     int count_three_in_row(char symbol) {
14         int count = 0;
15 
16         // Rows
17         for (int i = 0; i < 5; i++) {
18             for (int j = 0; j < 3; j++) {
19                 if (board[i][j] == symbol && board[i][j + 1] == symbol && board[i][j + 2] == symbol)
20                     count++;
21             }
22         }
23 
24         // Columns
25         for (int j = 0; j < 5; j++) {
26             for (int i = 0; i < 3; i++) {
27                 if (board[i][j] == symbol && board[i + 1][j] == symbol && board[i + 2][j] == symbol)
28                     count++;
29             }
30         }
31 
32         // Diagonals
33         for (int i = 0; i < 3; i++) {
34             for (int j = 0; j < 3; j++) {
35                 if (board[i][j] == symbol && board[i + 1][j + 1] == symbol && board[i + 2][j + 2] == symbol)
36                     count++;
37             }
38         }
39 
40         for (int i = 0; i < 3; i++) {
41             for (int j = 2; j < 5; j++) {
42                 if (board[i][j] == symbol && board[i + 1][j - 1] == symbol && board[i + 2][j - 2] == symbol)
43                     count++;
44             }
45         }
46 
47         return count;
48     }
49 
50 public:
51     TicTacToe5x5_Board() : Board(5, 5) {
52         for (int i = 0; i < 5; i++) {
53             for (int j = 0; j < 5; j++) {
54                 board[i][j] = ' ';
55             }
56         }
57     }
58 
59     bool update_board(Move<char>* move) override {
60         int x = move->get_x();
61         int y = move->get_y();
62         char symbol = move->get_symbol();
63 
64         if (x < 0 || x >= 5 || y < 0 || y >= 5) {
65             cout << "Invalid position! Use 0-4.\n";
66             return false;
67         }
68 
69         if (board[x][y] != ' ') {
70             cout << "Cell already occupied!\n";
71             return false;
72         }
73 
74         board[x][y] = symbol;
75         n_moves++;
76         return true;
77     }
78 
79     bool is_win(Player<char>* player) override {
80         if (n_moves < 24) return false;
81 
82         char player_symbol = player->get_symbol();
83         char opponent_symbol = (player_symbol == 'X') ? 'O' : 'X';
84 
85         int player_score = count_three_in_row(player_symbol);
86         int opponent_score = count_three_in_row(opponent_symbol);
87 
88         return player_score > opponent_score;
89     }
90 
91     bool is_lose(Player<char>* player) override {
92         if (n_moves < 24) return false;
93 
94         char player_symbol = player->get_symbol();
95         char opponent_symbol = (player_symbol == 'X') ? 'O' : 'X';
96 
97         int player_score = count_three_in_row(player_symbol);
98         int opponent_score = count_three_in_row(opponent_symbol);
99 
100         return player_score < opponent_score;
101     }
102 
103     bool is_draw(Player<char>* player) override {
104         if (n_moves < 24) return false;
105 
106         char player_symbol = player->get_symbol();
107         char opponent_symbol = (player_symbol == 'X') ? 'O' : 'X';
108 
109         int player_score = count_three_in_row(player_symbol);
110         int opponent_score = count_three_in_row(opponent_symbol);
111 
112         return player_score == opponent_score;
113     }
114 
115     bool game_is_over(Player<char>* player) override {
116         return (n_moves >= 24);
117     }
118 };
119 
120 // 5x5 Player
121 class TicTacToe5x5_Player : public Player<char> {
122 public:
123     TicTacToe5x5_Player(string name, char symbol) : Player(name, symbol, PlayerType::HUMAN) {}
124 };
125 
126 // 5x5 Random Player
127 class TicTacToe5x5_RandomPlayer : public Player<char> {
128 public:
129     TicTacToe5x5_RandomPlayer(char symbol) : Player("Random Computer", symbol, PlayerType::COMPUTER) {
130         srand(time(0));
131     }
132 };
133 
134 // 5x5 UI
135 class TicTacToe5x5_UI : public UI<char> {
136 public:
137     TicTacToe5x5_UI() : UI("Welcome to 5x5 Tic-Tac-Toe!", 3) {}
138 
139     Move<char>* get_move(Player<char>* player) override {
140         if (player->get_type() == PlayerType::HUMAN) {
141             int x, y;
142             cout << player->get_name() << " (" << player->get_symbol()
143                 << "), enter your move (row and column 0-4): ";
144             cin >> x >> y;
145             return new Move<char>(x, y, player->get_symbol());
146         }
147         else {
148             int x = rand() % 5;
149             int y = rand() % 5;
150             cout << player->get_name() << " chooses position (" << x << ", " << y << ")\n";
151             return new Move<char>(x, y, player->get_symbol());
152         }
153     }
154 };
155 
156 #endif // TICTACTOE5X5_H
157 

UltimateTicTacToe.h File Reference
#include "BoardGame_Classes.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
Classes
class UltimateTicTacToeBoardclass UltimateTicTacToe_Player
class UltimateTicTacToe_RandomPlayer
class UltimateTicTacToe_UI

UltimateTicTacToe.h
Go to the documentation of this file.

1 #ifndef ULTIMATETICTACTOE_H
2 #define ULTIMATETICTACTOE_H
3 
4 #include "BoardGame_Classes.h"
5 #include <iostream>
6 #include <cstdlib>
7 #include <ctime>
8 using namespace std;
9 
10 // Ultimate Tic Tac Toe Board
11 class UltimateTicTacToeBoard : public Board<char> {
12 private:
13     char sub_winners[3][3] = { {' ', ' ', ' '}, {' ', ' ', ' '}, {' ', ' ', ' '} };
14     int last_move_x = -1, last_move_y = -1;
15 
16     bool check_sub_win(int subgrid_row, int subgrid_col, char symbol) {
17         int start_row = subgrid_row * 3;
18         int start_col = subgrid_col * 3;
19 
20         // Check rows in subgrid
21         for (int i = 0; i < 3; i++) {
22             if (board[start_row + i][start_col] == symbol &&
23                 board[start_row + i][start_col + 1] == symbol &&
24                 board[start_row + i][start_col + 2] == symbol)
25                 return true;
26         }
27 
28         // Check columns in subgrid
29         for (int j = 0; j < 3; j++) {
30             if (board[start_row][start_col + j] == symbol &&
31                 board[start_row + 1][start_col + j] == symbol &&
32                 board[start_row + 2][start_col + j] == symbol)
33                 return true;
34         }
35 
36         // Check diagonals in subgrid
37         if (board[start_row][start_col] == symbol &&
38             board[start_row + 1][start_col + 1] == symbol &&
39             board[start_row + 2][start_col + 2] == symbol)
40             return true;
41 
42         if (board[start_row][start_col + 2] == symbol &&
43             board[start_row + 1][start_col + 1] == symbol &&
44             board[start_row + 2][start_col] == symbol)
45             return true;
46 
47         return false;
48     }
49 
50     bool check_main_win(char symbol) {
51         // Check rows in main grid
52         for (int i = 0; i < 3; i++) {
53             if (sub_winners[i][0] == symbol && sub_winners[i][1] == symbol && sub_winners[i][2] == symbol)
54                 return true;
55         }
56 
57         // Check columns in main grid
58         for (int j = 0; j < 3; j++) {
59             if (sub_winners[0][j] == symbol && sub_winners[1][j] == symbol && sub_winners[2][j] == symbol)
60                 return true;
61         }
62 
63         // Check diagonals in main grid
64         if (sub_winners[0][0] == symbol && sub_winners[1][1] == symbol && sub_winners[2][2] == symbol)
65             return true;
66         if (sub_winners[0][2] == symbol && sub_winners[1][1] == symbol && sub_winners[2][0] == symbol)
67             return true;
68 
69         return false;
70     }
71 
72 public:
73     UltimateTicTacToeBoard() : Board(9, 9) {
74         for (int i = 0; i < 9; i++) {
75             for (int j = 0; j < 9; j++) {
76                 board[i][j] = ' ';
77             }
78         }
79     }
80 
81     bool update_board(Move<char>* move) override {
82         int x = move->get_x();
83         int y = move->get_y();
84         char symbol = move->get_symbol();
85 
86         if (x < 0 || x >= 9 || y < 0 || y >= 9) {
87             cout << "Invalid position! Use 0-8.\n";
88             return false;
89         }
90 
91         // Check if move is in allowed subgrid
92         if (last_move_x != -1 && last_move_y != -1) {
93             int target_subgrid_row = last_move_x % 3;
94             int target_subgrid_col = last_move_y % 3;
95             int current_subgrid_row = x / 3;
96             int current_subgrid_col = y / 3;
97 
98             if (sub_winners[target_subgrid_row][target_subgrid_col] == ' ') {
99                 // Must play in specified subgrid unless it's won
100                 if (current_subgrid_row != target_subgrid_row ||
101                     current_subgrid_col != target_subgrid_col) {
102                     cout << "Must play in subgrid (" << target_subgrid_row
103                         << ", " << target_subgrid_col << ")\n";
104                     return false;
105                 }
106             }
107         }
108 
109         if (board[x][y] != ' ') {
110             cout << "Cell already occupied!\n";
111             return false;
112         }
113 
114         board[x][y] = symbol;
115         n_moves++;
116 
117         // Check if subgrid is won
118         int subgrid_row = x / 3;
119         int subgrid_col = y / 3;
120         if (sub_winners[subgrid_row][subgrid_col] == ' ' &&
121             check_sub_win(subgrid_row, subgrid_col, symbol)) {
122             sub_winners[subgrid_row][subgrid_col] = symbol;
123         }
124 
125         // Set next move target
126         last_move_x = x;
127         last_move_y = y;
128 
129         return true;
130     }
131 
132     bool is_win(Player<char>* player) override {
133         return check_main_win(player->get_symbol());
134     }
135 
136     bool is_lose(Player<char>* player) override {
137         return false;
138     }
139 
140     bool is_draw(Player<char>* player) override {
141         // Check if all subgrids are won or full
142         for (int i = 0; i < 3; i++) {
143             for (int j = 0; j < 3; j++) {
144                 if (sub_winners[i][j] == ' ') {
145                     // Check if subgrid has empty cells
146                     bool has_empty = false;
147                     for (int si = 0; si < 3; si++) {
148                         for (int sj = 0; sj < 3; sj++) {
149                             if (board[i * 3 + si][j * 3 + sj] == ' ') {
150                                 has_empty = true;
151                                 break;
152                             }
153                         }
154                         if (has_empty) break;
155                     }
156                     if (has_empty) return false;
157                 }
158             }
159         }
160         return !is_win(player);
161     }
162 
163     bool game_is_over(Player<char>* player) override {
164         return is_win(player) || is_draw(player);
165     }
166 };
167 
168 // Ultimate Player
169 class UltimateTicTacToe_Player : public Player<char> {
170 public:
171     UltimateTicTacToe_Player(string name, char symbol) : Player(name, symbol, PlayerType::HUMAN) {}
172 };
173 
174 // Ultimate Random Player
175 class UltimateTicTacToe_RandomPlayer : public Player<char> {
176 public:
177     UltimateTicTacToe_RandomPlayer(char symbol) : Player("Random Computer", symbol, PlayerType::COMPUTER) {
178         srand(time(0));
179     }
180 };
181 
182 // Ultimate UI
183 class UltimateTicTacToe_UI : public UI<char> {
184 public:
185     UltimateTicTacToe_UI() : UI("Welcome to Ultimate Tic-Tac-Toe!", 3) {}
186 
187     Move<char>* get_move(Player<char>* player) override {
188         if (player->get_type() == PlayerType::HUMAN) {
189             int x, y;
190             cout << player->get_name() << " (" << player->get_symbol()
191                 << "), enter your move (row and column 0-8): ";
192             cin >> x >> y;
193             return new Move<char>(x, y, player->get_symbol());
194         }
195         else {
196             int x = rand() % 9;
197             int y = rand() % 9;
198             cout << player->get_name() << " chooses position (" << x << ", " << y << ")\n";
199             return new Move<char>(x, y, player->get_symbol());
200         }
201     }
202 };
203 
204 #endif // ULTIMATETICTACTOE_H

wordTic_tac_toe.h File Reference
#include "BoardGame_Classes.h"
#include <fstream>
#include <set>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <ctime>
Classes
class word_Boardclass word_Player
class word_Random_Player
class word_UI

wordTic_tac_toe.h
Go to the documentation of this file.

1 #ifndef WORDTICTACTOE_H
2 #define WORDTICTACTOE_H
3 
4 #include "BoardGame_Classes.h"
5 #include <fstream>
6 #include <set>
7 #include <algorithm>
8 #include <iostream>
9 #include <cstdlib>
10 #include <ctime>
11 using namespace std;
12 
13 // Word Tic Tac Toe Board
14 class word_Board : public Board<char> {
15 private:
16     set<string> dictionary;
17 
18     void load_dictionary() {
19         ifstream file("dic.txt");
20         string word;
21         while (file >> word) {
22             transform(word.begin(), word.end(), word.begin(), ::toupper);
23             dictionary.insert(word);
24         }
25         file.close();
26     }
27 
28     string get_word(int r1, int c1, int r2, int c2, int r3, int c3) {
29         return string(1, board[r1][c1]) +
30             string(1, board[r2][c2]) +
31             string(1, board[r3][c3]);
32     }
33 
34 public:
35     word_Board() : Board(3, 3) {
36         load_dictionary();
37         for (int i = 0; i < 3; i++) {
38             for (int j = 0; j < 3; j++) {
39                 board[i][j] = ' ';
40             }
41         }
42     }
43 
44     bool update_board(Move<char>* move) override {
45         int x = move->get_x();
46         int y = move->get_y();
47         char symbol = move->get_symbol();
48 
49         if (x < 0 || x >= 3 || y < 0 || y >= 3) {
50             cout << "Invalid position! Use 0-2.\n";
51             return false;
52         }
53 
54         if (board[x][y] != ' ') {
55             cout << "Cell already occupied!\n";
56             return false;
57         }
58 
59         if (!isalpha(symbol)) {
60             cout << "Invalid symbol! Use letters only.\n";
61             return false;
62         }
63 
64         board[x][y] = toupper(symbol);
65         n_moves++;
66         return true;
67     }
68 
69     bool is_win(Player<char>* player) override {
70         // Check all rows, columns and diagonals
71         string lines[8][3] = {
72             {"00", "01", "02"}, {"10", "11", "12"}, {"20", "21", "22"}, // Rows
73             {"00", "10", "20"}, {"01", "11", "21"}, {"02", "12", "22"}, // Columns
74             {"00", "11", "22"}, {"02", "11", "20"}                      // Diagonals
75         };
76 
77         for (int i = 0; i < 8; i++) {
78             int r1 = lines[i][0][0] - '0', c1 = lines[i][0][1] - '0';
79             int r2 = lines[i][1][0] - '0', c2 = lines[i][1][1] - '0';
80             int r3 = lines[i][2][0] - '0', c3 = lines[i][2][1] - '0';
81 
82             string word = get_word(r1, c1, r2, c2, r3, c3);
83             string rev_word = string(word.rbegin(), word.rend());
84 
85             if (dictionary.find(word) != dictionary.end() ||
86                 dictionary.find(rev_word) != dictionary.end()) {
87                 return true;
88             }
89         }
90 
91         return false;
92     }
93 
94     bool is_lose(Player<char>* player) override {
95         return false;
96     }
97 
98     bool is_draw(Player<char>* player) override {
99         return (n_moves == 9 && !is_win(player));
100     }
101 
102     bool game_is_over(Player<char>* player) override {
103         return is_win(player) || is_draw(player);
104     }
105 };
106 
107 // Word Player
108 class word_Player : public Player<char> {
109 public:
110     word_Player(string name, char symbol) : Player(name, symbol, PlayerType::HUMAN) {}
111 };
112 
113 // Word Random Player
114 class word_Random_Player : public Player<char> {
115 public:
116     word_Random_Player(char symbol) : Player("Random Computer", symbol, PlayerType::COMPUTER) {
117         srand(time(0));
118     }
119 };
120 
121 // Word UI
122 class word_UI : public UI<char> {
123 public:
124     word_UI() : UI("Welcome to Word Tic-Tac-Toe!", 3) {}
125 
126     Move<char>* get_move(Player<char>* player) override {
127         if (player->get_type() == PlayerType::HUMAN) {
128             int x, y;
129             char letter;
130             cout << player->get_name() << " (" << player->get_symbol()
131                 << "), enter your move (row, column, and letter): ";
132             cin >> x >> y >> letter;
133             letter = toupper(letter);
134             return new Move<char>(x, y, letter);
135         }
136         else {
137             int x = rand() % 3;
138             int y = rand() % 3;
139             char letter = 'A' + rand() % 26;
140             cout << player->get_name() << " chooses position (" << x << ", " << y
141                 << ") with letter " << letter << "\n";
142             return new Move<char>(x, y, letter);
143         }
144     }
145 };
146 
147 #endif // WORDTICTACTOE_H
148 

XO.h File Reference
#include "BoardGame_Classes.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
Classes
class XO_Boardclass XO_Player
class XO_Random_Player
class XO_UI

XO.h
Go to the documentation of this file.

1 #ifndef XO_H
2 #define XO_H
3 
4 #include "BoardGame_Classes.h"
5 #include <iostream>
6 #include <cstdlib>
7 #include <ctime>
8 using namespace std;
9 
10 // XO Board
11 class XO_Board : public Board<char> {
12 public:
13     XO_Board() : Board(3, 3) {
14         for (int i = 0; i < 3; i++) {
15             for (int j = 0; j < 3; j++) {
16                 board[i][j] = ' ';
17             }
18         }
19     }
20 
21     bool update_board(Move<char>* move) override {
22         int x = move->get_x();
23         int y = move->get_y();
24         char symbol = move->get_symbol();
25 
26         if (x < 0 || x >= 3 || y < 0 || y >= 3) {
27             cout << "Invalid position! Use 0-2.\n";
28             return false;
29         }
30 
31         if (board[x][y] != ' ') {
32             cout << "Cell already occupied!\n";
33             return false;
34         }
35 
36         board[x][y] = symbol;
37         n_moves++;
38         return true;
39     }
40 
41     bool is_win(Player<char>* player) override {
42         char symbol = player->get_symbol();
43 
44         // Check rows
45         for (int i = 0; i < 3; i++) {
46             if (board[i][0] == symbol && board[i][1] == symbol && board[i][2] == symbol)
47                 return true;
48         }
49 
50         // Check columns
51         for (int j = 0; j < 3; j++) {
52             if (board[0][j] == symbol && board[1][j] == symbol && board[2][j] == symbol)
53                 return true;
54         }
55 
56         // Check diagonals
57         if (board[0][0] == symbol && board[1][1] == symbol && board[2][2] == symbol)
58             return true;
59         if (board[0][2] == symbol && board[1][1] == symbol && board[2][0] == symbol)
60             return true;
61 
62         return false;
63     }
64 
65     bool is_lose(Player<char>* player) override {
66         return false;
67     }
68 
69     bool is_draw(Player<char>* player) override {
70         return (n_moves == 9 && !is_win(player));
71     }
72 
73     bool game_is_over(Player<char>* player) override {
74         return is_win(player) || is_draw(player);
75     }
76 };
77 
78 // XO Player
79 class XO_Player : public Player<char> {
80 public:
81     XO_Player(string name, char symbol) : Player(name, symbol, PlayerType::HUMAN) {}
82 };
83 
84 // XO Random Player
85 class XO_Random_Player : public Player<char> {
86 public:
87     XO_Random_Player(char symbol) : Player("Random Computer", symbol, PlayerType::COMPUTER) {
88         srand(time(0));
89     }
90 };
91 
92 // XO UI
93 class XO_UI : public UI<char> {
94 public:
95     XO_UI() : UI("Welcome to Tic-Tac-Toe (XO)!", 3) {}
96 
97     Move<char>* get_move(Player<char>* player) override {
98         if (player->get_type() == PlayerType::HUMAN) {
99             int x, y;
100             cout << player->get_name() << " (" << player->get_symbol()
101                 << "), enter your move (row and column 0-2): ";
102             cin >> x >> y;
103             return new Move<char>(x, y, player->get_symbol());
104         }
105         else {
106             int x = rand() % 3;
107             int y = rand() % 3;
108             cout << player->get_name() << " chooses position (" << x << ", " << y << ")\n";
109             return new Move<char>(x, y, player->get_symbol());
110         }
111     }
112 };
113 
114 #endif // XO_H
115 

Index
INDEX