ctf.environment
Class Game
java.lang.Object
|
+--ctf.environment.Game
- class Game
- extends Object
CTF Game between two teams of agents.
- Author:
- Jason Rohrer
Method Summary |
(package private) void |
cancel()
Cancels the current round of play. |
(package private) void |
draw(Graphics inGraphics,
int inStartX,
int inStartY,
int inWide,
int inHigh)
Draws the current game state in a graphics context. |
Exception |
getTeamException()
|
int |
playRound(int inDrawThreshold)
Plays a one-round game. |
int |
playRound(int inDrawThreshold,
boolean inStartPaused)
Plays a one-round game. |
(package private) void |
setColorMap(GameColorMap inColorMap)
Set game-wide color map. |
(package private) void |
setDelay(int inDelayInMS)
Set delay between each step of play. |
(package private) void |
setPause(boolean inPaused)
Sets whether game is paused or not. |
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
lastTeamToGoFirst
int lastTeamToGoFirst
Game
Game(Class[] inTeamAgents,
GameColorMap inColorMap,
BoardSet inBoardSet,
ObstacleSet inObstacleSet,
int inNumAgentsPerTeam,
StateChangeListener inStateChangeListener)
throws IllegalArgumentException
- Constructs a
Game
.
- Parameters:
inTeamAgents
- array of classes to instantiate for
building agent set for each team. Classes should all extend
Agent
.inColorMap
- color settings for various components.inBoardSet
- board settings preset.inObstacleSet
- obstacle location preset.inNumAgentsPerTeam
- number of agents on a team.inStateChangeListener
- listener that will get fire
event callbacks when board-wide state changes during play.- Throws:
- IllegalArgumentException - if number of agents per
team is not > 0 or if instantiating any of
Agent
classes
fails.
setPause
void setPause(boolean inPaused)
- Sets whether game is paused or not.
cancel
void cancel()
- Cancels the current round of play.
setDelay
void setDelay(int inDelayInMS)
- Set delay between each step of play.
- Parameters:
inDelayInMS
- delay in milliseconds.
getTeamException
public Exception getTeamException()
playRound
public int playRound(int inDrawThreshold)
- Plays a one-round game. One round constitutes play
up to the first flag capture (or up to draw threshold).
(Note that state is reset to init. before start of each game).
- Parameters:
inDrawThreshold
- the number of state transitions
to make with no flag capture before declaring a draw.- Returns:
- index of the winning team. (-1 if draw or cancel,
2 if both teams score simultaneously, 3 if team 0 won because
1 threw an exception, and 4 if team 1 won because 0 threw
an exception).
playRound
public int playRound(int inDrawThreshold,
boolean inStartPaused)
- Plays a one-round game. One round constitutes play
up to the first flag capture (or up to draw threshold).
(Note that state is reset to init. before start of each game).
- Parameters:
inDrawThreshold
- the number of state transitions
to make with no flag capture before declaring a draw.inStartPaused
- set to true for round to start in paused state.- Returns:
- index of the winning team. (-1 if draw or cancel,
2 if both teams score simultaneously, 3 if team 0 won because
1 threw an exception, and 4 if team 1 won because 0 threw
an exception).
setColorMap
void setColorMap(GameColorMap inColorMap)
- Set game-wide color map.
- Parameters:
inColorMap
- new color map for game objects.
draw
void draw(Graphics inGraphics,
int inStartX,
int inStartY,
int inWide,
int inHigh)
- Draws the current game state in a graphics context. Not double-buffered.
- Parameters:
inGraphics
- the context in which to draw the current game state.inStartX
- the starting x location in the context where the
game should be drawn.inStartY
- the starting y location in the context where the
game should be drawn.inWide
- the width of the game image in the context.inHigh
- the width of the game image in the context.