|
Trabalho Prático - PDS2
|


Membros Públicos | |
| Reversi () | |
| Constructs a Reversi game with an 8x8 board and initializes the starting positions. | |
| void | makeMove () override |
| Executes a move in the Reversi game. | |
| char | isGameFinished () override |
| Checks if the game of Reversi is finished. | |
Membros Públicos herdados de Game | |
| Game (int rows, int cols) | |
| Constructs a new Game object with the specified number of rows and columns. | |
| void | changePlayer () |
| virtual void | printBoard () |
| Prints the current state of the game board to the standard output. | |
Membros privados | |
| void | readMove () override |
| Reads a move from the user and validates it. | |
| void | validateMove (const int row, const int col) |
| Validates a move in the Reversi game. | |
| void | checkPosition (const int row, const int col) |
| Checks if the specified position on the board is occupied. | |
| void | checkBoundaries (const int row, const int col) |
| Checks if the given row and column are within the boundaries of the board. | |
| void | checkDirections (const int row, const int col) |
| Checks all possible directions from a given position on the board. | |
| bool | checkDirection (const int row, const int col, char other, const Direction &dir) |
| Checks a specific direction from a given position on the board to find and mark opponent's pieces to be captured. | |
Atributos Privados Estáticos | |
| static const Direction | _dirs [] |
| Array of possible directions for the Reversi game. | |
Outros membros herdados | |
Atributos Protegidos herdados de Game | |
| Board | board |
| std::pair< int, int > | move |
| char | current_player |
|
private |
Checks if the given row and column are within the boundaries of the board.
| row | The row index to check. |
| col | The column index to check. |
| InvalidInputException | if the row or column is out of the board's boundaries. |


|
private |
Checks a specific direction from a given position on the board to find and mark opponent's pieces to be captured.
This function checks in the specified direction (given by dir) from the position (row, col) on the board. It looks for a sequence of opponent's pieces (other) that are bounded by the current player's piece. If such a sequence is found, the positions of the opponent's pieces are added to the list of pieces to be captured (toEat).
| row | The starting row position on the board. |
| col | The starting column position on the board. |
| other | The character representing the opponent's pieces. |
| dir | The direction to check, represented by a Direction object containing dx and dy. |


|
private |
Checks all possible directions from a given position on the board.
This function iterates through all 8 possible directions (up, down, left, right, and the four diagonals) from the specified row and column on the board.
| row | The row index of the starting position on the board. |
| col | The column index of the starting position on the board. |


|
private |
Checks if the specified position on the board is occupied.
| row | The row index of the position to check. |
| col | The column index of the position to check. |
| InvalidInputException | if the position is occupied. |


|
overridevirtual |
Checks if the game of Reversi is finished.
This function determines if the game has ended by checking for valid moves for the current player. If no valid moves are found, it switches to the other player and checks again. If neither player has valid moves, the game is considered finished. The function then counts the pieces for each player on the board and returns the result.
Implementa Game.

|
overridevirtual |
Executes a move in the Reversi game.
This function performs the following steps:
Implementa Game.

|
overrideprivatevirtual |
Reads a move from the user and validates it.
| InvalidInputException | if the move is invalid. |
Implementa Game.


|
private |
Validates a move in the Reversi game.
This function checks if a move is valid by verifying the position, boundaries, and possible directions for flipping opponent's pieces.
| row | The row index of the move. |
| col | The column index of the move. |


|
staticprivate |
Array of possible directions for the Reversi game.
This array contains all the possible directions in which a move can be made in the Reversi game. Each direction is represented by a Reversi::Direction object, which takes two parameters indicating the change in row and column respectively.
Directions included: