| OOP A3 Board Games 35 a Board Game Project Made by Students at Cairo FCAI

Loading...
Searching...
No Matches
Board< T > Class Template Referenceabstract

Base template for any board used in board games. More...

`#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

## ◆ Board()

template<typename T>

Board< T >::Board | ( | int | rows,
|  | int | columns )
| inline

Construct a board with given dimensions.

## ◆ ~Board()

template<typename T>

virtual Board< T >::~Board | ( |  | ) |
| inline virtual

Virtual destructor. Frees allocated board memory.

## Member Function Documentation

## ◆ game_is_over()

template<typename T>

virtual bool Board< T >::game_is_over | ( | Player< T > * |  | ) |
| pure virtual

Check if the game is over.

Implemented in DiamondTicTacToeBoard, FourBoard, FourInARowBoard, InfinityTicTacToeBoard, MemoryTicTacToeBoard, MisereTicTacToe_Board, Numerical_Board, NumericalTicTacToeBoard, ObstaclesTicTacToeBoard, Pyramic_XO_Board, SUS_Board, SUSBoard, TicTacToe4x4_Board, TicTacToe5x5_Board, UltimateTicTacToeBoard, word_Board, and XO_Board.

## ◆ get_board_matrix()

template<typename T>

vector< vector< T > > Board< T >::get_board_matrix | ( |  | ) | const
| inline

Return a copy of the current board as a 2D vector.

## ◆ get_columns()

template<typename T>

int Board< T >::get_columns | ( |  | ) | const
| inline

Get number of columns.

## ◆ get_rows()

template<typename T>

int Board< T >::get_rows | ( |  | ) | const
| inline

Get number of rows.

## ◆ is_draw()

template<typename T>

virtual bool Board< T >::is_draw | ( | Player< T > * |  | ) |
| pure virtual

Check if the game ended in a draw.

Implemented in DiamondTicTacToeBoard, FourBoard, FourInARowBoard, InfinityTicTacToeBoard, MemoryTicTacToeBoard, MisereTicTacToe_Board, Numerical_Board, NumericalTicTacToeBoard, ObstaclesTicTacToeBoard, Pyramic_XO_Board, SUS_Board, SUSBoard, TicTacToe4x4_Board, TicTacToe5x5_Board, UltimateTicTacToeBoard, word_Board, and XO_Board.

## ◆ is_lose()

template<typename T>

virtual bool Board< T >::is_lose | ( | Player< T > * |  | ) |
| pure virtual

Check if a player has lost.

Implemented in DiamondTicTacToeBoard, FourBoard, FourInARowBoard, InfinityTicTacToeBoard, MemoryTicTacToeBoard, MisereTicTacToe_Board, Numerical_Board, NumericalTicTacToeBoard, ObstaclesTicTacToeBoard, Pyramic_XO_Board, SUS_Board, SUSBoard, TicTacToe4x4_Board, TicTacToe5x5_Board, UltimateTicTacToeBoard, word_Board, and XO_Board.

## ◆ is_win()

template<typename T>

virtual bool Board< T >::is_win | ( | Player< T > * |  | ) |
| pure virtual

Check if a player has won.

Implemented in DiamondTicTacToeBoard, FourBoard, FourInARowBoard, InfinityTicTacToeBoard, MemoryTicTacToeBoard, MisereTicTacToe_Board, Numerical_Board, NumericalTicTacToeBoard, ObstaclesTicTacToeBoard, Pyramic_XO_Board, SUS_Board, SUSBoard, TicTacToe4x4_Board, TicTacToe5x5_Board, UltimateTicTacToeBoard, word_Board, and XO_Board.

## ◆ update_board()

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, FourBoard, FourInARowBoard, InfinityTicTacToeBoard, MemoryTicTacToeBoard, MisereTicTacToe_Board, Numerical_Board, NumericalTicTacToeBoard, ObstaclesTicTacToeBoard, Pyramic_XO_Board, SUS_Board, SUSBoard, TicTacToe4x4_Board, TicTacToe5x5_Board, UltimateTicTacToeBoard, word_Board, and XO_Board.

## Member Data Documentation

## ◆ board

template<typename T>

vector<vector<T> > Board< T >::board
| protected

2D vector for the board

## ◆ columns

template<typename T>

int Board< T >::columns
| protected

Number of columns.

## ◆ n_moves

template<typename T>

int Board< T >::n_moves = 0
| protected

Number of moves made.

## ◆ rows

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