game

Class Detective

Implemented Interfaces:
Transport

public class Detective
extends AbstractPlayer

Inherits the class AbstractPlayer to define a detective
Version:
2.4 (19-APR-2010)
Author:
Shashi Mittal

Field Summary

Fields inherited from class game.AbstractPlayer

position, prevPositions

Fields inherited from interface game.Transport

BLACK, BUS, FERRY, INF, NONE, TAXI, UG

Method Summary

boolean
canMove(TestBoard board)
Checks if the detective can make a move or not
void
change(Node n, int ticket)
This method is a "quick and dirty" way of changing the position of a detective.
void
changePosition(Node n, int ticket)
This method changes the position of the detective provided he has the requisite tickets and the availability of that particular node
TreeSet
getPossibleMoves(TestBoard board)
This method returns the possible moves of the detective in a TreeSet
int
mobility()
This method calculates the mobility of the detective the mobility is a parameter which depends on the number of tickets of the detectives and on the ways the detective can go from his current position to adjacent positions.
void
setStaticState()
This method is used to make the necessary changes in case the detective cannot move i.e.
String
toString()
This method displays the current status of the detective

Methods inherited from class game.AbstractPlayer

change, getPosition, getPrevPos

Method Details

canMove

public boolean canMove(TestBoard board)
Checks if the detective can make a move or not
Parameters:
board - the current board positions
Returns:
true if the detective can move,false if the detective is stranded

change

public void change(Node n,
                   int ticket)
This method is a "quick and dirty" way of changing the position of a detective. It does not verify if the move is valid or not. This is supposed to be used in the tree search algorithm for finding best moves.
Parameters:
n - the new node position to which the detective will be moved to
ticket - the ticket used for moving to the new position

changePosition

public void changePosition(Node n,
                           int ticket)
This method changes the position of the detective provided he has the requisite tickets and the availability of that particular node

getPossibleMoves

public TreeSet getPossibleMoves(TestBoard board)
This method returns the possible moves of the detective in a TreeSet
Parameters:
board - the board of which this detective is a part of
Returns:
all the possible moves in TreeSet

mobility

public int mobility()
This method calculates the mobility of the detective the mobility is a parameter which depends on the number of tickets of the detectives and on the ways the detective can go from his current position to adjacent positions.
Returns:
the mobility of this detective

setStaticState

public void setStaticState()
This method is used to make the necessary changes in case the detective cannot move i.e. when the detective is stranded either because it does not have the required ticket, or all the neighbor nodes are occupied by other detectives.

toString

public String toString()
This method displays the current status of the detective