My Project
UML Lab
Loading...
Searching...
No Matches
board.h
Go to the documentation of this file.
1#ifndef BOARD_HPP
2#define BOARD_HPP
3
4#include <SFML/Graphics.hpp>
5#include <vector>
6#include <limits>
7#include "player.h"
8#include "piece.h"
9#include "move.h"
10#include "movenode.h"
11
21class Board {
22public:
28 Board(Player& red, Player& black);
29
35
41
48
56 bool validarity(const Piece& piece, int x, int y);
57
62 void inputdata(sf::RenderWindow& window);
63
70 bool isPieceAt(int x, int y) const;
71
78 void highlight(int pieceIndex, sf::RenderWindow& window, Board& board);
79
85 int numberofmoves(Player* player);
86
91 bool endgame();
92
97 void draw(sf::RenderWindow& window);
98
104 int evaluateBoard(Board& board);
105
113 MoveNode MinMaxTree(Board& board, int depth, bool computerPlayer);
114
121 Move BestMove(int depth, bool computerPlayer);
122
130 bool opponentPiece(int x, int y, const sf::Color& colorToCheck);
131
137 std::vector<Move> generateMoves(Board& board);
138
146 int minimax(Board& board, int depth, bool computerPlayer);
147
151 void ComputerMove();
152
159 int MousePosition(int mouseX, int mouseY);
160
166 void makeMove(Board& board, const Move& move);
167
172 static constexpr int size = 8;
173private:
178 const int depth = 5;
179};
180
181#endif // BOARD_HPP
Represents the game board and its functionality.
Definition board.h:21
Player & getRedPlayer()
Getter for the red player.
int minimax(Board &board, int depth, bool computerPlayer)
Minimax algorithm to evaluate the board and choose the best move.
Definition board.cpp:343
bool endgame()
Checks if the game has ended.
Definition board.cpp:187
MoveNode MinMaxTree(Board &board, int depth, bool computerPlayer)
Implements the Minimax algorithm to search for the best move.
Definition board.cpp:248
void ComputerMove()
Executes the computer's move.
Definition board.cpp:374
static constexpr int size
Definition board.h:172
void draw(sf::RenderWindow &window)
Draws the game board and pieces on the SFML window.
Definition board.cpp:195
Move BestMove(int depth, bool computerPlayer)
Finds the best move using the Minimax algorithm.
Definition board.cpp:289
void makeMove(Board &board, const Move &move)
Makes a move on the board.
Definition board.cpp:403
bool isPieceAt(int x, int y) const
Checks if there is a piece at the given coordinates.
Definition board.cpp:51
Piece pieces[24]
Definition board.h:171
int evaluateBoard(Board &board)
Evaluates the current state of the board.
Definition board.cpp:225
Player & redPlayer
Reference to the red player.
Definition board.h:168
const int depth
Depth for the minimax algorithm.
Definition board.h:178
void InitializeGame(Player &redPlayer, Player &blackPlayer)
Initializes the game board with pieces.
Definition board.cpp:17
Player & getBlackPlayer()
Getter for the black player.
void highlight(int pieceIndex, sf::RenderWindow &window, Board &board)
Highlights the possible moves for a selected piece.
Definition board.cpp:138
bool opponentPiece(int x, int y, const sf::Color &colorToCheck)
Checks if a piece at a certain position belongs to the opponent.
Definition board.cpp:300
bool validarity(const Piece &piece, int x, int y)
Checks the validity of a move for a given piece.
Definition board.cpp:67
int MousePosition(int mouseX, int mouseY)
Generates the index of the piece that was clicked by the mouse.
Definition board.cpp:385
Board(Player &red, Player &black)
Constructor for the Board class.
Definition board.cpp:8
std::vector< Move > generateMoves(Board &board)
Generates all possible moves for the current board state.
Definition board.cpp:313
void inputdata(sf::RenderWindow &window)
Handles player input for moving pieces.
Definition board.cpp:85
Player & blackPlayer
Definition board.h:170
int selectedPieceIndex
Index of the currently selected piece.
Definition board.h:177
int numberofmoves(Player *player)
Counts the number of possible moves for a player.
Definition board.cpp:171
Class representing a move in the game.
Definition move.h:7
Class representing a node in the MinMax tree.
Definition movenode.h:10
Represents a checker piece on the board.
Definition piece.h:15
Class representing a player in the game.
Definition player.h:9
Header file for the Piece class, which represents a checker piece on the board.