Package org.swtpra1
Class AIPlayer
- java.lang.Object
-
- org.swtpra1.AIPlayer
-
- Direct Known Subclasses:
AlphaBetaPlayer
,RandomPlayer
,RelativeTerritoryPlayer
public abstract class AIPlayer extends java.lang.Object
Abstract class for all player implementations. Subclasses need to implement the calculateTurn functionality. To help with that the class offers functionality to calculate the possible turns given a position
-
-
Field Summary
Fields Modifier and Type Field Description static long
BUFFER_TIME
static long
DEFAULT_MAX_TURN_TIME
-
Constructor Summary
Constructors Constructor Description AIPlayer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Turn
calculateTurn(int gameId, Board board, int playerId, Turn enemyTurn)
Calculates best turn in the players' view.abstract Turn
calculateTurn(int gameId, Board board, int playerId, Turn enemyTurn, long maxTurnTime)
Calculates best turn in the players' view within a given timelimit.protected static java.util.List<Square>
generateQueensMoves(Square startingSquare, Board board)
Gets the Squares a queen can move to from a given square It is used to generate the queen and shot squares.static java.util.List<Turn>
getAllPossibleTurns(Board board, int playerId)
Get all possible turns of a player on the board.void
newGame()
-
-
-
Field Detail
-
DEFAULT_MAX_TURN_TIME
public static final long DEFAULT_MAX_TURN_TIME
-
BUFFER_TIME
public static final long BUFFER_TIME
- See Also:
- Constant Field Values
-
-
Method Detail
-
calculateTurn
public abstract Turn calculateTurn(int gameId, Board board, int playerId, Turn enemyTurn)
Calculates best turn in the players' view.- Parameters:
gameId
- the id of the game that is being playedboard
- the current board stateplayerId
- our player idenemyTurn
- the turn played by the enemy- Returns:
- best possible turn
-
calculateTurn
public abstract Turn calculateTurn(int gameId, Board board, int playerId, Turn enemyTurn, long maxTurnTime)
Calculates best turn in the players' view within a given timelimit.- Parameters:
gameId
- the id of the game that is being playedboard
- the current board stateplayerId
- our player idenemyTurn
- the turn played by the enemymaxTurnTime
- the time we are given to calculate the turn in ms- Returns:
- best possible turn
-
newGame
public void newGame()
-
getAllPossibleTurns
public static java.util.List<Turn> getAllPossibleTurns(Board board, int playerId)
Get all possible turns of a player on the board.- Parameters:
board
- The current board.playerId
- The relative player id of the player whose possible turns we want to get.- Returns:
- List of all possible turns a player can make.
-
generateQueensMoves
protected static java.util.List<Square> generateQueensMoves(Square startingSquare, Board board)
Gets the Squares a queen can move to from a given square It is used to generate the queen and shot squares.- Parameters:
startingSquare
- The start square.board
- The current board.- Returns:
- The list of squares where a queen can go.
-
-