Package game.controllers.pacman.modules
Class Maze.MazeNode
java.lang.Object
game.controllers.pacman.modules.Maze.MazeNode
- Enclosing class:
- Maze
public class Maze.MazeNode
extends java.lang.Object
-
Field Summary
Fields Modifier and Type Field Description int
index
protected Maze.MazeNode[]
neighbours
-
Constructor Summary
Constructors Constructor Description MazeNode(int index)
-
Method Summary
Modifier and Type Method Description Direction
direction(int neighbour)
Returns a direction for 'neighbour' ...Direction
direction(Maze.MazeNode neighbour)
Returns a direction for 'neighbour' ...Maze.MazeNode
getRandomLink()
Returns random neighbor.Maze.MazeNode
getRandomLink(Maze.MazeNode... forbidden)
Returns random neighbor that is not within 'forbidden' list of nodes.boolean
ghost()
Is there a ghost (either edible/dangerous) on this node?boolean
ghostDanger()
Is there a ghost that can kill Ms Pac-Man on this node?boolean
ghostEdible()
Is there an edible ghost on this node?boolean
hasLink(Direction direction)
If there is walkable node in given 'direction'.boolean
junction()
Is this node a JUNCTION (T_CROSS or CROSS) => requires decision what to do.Maze.MazeNode
link(Direction direction)
Returns aMaze.MazeNode
in given 'direction' or NULL if there is a wall.Maze.MazeNode[]
links()
Array[UP, RIGHT, DOWN, LEFT] (as defined byDirection.index
).Maze.NodeCategory
nodeCategory()
ReturnsMaze.NodeCategory
...Maze.NodeType
nodeType()
ConcreteMaze.NodeType
of givenMaze.NodeCategory
.Maze.MazeNode[]
options(Maze.MazeNode... forbidden)
Filterslinks()
.boolean
pacman()
Is there a Ms Pac-Man on this node?boolean
pill()
Is there a pill on this node?java.lang.Integer
pillIndex()
boolean
powerPill()
Is there a power pill on this node?java.lang.String
toString()
int
x()
X-coordinate of the node.int
y()
Y-coordinate of the node.
-
Field Details
-
index
public int index -
neighbours
-
-
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
ReturnsMaze.NodeCategory
... Cross / T-Cross / Corridor / Junction.- Returns:
-
nodeType
ConcreteMaze.NodeType
of givenMaze.NodeCategory
.- Returns:
-
junction
public boolean junction()Is this node a JUNCTION (T_CROSS or CROSS) => requires decision what to do.- Returns:
-
links
Array[UP, RIGHT, DOWN, LEFT] (as defined byDirection.index
). Array may contain NULLs == wall.- Returns:
-
options
Filterslinks()
. Array[UP, RIGHT, DOWN, LEFT] (as defined byDirection.index
). Array may contain NULLs == wall || forbidden node.- Returns:
-
link
Returns aMaze.MazeNode
in given 'direction' or NULL if there is a wall.Direction.NONE
evaluates to 'this'.- Parameters:
direction
-- Returns:
-
hasLink
If there is walkable node in given 'direction'.Direction.NONE
evaluates to 'null'.- Parameters:
direction
-- Returns:
-
getRandomLink
Returns random neighbor.- Returns:
-
getRandomLink
Returns random neighbor that is not within 'forbidden' list of nodes.- Returns:
-
direction
Returns a direction for 'neighbour' ... must be immediate neighbour!- Parameters:
neighbour
-- Returns:
-
direction
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 classjava.lang.Object
-