Class Maze.MazeNode

java.lang.Object
game.controllers.pacman.modules.Maze.MazeNode
Enclosing class:
Maze

public class Maze.MazeNode
extends java.lang.Object
  • Field Details

  • Constructor Details

    • MazeNode

      public MazeNode​(int index)
  • Method Details

    • x

      public int x()
      X-coordinate of the node.
      Returns:
    • y

      public int y()
      Y-coordinate of the node.
      Returns:
    • pill

      public boolean pill()
      Is there a pill on this node?
      Returns:
    • powerPill

      public boolean powerPill()
      Is there a power pill on this node?
      Returns:
    • pacman

      public boolean pacman()
      Is there a Ms Pac-Man on this node?
      Returns:
    • ghost

      public boolean ghost()
      Is there a ghost (either edible/dangerous) on this node?
      Returns:
    • ghostEdible

      public boolean ghostEdible()
      Is there an edible ghost on this node?
      Returns:
    • ghostDanger

      public boolean ghostDanger()
      Is there a ghost that can kill Ms Pac-Man on this node?
      Returns:
    • nodeCategory

      public Maze.NodeCategory nodeCategory()
      Returns Maze.NodeCategory ... Cross / T-Cross / Corridor / Junction.
      Returns:
    • nodeType

      public Maze.NodeType nodeType()
      Concrete Maze.NodeType of given Maze.NodeCategory.
      Returns:
    • junction

      public boolean junction()
      Is this node a JUNCTION (T_CROSS or CROSS) => requires decision what to do.
      Returns:
    • links

      public Maze.MazeNode[] links()
      Array[UP, RIGHT, DOWN, LEFT] (as defined by Direction.index). Array may contain NULLs == wall.
      Returns:
    • options

      public Maze.MazeNode[] options​(Maze.MazeNode... forbidden)
      Filters links(). Array[UP, RIGHT, DOWN, LEFT] (as defined by Direction.index). Array may contain NULLs == wall || forbidden node.
      Returns:
    • link

      public Maze.MazeNode link​(Direction direction)
      Returns a Maze.MazeNode in given 'direction' or NULL if there is a wall. Direction.NONE evaluates to 'this'.
      Parameters:
      direction -
      Returns:
    • hasLink

      public boolean hasLink​(Direction direction)
      If there is walkable node in given 'direction'. Direction.NONE evaluates to 'null'.
      Parameters:
      direction -
      Returns:
    • getRandomLink

      public Maze.MazeNode getRandomLink()
      Returns random neighbor.
      Returns:
    • getRandomLink

      public Maze.MazeNode getRandomLink​(Maze.MazeNode... forbidden)
      Returns random neighbor that is not within 'forbidden' list of nodes.
      Returns:
    • direction

      public Direction direction​(Maze.MazeNode neighbour)
      Returns a direction for 'neighbour' ... must be immediate neighbour!
      Parameters:
      neighbour -
      Returns:
    • direction

      public Direction direction​(int neighbour)
      Returns a direction for 'neighbour' ... must be immediate neighbour!
      Parameters:
      neighbour -
      Returns:
    • pillIndex

      public java.lang.Integer pillIndex()
    • toString

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