Class representing the Noughts and Crosses (Tic-Tac-Toe) game.
More...
#include <NaughtsxCrossess.h>
Class representing the Noughts and Crosses (Tic-Tac-Toe) game.
◆ aiMove()
void NaughtsxCrossess::aiMove |
( |
int |
difficulty | ) |
|
Handles the AI's move based on the selected difficulty level.
- Parameters
-
difficulty | The difficulty level of the AI. |
◆ evaluate()
int NaughtsxCrossess::evaluate |
( |
| ) |
const |
Evaluates the current board and returns a score.
- Returns
- +10 if 'X' wins, -10 if 'O' wins, 0 otherwise.
◆ findBestMove()
std::pair< int, int > NaughtsxCrossess::findBestMove |
( |
int |
difficulty | ) |
|
Finds the best move for the AI based on the current board state.
- Parameters
-
difficulty | The difficulty level of the AI. |
- Returns
- The best move as a pair of integers representing row and column.
◆ getBoardValue()
char & NaughtsxCrossess::getBoardValue |
( |
int |
row, |
|
|
int |
col |
|
) |
| |
Get a reference to the value of the board at a specific position.
- Parameters
-
row | The row index of the board. |
col | The column index of the board. |
- Returns
- A reference to the value at the specified position.
◆ isMovesLeft()
bool NaughtsxCrossess::isMovesLeft |
( |
| ) |
const |
Checks if there are any moves left on the board.
- Returns
- True if there are moves left, false otherwise.
◆ minimax()
int NaughtsxCrossess::minimax |
( |
int |
depth, |
|
|
bool |
isMax, |
|
|
int |
difficulty |
|
) |
| |
Minimax algorithm to calculate the best move for the AI.
- Parameters
-
depth | The current depth of the recursion. |
isMax | True if the AI is maximizing, false if minimizing. |
difficulty | The depth limit for Medium difficulty. |
- Returns
- The evaluated score.
◆ playerMove()
bool NaughtsxCrossess::playerMove |
( |
char |
player, |
|
|
std::function< std::string()> |
inputProvider = nullptr |
|
) |
| |
Handles player input for a move with optional input simulation for testing.
- Parameters
-
player | The character representing the player ('x' or 'o'). |
inputProvider | A function or lambda that provides input for testing. |
- Returns
- False if the player typed "stop", true otherwise.
◆ resetBoard()
void NaughtsxCrossess::resetBoard |
( |
| ) |
|
Resets the game board, clearing all pieces and setting it to the initial state.
This is called at the start of each new game.
The documentation for this class was generated from the following files: