game
Class TestBoard
- Comparable, Comparator, Transport
public class TestBoard
extends java.lang.Object
Defines the board for the game. The main workhorse of the game.
void | changeDetectivePosition(int i, Move move) - This method is used to change the position of a detective
|
int | compare(Object b1, Object b2) - This method compares two objects of this class depending on the score of
the boards
|
int | compareTo(Object o) - This method compares this board to another board o
|
boolean | equal(TestBoard b1, TestBoard b2) - This method checks whether two boards are equal
|
int | getCurrentMoves() - This method returns the currentMoves of this object.
|
TreeSet | getDetectivePossibleMoves(int i) - This method returns all the possible moves for a given detective
|
Detective[] | getDetectives() - This method is used to get the detectives of this board.
|
Fugitive | getMrX() - This method is used to get the MrX of this object.
|
static int | getNumberOfDetectives()
|
Point | getPoint(int nodeIndex) - Returns the pixel coordinates of the specified node on the map.
|
boolean | isCheckPoint() - This method checks if Mr.
|
boolean | isCheckPoint(int move) - This method checks if Mr.
|
boolean | isMachineWin() - Checks whether the machine has won
|
boolean | isUserWin() - Checks if the user has won
|
Move | moveMrX() - This method computes a move for Mr.
|
void | printBoard() - This method prints the board i.e what are the nodes what are the links.
|
void | printPossibleDetectiveMoves() - Prints all the possible detective moves for the current board positions
of the detectives, together with the corresponding scores for each new
positions of the detectives.
|
void | setDepth(int d) - This method changes the difficulty level for the game
|
void | test() - Prints the shortest distance matrix
|
String | toString() - String representation of this board.
|
changeDetectivePosition
public void changeDetectivePosition(int i,
Move move)
This method is used to change the position of a detective
i
- the index of the detective whose position we want to changemove
- the new move for this detective
compare
public int compare(Object b1,
Object b2)
This method compares two objects of this class depending on the score of
the boards
b1
- the first boardb2
- the second board
- negative if score of b1 less then score of b2 positive otherwise
compareTo
public int compareTo(Object o)
This method compares this board to another board o
o
- the board with which this is to be compared
- similar to the compare() method
equal
public boolean equal(TestBoard b1,
TestBoard b2)
This method checks whether two boards are equal
b1
- the first boardb2
- the second board
- true if the boards are equal,false otherwise
getCurrentMoves
public int getCurrentMoves()
This method returns the currentMoves of this object.
- the currentMoves of this object
getDetectivePossibleMoves
public TreeSet getDetectivePossibleMoves(int i)
This method returns all the possible moves for a given detective
i
- the detective index of the detective whose possible moves we
want
- the possible moves of this detective in a TreeSet. If this
detective cannot move, it returns null.
getDetectives
public Detective[] getDetectives()
This method is used to get the detectives of this board.
- the array containing the detectives of the current game.
getMrX
public Fugitive getMrX()
This method is used to get the MrX of this object.
getNumberOfDetectives
public static int getNumberOfDetectives()
getPoint
public Point getPoint(int nodeIndex)
Returns the pixel coordinates of the specified node on the map.
isCheckPoint
public boolean isCheckPoint()
This method checks if Mr. X has to reveal his position at this move or not.
- true if Mr. X has to reveal himself at this move, false
otherwise.
isCheckPoint
public boolean isCheckPoint(int move)
This method checks if Mr. X has to reveal his position at a given move or not
move
- the index of the move for which we want to check if it is a
checkpoint
- true if move is a checkpoint, false otherwise
isMachineWin
public boolean isMachineWin()
Checks whether the machine has won
- true if machine has won,otherwise false
isUserWin
public boolean isUserWin()
Checks if the user has won
- true if the user has won, otherwise false
moveMrX
public Move moveMrX()
This method computes a move for Mr. X and returns that move.
- The move computed for Mr. X.
printBoard
public void printBoard()
This method prints the board i.e what are the nodes what are the links.
It is useful for testing if the map which has been entered is correct or
not
printPossibleDetectiveMoves
public void printPossibleDetectiveMoves()
Prints all the possible detective moves for the current board positions
of the detectives, together with the corresponding scores for each new
positions of the detectives.
setDepth
public void setDepth(int d)
This method changes the difficulty level for the game
d
- the required difficulty level
test
public void test()
Prints the shortest distance matrix
toString
public String toString()
String representation of this board.
- the score of this board in String form.