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
FieldsModifier and TypeFieldDescriptionstatic final doubleMinimum and maximum bonusesstatic final intminimum and maximum number of columnsstatic final intminimum and maximum number of rowsstatic final doubleMinimum and maximum bonusesstatic final intminimum and maximum number of columnsstatic final intminimum and maximum number of rows -
Method Summary
Modifier and TypeMethodDescriptionallNodes()Return a collection containing all the nodes in the graph.longReturn the unique id of the current location.Return the Node corresponding to McDiver's location in the graph.intReturn 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.voidmoveTo(long id) See moveTo(Node<TileData> n)voidAttempt 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 intrunNewGame(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"intReturn 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:
currentLocationin 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:
distanceToRingin interfaceSeekState
-
currentNode
Description copied from interface:ScramStateReturn the Node corresponding to McDiver's location in the graph.- Specified by:
currentNodein interfaceScramState
-
exit
Description copied from interface:ScramStateReturn the Node associated with the exit from the sewer system. McDiver has to move to this Node in order to get out.- Specified by:
exitin interfaceScramState
-
allNodes
Description copied from interface:ScramStateReturn a collection containing all the nodes in the graph. They are in no particular order.- Specified by:
allNodesin interfaceScramState
-
moveTo
Attempt to move the sewerDiver from the current position to theNode n. ThrowIllegalArgumentExceptionifnis not neighboring. Increment the steps taken if successful.- Specified by:
moveToin interfaceScramState
-
stepsToGo
public int stepsToGo()Description copied from interface:ScramStateReturn 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:
stepsToGoin interfaceScramState
-
runNewGame
Given seed, whether to use the GUI, and an instance of a solution, run the game using that solution.
-