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 intindexprotected Maze.MazeNode[]neighbours -
Constructor Summary
Constructors Constructor Description MazeNode(int index) -
Method Summary
Modifier and Type Method Description Directiondirection(int neighbour)Returns a direction for 'neighbour' ...Directiondirection(Maze.MazeNode neighbour)Returns a direction for 'neighbour' ...Maze.MazeNodegetRandomLink()Returns random neighbor.Maze.MazeNodegetRandomLink(Maze.MazeNode... forbidden)Returns random neighbor that is not within 'forbidden' list of nodes.booleanghost()Is there a ghost (either edible/dangerous) on this node?booleanghostDanger()Is there a ghost that can kill Ms Pac-Man on this node?booleanghostEdible()Is there an edible ghost on this node?booleanhasLink(Direction direction)If there is walkable node in given 'direction'.booleanjunction()Is this node a JUNCTION (T_CROSS or CROSS) => requires decision what to do.Maze.MazeNodelink(Direction direction)Returns aMaze.MazeNodein given 'direction' or NULL if there is a wall.Maze.MazeNode[]links()Array[UP, RIGHT, DOWN, LEFT] (as defined byDirection.index).Maze.NodeCategorynodeCategory()ReturnsMaze.NodeCategory...Maze.NodeTypenodeType()ConcreteMaze.NodeTypeof givenMaze.NodeCategory.Maze.MazeNode[]options(Maze.MazeNode... forbidden)Filterslinks().booleanpacman()Is there a Ms Pac-Man on this node?booleanpill()Is there a pill on this node?java.lang.IntegerpillIndex()booleanpowerPill()Is there a power pill on this node?java.lang.StringtoString()intx()X-coordinate of the node.inty()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.NodeTypeof 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.MazeNodein given 'direction' or NULL if there is a wall.Direction.NONEevaluates to 'this'.- Parameters:
direction-- Returns:
-
hasLink
If there is walkable node in given 'direction'.Direction.NONEevaluates 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:
toStringin classjava.lang.Object
-