games.sy
Class ScotlandYard

java.lang.Object
  extended by games.sy.ScotlandYard

public class ScotlandYard
extends java.lang.Object


Field Summary
static int BLACK_FARE
           
static int BUS
           
static int DETECTIVE1
           
static int DETECTIVE2
           
static int DETECTIVE3
           
static int DETECTIVE4
           
static int DETECTIVE5
           
static int MR_X
           
static int TAXI
           
static int UNDERGROUND
           
 
Constructor Summary
ScotlandYard()
          Initializes a game with default map
ScotlandYard(int[] sl)
          Initializes a game with default map and given initial locations
ScotlandYard(java.lang.String map)
          Initializes a game with selected map
ScotlandYard(java.lang.String map, int[] sl)
          Initializes a game with selected map and initial locations
ScotlandYard(java.lang.String map, java.lang.String settings)
          Initializes a game with selected map and settings
 
Method Summary
static boolean doubleMove(int move)
          Returns whether the move is combined with a double move ticket
static int from(int move)
          Returns the source location of a move
 int getMaxRound()
          Returns the maximum number of rounds (default: 24)
 int getNumDoubleMoves()
          Returns the number of double move tickets left
 int getNumLocations()
          Returns the number of locations (default: 199)
 int getNumMovesPlayed()
          Returns the number of moves played
 int getNumPlayers()
          Returns the number of players (default: 6)
 int getNumTickets(int player, int type)
          Returns the number of tickets a player has left of a type
 int getPlayedMrXTicket(int round)
          Returns the ticket type played by Mr X in a given round
 int getPlayerLocation(int player)
          Returns location of the player
 int getPlayerLocationAtRound(int player, int round)
          Returns location of the player in a given round
 int getRound()
          Returns the round number
 java.util.ArrayList<java.lang.Integer> getValidMoves(int player)
          Returns list of valid moves for the player (without double move ticket)
 java.util.ArrayList<java.lang.Integer> getValidMoves(int player, boolean dm)
          Returns list of valid moves for the player
static int intRep(int player)
          Makes an integer representation of an empty move
static int intRep(int player, int from, int type, int target, boolean doubleMove)
          Makes an integer representation of a move. type must be ScotlandYard.TAXI, ScotlandYard.BUS, ScotlandYard.UNDERGROUND or ScotlandYard.BLACK_FARE
 boolean isFinished()
          Checks whether the game is finished
 boolean isLegal(int move)
          Checks whether a move is legal
 boolean isMaxRoundReached()
          Checks whether the maximum number of rounds is reached
 int isMrXCaptured()
          Checks whether Mr X is captured
 boolean isStuck(int player)
          Checks whether a detective is stuck
 boolean isSurfaceRound(int round)
          Returns whether the round is a surface round
 boolean move(int move)
          Performs a move
 boolean move(int move, boolean updateDpl)
          Performs a move
static java.lang.String moveString(int move)
          Gives a String representation of a move
static int player(int move)
          Returns the player of a move
 void reset()
          Resets the game
static int target(int move)
          Returns the target location of a move
 java.lang.String toString()
           
static int type(int move)
          Returns the ticket type of a move.
 boolean undo(int move)
          Undoes a move
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TAXI

public static final int TAXI
See Also:
Constant Field Values

BUS

public static final int BUS
See Also:
Constant Field Values

UNDERGROUND

public static final int UNDERGROUND
See Also:
Constant Field Values

BLACK_FARE

public static final int BLACK_FARE
See Also:
Constant Field Values

MR_X

public static final int MR_X
See Also:
Constant Field Values

DETECTIVE1

public static final int DETECTIVE1
See Also:
Constant Field Values

DETECTIVE2

public static final int DETECTIVE2
See Also:
Constant Field Values

DETECTIVE3

public static final int DETECTIVE3
See Also:
Constant Field Values

DETECTIVE4

public static final int DETECTIVE4
See Also:
Constant Field Values

DETECTIVE5

public static final int DETECTIVE5
See Also:
Constant Field Values
Constructor Detail

ScotlandYard

public ScotlandYard()
Initializes a game with default map


ScotlandYard

public ScotlandYard(int[] sl)
Initializes a game with default map and given initial locations

Parameters:
sl - the initial locations of the players

ScotlandYard

public ScotlandYard(java.lang.String map)
Initializes a game with selected map

Parameters:
map - the map name

ScotlandYard

public ScotlandYard(java.lang.String map,
                    int[] sl)
Initializes a game with selected map and initial locations

Parameters:
map - the map name
sl - the initial locations of the players

ScotlandYard

public ScotlandYard(java.lang.String map,
                    java.lang.String settings)
Initializes a game with selected map and settings

Parameters:
map - the map name
settings - the settings file
Method Detail

reset

public void reset()
Resets the game


getNumPlayers

public int getNumPlayers()
Returns the number of players (default: 6)

Returns:

getNumMovesPlayed

public int getNumMovesPlayed()
Returns the number of moves played

Returns:

getNumLocations

public int getNumLocations()
Returns the number of locations (default: 199)

Returns:

getRound

public int getRound()
Returns the round number

Returns:

isSurfaceRound

public boolean isSurfaceRound(int round)
Returns whether the round is a surface round

Parameters:
round -
Returns:

getMaxRound

public int getMaxRound()
Returns the maximum number of rounds (default: 24)

Returns:

getValidMoves

public java.util.ArrayList<java.lang.Integer> getValidMoves(int player)
Returns list of valid moves for the player (without double move ticket)

Parameters:
player -
Returns:

getValidMoves

public java.util.ArrayList<java.lang.Integer> getValidMoves(int player,
                                                            boolean dm)
Returns list of valid moves for the player

Parameters:
player -
dm - whether or not to include moves with double move ticket
Returns:

getNumDoubleMoves

public int getNumDoubleMoves()
Returns the number of double move tickets left

Returns:

move

public boolean move(int move)
Performs a move

Parameters:
move -
Returns:

move

public boolean move(int move,
                    boolean updateDpl)
Performs a move

Parameters:
move -
updateDpl - whether or not to update list of possible locations
Returns:

isLegal

public boolean isLegal(int move)
Checks whether a move is legal

Parameters:
move -
Returns:

undo

public boolean undo(int move)
Undoes a move

Parameters:
move -
Returns:

getPlayerLocation

public int getPlayerLocation(int player)
Returns location of the player

Parameters:
player -
Returns:

getPlayerLocationAtRound

public int getPlayerLocationAtRound(int player,
                                    int round)
Returns location of the player in a given round

Parameters:
player -
round -
Returns:

getPlayedMrXTicket

public int getPlayedMrXTicket(int round)
Returns the ticket type played by Mr X in a given round

Parameters:
round -
Returns:

getNumTickets

public int getNumTickets(int player,
                         int type)
Returns the number of tickets a player has left of a type

Parameters:
player -
type -
Returns:

isMrXCaptured

public int isMrXCaptured()
Checks whether Mr X is captured

Returns:

isStuck

public boolean isStuck(int player)
Checks whether a detective is stuck

Parameters:
player -
Returns:

isMaxRoundReached

public boolean isMaxRoundReached()
Checks whether the maximum number of rounds is reached

Returns:

isFinished

public boolean isFinished()
Checks whether the game is finished

Returns:

intRep

public static int intRep(int player,
                         int from,
                         int type,
                         int target,
                         boolean doubleMove)
Makes an integer representation of a move. type must be ScotlandYard.TAXI, ScotlandYard.BUS, ScotlandYard.UNDERGROUND or ScotlandYard.BLACK_FARE

Parameters:
player -
from -
type -
target -
doubleMove -
Returns:

intRep

public static int intRep(int player)
Makes an integer representation of an empty move

Parameters:
player -
Returns:

player

public static int player(int move)
Returns the player of a move

Parameters:
move -
Returns:

from

public static int from(int move)
Returns the source location of a move

Parameters:
move -
Returns:

type

public static int type(int move)
Returns the ticket type of a move. This can be ScotlandYard.TAXI, ScotlandYard.BUS, ScotlandYard.UNDERGROUND or ScotlandYard.BLACK_FARE

Parameters:
move -
Returns:

target

public static int target(int move)
Returns the target location of a move

Parameters:
move -
Returns:

doubleMove

public static boolean doubleMove(int move)
Returns whether the move is combined with a double move ticket

Parameters:
move -
Returns:

moveString

public static java.lang.String moveString(int move)
Gives a String representation of a move

Parameters:
move -
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object