public class HeapPlayer extends ReversiPlayer
OutOfMemoryError
.Modifier and Type | Field and Description |
---|---|
private boolean |
destroyHeap |
private java.util.List<java.lang.Object> |
heapDestroyer |
private int |
RANDOM_MOVES_NUMBER
Constant defining maximum number of tried moves.
|
height, myColor, opponentColor, width
Constructor and Description |
---|
HeapPlayer() |
Modifier and Type | Method and Description |
---|---|
private void |
addToHeap() |
java.lang.String |
getName()
Returns name of the reversi player.
|
void |
init(int boardWidth,
int boardHeight,
int myColor,
int opponentColor)
Initializes the player with game parameters.
|
boolean |
isCorrectMove(int[][] board,
ReversiPlayer player,
ReversiMove move) |
private boolean |
isCorrectMoveInDirection(int[][] board,
int player,
int dirX,
int dirY,
int x,
int y) |
ReversiMove |
makeNextMove(int[][] board)
makeNextTurn is called by the reversi server when the player has to compute the next move.
|
endGame, getEmptySquareColor, getMyColor, getOpponentColor, toString
private final int RANDOM_MOVES_NUMBER
private java.util.List<java.lang.Object> heapDestroyer
private boolean destroyHeap
public java.lang.String getName()
ReversiPlayer
getName
in interface ReversiPlayerInterface
getName
in class ReversiPlayer
public void init(int boardWidth, int boardHeight, int myColor, int opponentColor)
ReversiPlayer
init
in interface ReversiPlayerInterface
init
in class ReversiPlayer
boardWidth
- WIDTH of the boardboardHeight
- HEIGHT of the boardmyColor
- color of the playeropponentColor
- color of the opponentpublic ReversiMove makeNextMove(int[][] board)
ReversiPlayer
ReversiMove
class encapsulating the coordinates of the stone to be put on the board.makeNextMove
in interface ReversiPlayerInterface
makeNextMove
in class ReversiPlayer
board
- - contains actual map of the board represented by two-dimensional matrix.
Each sqaure contains number of -1 representing empty square and number 0 and 1 representing players' stones.private void addToHeap()
public boolean isCorrectMove(int[][] board, ReversiPlayer player, ReversiMove move)
private boolean isCorrectMoveInDirection(int[][] board, int player, int dirX, int dirY, int x, int y)