Package game

Class Sewers

java.lang.Object
game.Sewers

public class Sewers extends Object
A sewer through which a sewer diver can move: a grid of Tile objects with a weighted graph of all non-floor tiles.

There is an entrance to the sewer system and a ring location (which may also be the entrance).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    An enum representing a grid direction.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Return the number of columns in the grid.
    static Sewers
    deserialize(List<String> nodeStrList)
    Convert nodeStrList, which was output by serialize(), back into a Sewers.
    static Sewers
    digExploreSewer(int r, int c, Random rand)
    Return a new random sewer system with r rows, c columns, and no coins, all edges have weight 1, and there is a ring a reasonable distance from the exit.
    static Sewers
    digGetOutSewer(int r, int c, int currentRow, int currentCol, Random rand)
    Return a new random sewer system with r rows, c columns, and random coins and edge weights.
    Return the node corresponding to the entrance to the sewer system.
    Return the set of all nodes in the graph.
    nodeAt(int r, int c)
    Return the node at the given (r, c).
    int
    Return the number of open floor tiles in this sewer system (this is the size of the graph).
    Return the ring node in this sewer system.
    int
    Return the number of rows in the grid.
    Serialize this sewer system to a list of strings that can be written out to a file.
    tileAt(int r, int c)
    Return the Tile information for tile (r, c).

    Methods inherited from class java.lang.Object

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

  • Method Details

    • digExploreSewer

      public static Sewers digExploreSewer(int r, int c, Random rand)
      Return a new random sewer system with r rows, c columns, and no coins, all edges have weight 1, and there is a ring a reasonable distance from the exit. rand is the source of randomness for the sewer-system generation.
    • digGetOutSewer

      public static Sewers digGetOutSewer(int r, int c, int currentRow, int currentCol, Random rand)
      Return a new random sewer system with r rows, c columns, and random coins and edge weights. It is guaranteed that (currentRow, {currentCol) will be an open floor cell. rand is the source of randomness to use for the sewer-system generation.
    • numOpenTiles

      public int numOpenTiles()
      Return the number of open floor tiles in this sewer system (this is the size of the graph).
    • rowCount

      public int rowCount()
      Return the number of rows in the grid.
    • columnCount

      public int columnCount()
      Return the number of columns in the grid.
    • graph

      public Set<Node> graph()
      Return the set of all nodes in the graph. This is an umodifiable view of the graph.
    • entrance

      public Node entrance()
      Return the node corresponding to the entrance to the sewer system.
    • ring

      public Node ring()
      Return the ring node in this sewer system.
    • tileAt

      public Tile tileAt(int r, int c)
      Return the Tile information for tile (r, c). Requires: (r, c) must be in the grid.
    • nodeAt

      public Node nodeAt(int r, int c)
      Return the node at the given (r, c). Requires: (r, c) must be in the grid.
    • serialize

      public List<String> serialize()
      Serialize this sewer system to a list of strings that can be written out to a file. The list of strings can be converted back into a Sewers using deserialize().
    • deserialize

      public static Sewers deserialize(List<String> nodeStrList)
      Convert nodeStrList, which was output by serialize(), back into a Sewers. Requires: The list of strings is of the format output by serialize().