|
My Project
UML Lab
|
Represents the game board and its functionality. More...
#include <board.h>
Public Member Functions | |
| Board (Player &red, Player &black) | |
| Constructor for the Board class. | |
| Player & | getRedPlayer () |
| Getter for the red player. | |
| Player & | getBlackPlayer () |
| Getter for the black player. | |
| void | InitializeGame (Player &redPlayer, Player &blackPlayer) |
| Initializes the game board with pieces. | |
| bool | validarity (const Piece &piece, int x, int y) |
| Checks the validity of a move for a given piece. | |
| void | inputdata (sf::RenderWindow &window) |
| Handles player input for moving pieces. | |
| bool | isPieceAt (int x, int y) const |
| Checks if there is a piece at the given coordinates. | |
| void | highlight (int pieceIndex, sf::RenderWindow &window, Board &board) |
| Highlights the possible moves for a selected piece. | |
| int | numberofmoves (Player *player) |
| Counts the number of possible moves for a player. | |
| bool | endgame () |
| Checks if the game has ended. | |
| void | draw (sf::RenderWindow &window) |
| Draws the game board and pieces on the SFML window. | |
| int | evaluateBoard (Board &board) |
| Evaluates the current state of the board. | |
| MoveNode | MinMaxTree (Board &board, int depth, bool computerPlayer) |
| Implements the Minimax algorithm to search for the best move. | |
| Move | BestMove (int depth, bool computerPlayer) |
| Finds the best move using the Minimax algorithm. | |
| bool | opponentPiece (int x, int y, const sf::Color &colorToCheck) |
| Checks if a piece at a certain position belongs to the opponent. | |
| std::vector< Move > | generateMoves (Board &board) |
| Generates all possible moves for the current board state. | |
| int | minimax (Board &board, int depth, bool computerPlayer) |
| Minimax algorithm to evaluate the board and choose the best move. | |
| void | ComputerMove () |
| Executes the computer's move. | |
| int | MousePosition (int mouseX, int mouseY) |
| Generates the index of the piece that was clicked by the mouse. | |
| void | makeMove (Board &board, const Move &move) |
| Makes a move on the board. | |
Public Attributes | |
| Player & | redPlayer |
| Reference to the red player. | |
| Player & | blackPlayer |
| Piece | pieces [24] |
Static Public Attributes | |
| static constexpr int | size = 8 |
Private Attributes | |
| int | selectedPieceIndex = -1 |
| Index of the currently selected piece. | |
| const int | depth = 5 |
| Depth for the minimax algorithm. | |
Represents the game board and its functionality.
Constructor for the Board class.
| red | The red player. |
| black | The black player. |
| Move Board::BestMove | ( | int | depth, |
| bool | computerPlayer ) |
Finds the best move using the Minimax algorithm.
Determines the best move for the computer player.
| depth | The depth of the search tree. |
| computerPlayer | Boolean indicating if it's the computer's turn. |
| depth | The depth of the Minimax algorithm. |
| computerPlayer | True if the computer is playing, false otherwise. |
| void Board::ComputerMove | ( | ) |
Executes the computer's move.
| void Board::draw | ( | sf::RenderWindow & | window | ) |
Draws the game board and pieces on the SFML window.
Draws the board and pieces on the SFML window.
| window | The SFML window. |
| bool Board::endgame | ( | ) |
Checks if the game has ended.
| int Board::evaluateBoard | ( | Board & | board | ) |
Evaluates the current state of the board.
Evaluates the board for the Minimax algorithm.
| board | The current board. |
| board | The game board. |
Generates all possible moves for the current board state.
Generates possible moves for all pieces on the board.
| board | The current board. |
| board | The game board. |
| Player & Board::getBlackPlayer | ( | ) |
Getter for the black player.
| Player & Board::getRedPlayer | ( | ) |
Getter for the red player.
| void Board::highlight | ( | int | pieceIndex, |
| sf::RenderWindow & | window, | ||
| Board & | board ) |
Highlights the possible moves for a selected piece.
| pieceIndex | The index of the selected piece. |
| window | The SFML window. |
| board | The game board. |
Initializes the game board with pieces.
| redPlayer | The red player. |
| blackPlayer | The black player. |
| void Board::inputdata | ( | sf::RenderWindow & | window | ) |
Handles player input for moving pieces.
| window | The SFML window. |
| bool Board::isPieceAt | ( | int | x, |
| int | y ) const |
Checks if there is a piece at the given coordinates.
| x | The x-coordinate. |
| y | The y-coordinate. |
| x | The x-coordinate. |
| y | The y-coordinate. |
Makes a move on the board.
| board | The current board state. |
| move | The move to make. |
| board | The game board. |
| move | The move to make. |
| int Board::minimax | ( | Board & | board, |
| int | depth, | ||
| bool | computerPlayer ) |
Minimax algorithm to evaluate the board and choose the best move.
Implements the Minimax algorithm for move selection.
| board | The current board state. |
| depth | The depth of the search tree. |
| computerPlayer | Boolean indicating if it's the computer's turn. |
| board | The game board. |
| depth | The depth of the Minimax algorithm. |
| computerPlayer | True if the computer is playing, false otherwise. |
Implements the Minimax algorithm to search for the best move.
Generates the Minimax tree and returns the best move.
| board | The current board state. |
| depth | The depth of the search tree. |
| computerPlayer | Boolean indicating if it's the computer's turn. |
| board | The game board. |
| depth | The depth of the tree. |
| computerPlayer | True if the computer is playing, false otherwise. |
| int Board::MousePosition | ( | int | mouseX, |
| int | mouseY ) |
Generates the index of the piece that was clicked by the mouse.
Gets the index of the piece at the given mouse coordinates.
| mouseX | The x-coordinate of the mouse. |
| mouseY | The y-coordinate of the mouse. |
| mouseX | The x-coordinate of the mouse. |
| mouseY | The y-coordinate of the mouse. |
| int Board::numberofmoves | ( | Player * | player | ) |
Counts the number of possible moves for a player.
| player | The player. |
| bool Board::opponentPiece | ( | int | x, |
| int | y, | ||
| const sf::Color & | colorToCheck ) |
Checks if a piece at a certain position belongs to the opponent.
Checks if there is an opponent piece at the given coordinates.
| x | The x-coordinate of the piece. |
| y | The y-coordinate of the piece. |
| colorToCheck | The color of the opponent. |
| x | The x-coordinate. |
| y | The y-coordinate. |
| colorToCheck | The color to check against. |
| bool Board::validarity | ( | const Piece & | piece, |
| int | x, | ||
| int | y ) |
Checks the validity of a move for a given piece.
| piece | The piece to check the move for. |
| x | The x-coordinate of the destination. |
| y | The y-coordinate of the destination. |
| Player& Board::blackPlayer |
|
private |
Depth for the minimax algorithm.
| Piece Board::pieces[24] |
| Player& Board::redPlayer |
Reference to the red player.
|
private |
Index of the currently selected piece.
< The size of the board. Array of pieces on the board. Reference to the black player.
|
staticconstexpr |