Package game

Class GameState

java.lang.Object
game.GameState
All Implemented Interfaces:
ScramState, SeekState

public class GameState extends Object implements SeekState, ScramState
The game controller. The diver algorithm calls into this class to move the diver around, through the SeekState and ScramState interfaces.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Minimum and maximum bonuses
    static final int
    minimum and maximum number of columns
    static final int
    minimum and maximum number of rows
    static final double
    Minimum and maximum bonuses
    static final int
    minimum and maximum number of columns
    static final int
    minimum and maximum number of rows
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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 the Node 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MIN_ROWS

      public static final int MIN_ROWS
      minimum and maximum number of rows
      See Also:
    • MAX_ROWS

      public static final int MAX_ROWS
      minimum and maximum number of rows
      See Also:
    • MIN_COLS

      public static final int MIN_COLS
      minimum and maximum number of columns
      See Also:
    • MAX_COLS

      public static final int MAX_COLS
      minimum and maximum number of columns
      See Also:
    • MIN_BONUS

      public static final double MIN_BONUS
      Minimum and maximum bonuses
      See Also:
    • MAX_BONUS

      public static final double MAX_BONUS
      Minimum and maximum bonuses
      See Also:
  • Method Details

    • scramSucceeded

      public boolean scramSucceeded()
      = "scram succeeded"
    • moveTo

      public void moveTo(long id)
      See moveTo(Node<TileData> n)
      Specified by:
      moveTo in interface SeekState
      Parameters:
      id - The Id of the neighboring Node to move to
    • currentLocation

      public long currentLocation()
      Return the unique id of the current location.
      Specified by:
      currentLocation in interface SeekState
    • neighbors

      public Collection<NodeStatus> neighbors()
      Return a collection of NodeStatus objects that contain the unique ID of the node and the distance from that node to the ring.
      Specified by:
      neighbors in interface SeekState
    • distanceToRing

      public int distanceToRing()
      Return the Manhattan distance from the current location to the ring location on the map.
      Specified by:
      distanceToRing in interface SeekState
    • currentNode

      public Node currentNode()
      Description copied from interface: ScramState
      Return the Node corresponding to McDiver's location in the graph.
      Specified by:
      currentNode in interface ScramState
    • exit

      public Node 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 interface ScramState
    • allNodes

      public Collection<Node> 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 interface ScramState
    • moveTo

      public void moveTo(Node n)
      Attempt to move the sewerDiver from the current position to the Node n. Throw IllegalArgumentException if n is not neighboring. Increment the steps taken if successful.
      Specified by:
      moveTo in interface ScramState
    • 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 interface ScramState
    • runNewGame

      public 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.