edu.ou.pacman.board
Class GameBoard

java.lang.Object
  extended by edu.ou.pacman.board.GameBoard

public class GameBoard
extends java.lang.Object

Class used to perform all actions for the game. Holds the characters, locations, items, etc.

Author:
Derek Rushing

Field Summary
static int GAME_OVER_REWARD
           
static int GHOST_WORTH
           
 int m_maxSteps
           
 boolean[] m_xThroughWayIndecies
           
 boolean[] m_yThroughWayIndecies
           
static int PELLET_WORTH
           
 
Constructor Summary
GameBoard(boolean hasView, AI pacman_ai, AI team_ai, java.lang.String template)
           
 
Method Summary
 BoardLocation[][] board()
           
 java.util.ArrayList<Location2D> bonusItemLocations()
          Return a list of all available bonus items still on the board.
 int bonusItemsCollected()
           
static int bonusValue(BonusType bonus)
          Return the value of the given bonus.
 boolean canMove(CharacterType character, Direction direction)
          Determine whether a player can move in a given direction.
 Location2D characterLocation(CharacterType character)
          Returns the location of the given character.
 int[] charactersVisible(CharacterType character1, CharacterType character2)
          Checks whether 2 characters are in sight of each other in any direction.
 void cleanupGame()
           
 boolean[] colorsEatenCurrently()
          Blue, Orange, Pink, Red
 boolean[] directionsToCharacter(CharacterType char1, CharacterType char2)
          Gives the directions from char1 to char2.
 void endGame()
          End the game.
 boolean gameOver()
           
 PacmanCharacter[] getCharacters()
           
 java.util.ArrayList<Location2D> ghostLocations()
          Returns a list of all the locations a ghost currently occupies.
 Location2D goalState()
          Returns the goal state of this game board.
 int height()
           
 boolean isRunning()
           
 CharacterType pacmanCapturer()
           
 int[] pacmanVisible(CharacterType character)
          Helper method to see which directions pacman is visible in for the given character.
 boolean paused()
           
 void pauseGame()
           
 java.util.ArrayList<Location2D> pelletLocations()
          Return a list of all available pellets still on the board.
 int pelletsCollected()
           
 java.util.ArrayList<Location2D> powerPelletLocations()
          Return a list of all available power pellets still on the board.
 void restartGame()
          Start the game back up from a paused state.
 void runGame()
          Method used to control the game operations.
 void setupGame()
           
 Location2D simulateMove(Location2D startingLocation, Direction direction)
          Simulate moving from one location to another (but don't actually update the game board)
 void step()
           
 int stepsTaken()
           
 int[] teammatesVisible(CharacterType character)
           
 int totalEatenColors()
           
 int totalPellets()
          Return the total number of pellets that were originally on the board.
 boolean upgraded()
           
 int upgradesCollected()
           
 boolean[] viableDirections(CharacterType character)
          Return a list of the viable directions for a given character.
 int width()
           
 boolean xScrollBetweenIndex(int y)
          Check if the given y index is a scroll between index.
 boolean yScrollBetweenIndex(int x)
          Check if the given x index is a scroll between index.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GAME_OVER_REWARD

public static final int GAME_OVER_REWARD
See Also:
Constant Field Values

GHOST_WORTH

public static final int GHOST_WORTH
See Also:
Constant Field Values

PELLET_WORTH

public static final int PELLET_WORTH
See Also:
Constant Field Values

m_xThroughWayIndecies

public final boolean[] m_xThroughWayIndecies

m_yThroughWayIndecies

public final boolean[] m_yThroughWayIndecies

m_maxSteps

public final int m_maxSteps
Constructor Detail

GameBoard

public GameBoard(boolean hasView,
                 AI pacman_ai,
                 AI team_ai,
                 java.lang.String template)
Method Detail

getCharacters

public PacmanCharacter[] getCharacters()

bonusItemLocations

public java.util.ArrayList<Location2D> bonusItemLocations()
Return a list of all available bonus items still on the board.


bonusValue

public static int bonusValue(BonusType bonus)
Return the value of the given bonus.

Parameters:
bonus - - The bonus to get the value for
Returns:
The value of the bonus.

canMove

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

Parameters:
character - - The character to move
direction - - The direction to move
Returns:
Whether the move is allowed.

characterLocation

public Location2D characterLocation(CharacterType character)
Returns the location of the given character. Location returned is new memory so you can't affect the current game board.

Parameters:
character - - The character whose location we are to retrieve
Returns:
The location of the character

charactersVisible

public int[] charactersVisible(CharacterType character1,
                               CharacterType character2)
Checks whether 2 characters are in sight of each other in any direction. Returns the results as an int array coordinated with the amount of spaces between characters from left, right, up, and down. -1 is the result if a character isn't in view in a given direction. Characters can not see beyond the end of the map, even if there is a throughway there. Throughways are treated as dimensional warps.

Parameters:
character1 - - The first character to measure the location from
character2 - - The second character to measure the location to
Returns:
The results of whether the characters can see each other in the given directions

directionsToCharacter

public boolean[] directionsToCharacter(CharacterType char1,
                                       CharacterType char2)
Gives the directions from char1 to char2. Goes from left, right, up, down.

Parameters:
char1 - - The character to go from
char2 - - The character to go to
Returns:
An array representing the directions to get from char1 to char2

endGame

public void endGame()
End the game.


ghostLocations

public java.util.ArrayList<Location2D> ghostLocations()
Returns a list of all the locations a ghost currently occupies.


goalState

public Location2D goalState()
Returns the goal state of this game board. Might not be applicable if involved in a multiplayer game.


simulateMove

public Location2D simulateMove(Location2D startingLocation,
                               Direction direction)
Simulate moving from one location to another (but don't actually update the game board)

Parameters:
startingLocation - - the location to move from
direction - - the direction to move
Returns:
the resulting location

pacmanVisible

public int[] pacmanVisible(CharacterType character)
Helper method to see which directions pacman is visible in for the given character. Calls upon charactersVisible.

Parameters:
character - - The character to try and find pacman with
Returns:
The directions pacman is visible in for the given character.

paused

public boolean paused()

pauseGame

public void pauseGame()

pelletLocations

public java.util.ArrayList<Location2D> pelletLocations()
Return a list of all available pellets still on the board.


powerPelletLocations

public java.util.ArrayList<Location2D> powerPelletLocations()
Return a list of all available power pellets still on the board.


restartGame

public void restartGame()
Start the game back up from a paused state.


step

public void step()

setupGame

public void setupGame()

cleanupGame

public void cleanupGame()

runGame

public void runGame()
Method used to control the game operations. Ends when ever the game is over.


teammatesVisible

public int[] teammatesVisible(CharacterType character)
Parameters:
character - - The character to find the teammates for
Returns:
The directions the teammates are visible in. Every 4 elements corresponds to a new color, with the colors being ordered lexographic ascending.

totalPellets

public int totalPellets()
Return the total number of pellets that were originally on the board.


viableDirections

public boolean[] viableDirections(CharacterType character)
Return a list of the viable directions for a given character.

Parameters:
character - - The character to look at viable directions for
Returns:
A list of booleans mapping to the directions that can be moved. Ordering is Left, Right, Up, Down.

xScrollBetweenIndex

public boolean xScrollBetweenIndex(int y)
Check if the given y index is a scroll between index.


yScrollBetweenIndex

public boolean yScrollBetweenIndex(int x)
Check if the given x index is a scroll between index.


board

public BoardLocation[][] board()

bonusItemsCollected

public int bonusItemsCollected()

colorsEatenCurrently

public boolean[] colorsEatenCurrently()
Blue, Orange, Pink, Red


gameOver

public boolean gameOver()

height

public int height()

isRunning

public boolean isRunning()

pacmanCapturer

public CharacterType pacmanCapturer()

pelletsCollected

public int pelletsCollected()

stepsTaken

public int stepsTaken()

totalEatenColors

public int totalEatenColors()

upgraded

public boolean upgraded()

upgradesCollected

public int upgradesCollected()

width

public int width()