Package game
Class GameState
java.lang.Object
game.GameState
- All Implemented Interfaces:
ScramState
,SeekState
The game controller. The diver algorithm calls into this class to move the diver around,
through the SeekState and ScramState interfaces.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
Minimum and maximum bonusesstatic final int
minimum and maximum number of columnsstatic final int
minimum and maximum number of rowsstatic final double
Minimum and maximum bonusesstatic final int
minimum and maximum number of columnsstatic final int
minimum and maximum number of rows -
Method Summary
Modifier and TypeMethodDescriptionallNodes()
Return a collection containing all the nodes in the graph.long
Return the unique id of the current location.Return the Node corresponding to McDiver's location in the graph.int
Return the Manhattan distance from the current location to the ring location on the map.exit()
Return the Node associated with the exit from the sewer system.void
moveTo
(long id) See moveTo(Node<TileData> n)void
Attempt to move the sewerDiver from the current position to theNode n
.Return a collection of NodeStatus objects that contain the unique ID of the node and the distance from that node to the ring.static int
runNewGame
(long seed, boolean useGui, SewerDiver solution) Given seed, whether to use the GUI, and an instance of a solution, run the game using that solution.boolean
= "scram succeeded"int
Return the steps remaining to get out of the sewer system.
-
Field Details
-
MIN_ROWS
public static final int MIN_ROWSminimum and maximum number of rows- See Also:
-
MAX_ROWS
public static final int MAX_ROWSminimum and maximum number of rows- See Also:
-
MIN_COLS
public static final int MIN_COLSminimum and maximum number of columns- See Also:
-
MAX_COLS
public static final int MAX_COLSminimum and maximum number of columns- See Also:
-
MIN_BONUS
public static final double MIN_BONUSMinimum and maximum bonuses- See Also:
-
MAX_BONUS
public static final double MAX_BONUSMinimum and maximum bonuses- See Also:
-
-
Method Details
-
scramSucceeded
public boolean scramSucceeded()= "scram succeeded" -
moveTo
public void moveTo(long id) See moveTo(Node<TileData> n) -
currentLocation
public long currentLocation()Return the unique id of the current location.- Specified by:
currentLocation
in interfaceSeekState
-
neighbors
Return a collection of NodeStatus objects that contain the unique ID of the node and the distance from that node to the ring. -
distanceToRing
public int distanceToRing()Return the Manhattan distance from the current location to the ring location on the map.- Specified by:
distanceToRing
in interfaceSeekState
-
currentNode
Description copied from interface:ScramState
Return the Node corresponding to McDiver's location in the graph.- Specified by:
currentNode
in interfaceScramState
-
exit
Description copied from interface:ScramState
Return the Node associated with the exit from the sewer system. McDiver has to move to this Node in order to get out.- Specified by:
exit
in interfaceScramState
-
allNodes
Description copied from interface:ScramState
Return a collection containing all the nodes in the graph. They are in no particular order.- Specified by:
allNodes
in interfaceScramState
-
moveTo
Attempt to move the sewerDiver from the current position to theNode n
. ThrowIllegalArgumentException
ifn
is not neighboring. Increment the steps taken if successful.- Specified by:
moveTo
in interfaceScramState
-
stepsToGo
public int stepsToGo()Description copied from interface:ScramState
Return the steps remaining to get out of the sewer system. This value will change with every call to moveTo(Node), and if it reaches 0 before you get out, you have failed to get out.- Specified by:
stepsToGo
in interfaceScramState
-
runNewGame
Given seed, whether to use the GUI, and an instance of a solution, run the game using that solution.
-