This class represents the game's minimax player.
More...
|
|
int | supplyInDirection (int currentPos, int direction, Board board) |
| Utility to get the distance of a possible supply in some direction. More...
|
|
int | opponetInDirection (int currentPos, int direction, Board board) |
| Utility to get the distance of a possible opponent in some direction. More...
|
|
double | evaluate (int currentPos, int direction, Board board) |
| This is the main move evaluation function. More...
|
|
Node | chooseMinMaxMove (Node node) |
| Executes the minimax algorithm and return a reference to selected move. More...
|
|
int [] | getNextMove (int currentPos) |
| Selects the best possible move to return. More...
|
|
int [] | move (int id) |
| MinMaxPlayer's move. More...
|
|
void | statistics () |
| Prints round information for the player. More...
|
|
void | final_statistics () |
| Prints final statistics for the player. More...
|
|
| Player (String name, boolean champion, Board board, int row, int column) throws Exception |
| Create a new player and put him at the row-column coordinates. More...
|
|
| Player (String name, boolean champion, Board board, int tileId) throws Exception |
| Create a new player and put him at the row-column coordinates. More...
|
|
int [] | move (int id) |
| Player's move. More...
|
|
void | statistics () |
| Prints round information for the player. More...
|
|
void | final_statistics () |
| Prints final statistics for the player. More...
|
|
int | playerTileId () |
| Utility to access player's tileID. More...
|
|
int | playerRow () |
| Utility to access player's row position (row coordinate) More...
|
|
int | playerCol () |
| Utility to access player's column position (column coordinate) More...
|
|
int | getPlayerId () |
|
String | getName () |
|
Board | getBoard () |
|
int | getScore () |
|
int | getX () |
|
int | getY () |
|
boolean | getChampion () |
|
int [] | getDirCounter () |
|
ArrayList< Integer[]> | getPath () |
|
void | setPlayerId (int id) |
|
void | setName (String name) |
|
void | setBoard (Board board) |
|
void | setScore (int score) |
|
void | setX (int x) |
|
void | setY (int y) |
|
void | setChampion (boolean champion) |
|
void | setDirCounter (int[] dirCounter) |
|
void | setPath (ArrayList< Integer[]> path) |
|
This class represents the game's minimax player.
Definition at line 19 of file MinMaxPlayer.java.
◆ MinMaxPlayer() [1/2]
host.labyrinth.MinMaxPlayer.MinMaxPlayer |
( |
String |
name, |
|
|
boolean |
champion, |
|
|
Board |
board, |
|
|
int |
row, |
|
|
int |
column |
|
) |
| throws Exception |
Create a new player and put him at the row-column coordinates.
- Parameters
-
name | The name of the player |
champion | Flag to indicate if a player is a champion |
board | Reference to the board of the game |
row | The row coordinate of initial player position |
column | The column coordinate of initial player's position |
Definition at line 32 of file MinMaxPlayer.java.
◆ MinMaxPlayer() [2/2]
host.labyrinth.MinMaxPlayer.MinMaxPlayer |
( |
String |
name, |
|
|
boolean |
champion, |
|
|
Board |
board, |
|
|
int |
tileId |
|
) |
| throws Exception |
Create a new player and put him at the row-column coordinates.
- Parameters
-
name | The name of the player |
champion | Flag to indicate if a player is a champion |
board | Reference to the board of the game |
tileId | The tileId coordinate of player's initial position |
Definition at line 43 of file MinMaxPlayer.java.
◆ chooseMinMaxMove()
Node host.labyrinth.MinMaxPlayer.chooseMinMaxMove |
( |
Node |
node | ) |
|
|
package |
Executes the minimax algorithm and return a reference to selected move.
- Parameters
-
node | The root node to start |
- Returns
- Reference to the selected move
Definition at line 122 of file MinMaxPlayer.java.
◆ createMySubtree()
void host.labyrinth.MinMaxPlayer.createMySubtree |
( |
int |
currentPos, |
|
|
int |
oppCurrentPos, |
|
|
Node |
parent, |
|
|
int |
depth |
|
) |
| |
|
private |
One of the 2 recursive functions for creating the minimax tree.
This one creates children for the MinMax player.
- Parameters
-
parent | The parent Node |
depth | The current depth for the children |
currentPos | The tile of MinMax player |
oppCurrentPos | The tile of the opponent |
- Note
- Even though unnecessary we calculate the evaluation for every node and not only for the leafs. This follows the exercise instructions. We could also rely on lazy evaluation of "evaluation()" and use AB pruning but the depth of the tree is not worth the try.
Definition at line 281 of file MinMaxPlayer.java.
◆ createOppSubtree()
void host.labyrinth.MinMaxPlayer.createOppSubtree |
( |
int |
currentPos, |
|
|
int |
oppCurrentPos, |
|
|
Node |
parent, |
|
|
int |
depth |
|
) |
| |
|
private |
One of the 2 recursive functions for creating the minimax tree.
This one creates children for the opponent player.
- Parameters
-
parent | The parent Node |
depth | The current depth for the children |
currentPos | The tile of MinMax player |
oppCurrentPos | The tile of the opponent |
- Note
- Even though unnecessary we calculate the evaluation for every node and not only for the leafs. This follows the exercise instructions. We could also rely on lazy evaluation of "evaluation()" and use AB pruning but the depth of the tree is not worth the try.
Definition at line 313 of file MinMaxPlayer.java.
◆ dryMove()
int [] host.labyrinth.MinMaxPlayer.dryMove |
( |
Board |
board, |
|
|
int |
currentPos, |
|
|
int |
dir, |
|
|
boolean |
champion |
|
) |
| |
|
private |
A simulated move in a copy of the bard.
- Parameters
-
board | The board on witch we simulate the move |
currentPos | The current position of the player to the board |
dir | The direction of the move |
champion | Flag to indicate if the player is champion or not |
- Returns
- The move array
Definition at line 255 of file MinMaxPlayer.java.
◆ evaluate()
double host.labyrinth.MinMaxPlayer.evaluate |
( |
int |
currentPos, |
|
|
int |
direction, |
|
|
Board |
board |
|
) |
| |
|
package |
This is the main move evaluation function.
- Parameters
-
currentPos | The current position of the player (before the move to evaluate) |
direction | The direction (a.k.a. the move) to evaluate |
board | Reference to the Board object to use |
- Returns
- A signed real number. The higher the output, the higher the evaluation.
Definition at line 103 of file MinMaxPlayer.java.
◆ final_statistics()
void host.labyrinth.MinMaxPlayer.final_statistics |
( |
| ) |
|
|
package |
◆ getNextMove()
int [] host.labyrinth.MinMaxPlayer.getNextMove |
( |
int |
currentPos | ) |
|
|
package |
Selects the best possible move to return.
- Parameters
-
currentPos | Player's current position to the board |
- Returns
- The move array
- Note
- This function always return a new move.
Definition at line 135 of file MinMaxPlayer.java.
◆ maxValue()
double host.labyrinth.MinMaxPlayer.maxValue |
( |
Node |
node | ) |
|
|
private |
The Minimax recursive function for the maximizing part.
- Parameters
-
- Returns
- The selected Node
Definition at line 344 of file MinMaxPlayer.java.
◆ minValue()
double host.labyrinth.MinMaxPlayer.minValue |
( |
Node |
node | ) |
|
|
private |
The Minimax recursive function for the minimizing part.
- Parameters
-
- Returns
- The selected Node
Definition at line 368 of file MinMaxPlayer.java.
◆ move()
int [] host.labyrinth.MinMaxPlayer.move |
( |
int |
id | ) |
|
|
package |
MinMaxPlayer's move.
A player of this kind cheats. He does not throw a dice to get a direction. In contrary he calculates his next move very carefully. If the player is a champion then he also picks up a possible supply from the tile.
- Parameters
-
id | The id of the starting tile. |
- Returns
- An array containing player's final position and possible supply of that position. The array format is:
-
int[0]: The tileId of the final player's position.
-
int[1]: The row of the final player's position.
-
int[2]: The column of the final player's position.
-
int[3]: The dice/direction of the move.
Definition at line 162 of file MinMaxPlayer.java.
◆ opponetInDirection()
int host.labyrinth.MinMaxPlayer.opponetInDirection |
( |
int |
currentPos, |
|
|
int |
direction, |
|
|
Board |
board |
|
) |
| |
|
package |
Utility to get the distance of a possible opponent in some direction.
- Parameters
-
currentPos | The current position of the player |
direction | The direction to check |
board | Reference to the Board object to use |
- Returns
- The distance or Const.noView
Definition at line 80 of file MinMaxPlayer.java.
◆ prevDirection()
int host.labyrinth.MinMaxPlayer.prevDirection |
( |
Node |
parent | ) |
|
|
private |
Get the previous direction of the player.
- Parameters
-
parent | Reference to previous nNode |
- Returns
- The previous direction if exist, else return Direction.NONE
Definition at line 240 of file MinMaxPlayer.java.
◆ statistics()
void host.labyrinth.MinMaxPlayer.statistics |
( |
| ) |
|
|
package |
◆ supplyInDirection()
int host.labyrinth.MinMaxPlayer.supplyInDirection |
( |
int |
currentPos, |
|
|
int |
direction, |
|
|
Board |
board |
|
) |
| |
|
package |
Utility to get the distance of a possible supply in some direction.
- Parameters
-
currentPos | The current position of the player |
direction | The direction to check |
board | Reference to the Board object to use |
- Returns
- The distance or Const.noView
Definition at line 58 of file MinMaxPlayer.java.
The documentation for this class was generated from the following file: