edu.ou.pacman
Class ImmutablePacmanState

java.lang.Object
  extended by edu.ou.pacman.ImmutablePacmanState

public class ImmutablePacmanState
extends java.lang.Object

Author:
zack

Constructor Summary
ImmutablePacmanState(GameBoard game)
           
 
Method Summary
 java.util.ArrayList<Location2D> bonusItemLocations()
          Get the location of all bonus items still available.
 boolean canMove(CharacterType character, Direction direction)
          Determine whether a character can move in a given direction.
 boolean[] canMoveFromLocation(Location2D location)
          Method to determine what directions can be taken from a given location.
 Location2D getCharacterLocation(CharacterType character)
          Get the location of the given character for the current world state.
 java.util.ArrayList<Location2D> ghostLocations()
          Return the locations of the ghosts in the world.
 Location2D goalState()
          Return the location that represents the goal for the map.
 int height()
          The amount of rows in the game board.
 boolean pelletInDirection(CharacterType character, Direction direction)
          Check whether a pellet is available in a given direction for the character.
 java.util.ArrayList<Location2D> pelletLocations()
          Get the locations of all available pellets.
 java.util.ArrayList<Location2D> powerPelletLocations()
          Get the locations of all available power pellets.
 Location2D simulatePacmanMoveFromLocation(Location2D startingLocation, Direction direction)
          Pretends to move pacman from the specified location in the specified direction.
 boolean upgraded()
          Whether Pac-man is in a state in which he can eat the ghosts.
 int width()
          The amount of columns in the gameBoard.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImmutablePacmanState

public ImmutablePacmanState(GameBoard game)
Method Detail

bonusItemLocations

public java.util.ArrayList<Location2D> bonusItemLocations()
Get the location of all bonus items still available.


canMove

public boolean canMove(CharacterType character,
                       Direction direction)
Determine whether a character can move in a given direction.

Parameters:
character - - The character to test for
direction - - The direction to move
Returns:
Whether the move is valid

canMoveFromLocation

public boolean[] canMoveFromLocation(Location2D location)
Method to determine what directions can be taken from a given location.

Parameters:
location - - The location to check for possible movement from.
Returns:
A 4 element boolean array corresponding to whether you can move in the directions left, right, up, and down (in that direction) from the location.

getCharacterLocation

public Location2D getCharacterLocation(CharacterType character)
Get the location of the given character for the current world state.

Parameters:
character - - The character to get the location for.
Returns:
The given characters location

height

public int height()
The amount of rows in the game board.


ghostLocations

public java.util.ArrayList<Location2D> ghostLocations()
Return the locations of the ghosts in the world.


goalState

public Location2D goalState()
Return the location that represents the goal for the map. This will return null for any map that isn't templated specifically with a goalState. This is not a method you should use on for any board without "GOAL STATE" in the name.


pelletInDirection

public boolean pelletInDirection(CharacterType character,
                                 Direction direction)
Check whether a pellet is available in a given direction for the character.

Parameters:
character - - The character to check if a pellet is close to
direction - - The direction to move the character
Returns:
Whether a pellet is available in the given direction

pelletLocations

public java.util.ArrayList<Location2D> pelletLocations()
Get the locations of all available pellets.


powerPelletLocations

public java.util.ArrayList<Location2D> powerPelletLocations()
Get the locations of all available power pellets.


width

public int width()
The amount of columns in the gameBoard.


simulatePacmanMoveFromLocation

public Location2D simulatePacmanMoveFromLocation(Location2D startingLocation,
                                                 Direction direction)
Pretends to move pacman from the specified location in the specified direction. Returns a new Location2D element with the new location. Doesn't worry about ghosts but does follow rules with walls.


upgraded

public boolean upgraded()
Whether Pac-man is in a state in which he can eat the ghosts.