net.sourceforge.cilib.games.game.predatorprey
Class PredatorPreyGame

java.lang.Object
  extended by net.sourceforge.cilib.games.game.Game<ListGameState>
      extended by net.sourceforge.cilib.games.game.predatorprey.PredatorPreyGame
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
RealTimePredatorPreyGame

public class PredatorPreyGame
extends Game<ListGameState>

Author:
leo This is an implimentation of the predator prey game. The game is played on a 2 dimentional grid with a Predator and a Prey agent. The goal of the Predator is to catch the Prey, and vice versa. For this implimentation the players take turns making movement decisions.
See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sourceforge.cilib.games.game.Game
agentMeasurement, currentPlayer, players
 
Constructor Summary
PredatorPreyGame()
          
PredatorPreyGame(PredatorPreyGame other)
          
PredatorPreyGame(PredatorPreyGame other, ListGameState newState)
          
 
Method Summary
 void display()
          Print the game to the console, is useful during testing.
 boolean gameOver()
          check if the game should terminate
 int getBoardHeight()
           
 int getBoardWidth()
           
 PredatorPreyGame getClone()
          Create a cloned copy of the current object and return it.
 PredatorPreyGame getClone(ListGameState newState)
          Get a clone with the given GameState This method should typically be used by the StateTraversalStrategy and Agent with regards to decision making when playing the game.
 AbstractGameResult getGameResult()
          Get the result of the game (Win/Lose/Draw)
 PredPreyPositionInitializationStrategy getInitializationStrategy()
           
 int getMaxIterations()
           
 void initializeGame()
          perform any game specific initialization
 void movePlayer(int playerID, int x, int y)
          Move a specified player
 void setBoardHeight(int boardHeight)
           
 void setBoardWidth(int boardWidth)
           
 void setInitializationStrategy(PredPreyPositionInitializationStrategy initializationStrategy)
           
 void setMaxIterations(int maxIterations)
           
 
Methods inherited from class net.sourceforge.cilib.games.game.Game
addMeasurement, assignPlayerScore, clearMeasurementData, clearMeasurements, getAgentMeasurements, getCurrentIteration, getCurrentPlayer, getCurrentState, getDecisionState, getDomainForPlayer, getNextPlayerID, getPlayer, getPlayerCount, getPlayerIDList, getPlayerScore, getScoringStrategy, initializeAgent, playGame, playGame, setAgent, setAgent, setCurrentGameState, setCurrentPlayer, setEntityScore, setScoringStrategy, setSeedingStrategy, setStartPlayer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PredatorPreyGame

public PredatorPreyGame()


PredatorPreyGame

public PredatorPreyGame(PredatorPreyGame other)


PredatorPreyGame

public PredatorPreyGame(PredatorPreyGame other,
                        ListGameState newState)

Method Detail

movePlayer

public void movePlayer(int playerID,
                       int x,
                       int y)
Move a specified player

Parameters:
playerID - the player to move
x - the amount to move on the X axes
y - the amount to move on the Y axes

gameOver

public boolean gameOver()
check if the game should terminate

Specified by:
gameOver in class Game<ListGameState>
Returns:
the endgame flag

getClone

public PredatorPreyGame getClone()
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Specified by:
getClone in interface Cloneable
Specified by:
getClone in class Game<ListGameState>
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

getClone

public PredatorPreyGame getClone(ListGameState newState)
Get a clone with the given GameState This method should typically be used by the StateTraversalStrategy and Agent with regards to decision making when playing the game. Since this process includes making alot of copies of the game a seperate, faster, method is neccesary that does not waste time by making unneccesary copies of the game state and player logic.

Specified by:
getClone in class Game<ListGameState>
Parameters:
newState - the new sate to use
Returns:
the copy

getGameResult

public AbstractGameResult getGameResult()
Get the result of the game (Win/Lose/Draw)

Specified by:
getGameResult in class Game<ListGameState>
Returns:
the relevant AbstractGameResult object

initializeGame

public void initializeGame()
perform any game specific initialization

Specified by:
initializeGame in class Game<ListGameState>

display

public void display()
Print the game to the console, is useful during testing.

Specified by:
display in class Game<ListGameState>

getBoardHeight

public int getBoardHeight()

setBoardHeight

public void setBoardHeight(int boardHeight)

getBoardWidth

public int getBoardWidth()

setBoardWidth

public void setBoardWidth(int boardWidth)

getMaxIterations

public int getMaxIterations()

setMaxIterations

public void setMaxIterations(int maxIterations)

setInitializationStrategy

public void setInitializationStrategy(PredPreyPositionInitializationStrategy initializationStrategy)

getInitializationStrategy

public PredPreyPositionInitializationStrategy getInitializationStrategy()


Copyright © 2009 CIRG. All Rights Reserved.