|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.vizzini.game.AbstractEngine
public abstract class AbstractEngine
Provides base functionality for engines in the game framework. An engine instance encapsulates the game mechanics, meaning how the agents interact. Examples of engines include a synchronous engine, where agents take turns, a simultaneous engine, where each agent's actions occur at the same time, or an asynchronous engine, where the agent's actions occur at any time and any amount.
Constructor Summary | |
---|---|
AbstractEngine()
|
Method Summary | |
---|---|
void |
addGameListener(IGameListener listener)
Add the given listener. |
void |
configure(Properties properties)
Configure this engine. |
protected Thread |
createGameThread(IEngine engine)
Create the internal game thread. |
protected void |
cycleSleep(long start)
Sleep for long enough to bring the cycle time up to the minimum. |
protected ActionCollection |
getActionList()
Return the action list. |
IAgent |
getCurrentAgent()
Return the current agent. |
IEnvironment |
getEnvironment()
Return the environment. |
protected Thread |
getGameThread()
Return the game thread. |
long |
getMinCycleTime()
Return the minimum cycle time. |
boolean |
isFiringGameChanges()
Return true if this is set to fire game change events. |
boolean |
isGameOver()
Return true if the game is over. |
boolean |
isPaused()
Return true if this is paused. |
void |
pause()
Pause the engine. |
void |
removeGameListener(IGameListener listener)
Remove the given listener. |
void |
reset()
Reset to the initial state. |
void |
resume()
Resume the engine from a pause. |
protected void |
setCurrentAgent(IAgent agent)
Set the current agent. |
void |
setEnvironment(IEnvironment environment)
Set the environment to the given value. |
void |
setFiringGameChanges(boolean fire)
Set the flag which indicates whether to fire game change events. |
void |
setGameOver(boolean isGameOver,
IAgent winner)
Set the game over flag to the given value. |
void |
setMinCycleTime(long minCycleTime)
Set the minimum cycle time. |
void |
start()
Start the engine by starting the game loop thread. |
void |
step()
Step the engine. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.vizzini.game.IEngine |
---|
run |
Constructor Detail |
---|
public AbstractEngine()
Method Detail |
---|
public void addGameListener(IGameListener listener)
addGameListener
in interface IEngine
public void configure(Properties properties) throws InstantiationException, IllegalAccessException
configure
in interface IEngine
properties
- Source of configuration information.
InstantiationException
IllegalAccessException
public IAgent getCurrentAgent()
getCurrentAgent
in interface IEngine
public IEnvironment getEnvironment()
getEnvironment
in interface IEngine
public long getMinCycleTime()
getMinCycleTime
in interface IEngine
public boolean isFiringGameChanges()
isFiringGameChanges
in interface IEngine
public boolean isGameOver()
isGameOver
in interface IEngine
public boolean isPaused()
isPaused
in interface IEngine
public void pause()
pause
in interface IEngine
public void removeGameListener(IGameListener listener)
removeGameListener
in interface IEngine
public void reset()
reset
in interface IEngine
public void resume()
resume
in interface IEngine
public void setEnvironment(IEnvironment environment)
setEnvironment
in interface IEngine
environment
- The new environment.public void setFiringGameChanges(boolean fire)
setFiringGameChanges
in interface IEngine
public void setGameOver(boolean isGameOver, IAgent winner)
setGameOver
in interface IEngine
isGameOver
- The new value.public void setMinCycleTime(long minCycleTime)
setMinCycleTime
in interface IEngine
public void start()
start
in interface IEngine
public void step()
step
in interface IEngine
protected Thread createGameThread(IEngine engine)
run
method.
engine
- The owning engine.protected void cycleSleep(long start)
protected ActionCollection getActionList()
protected Thread getGameThread()
protected void setCurrentAgent(IAgent agent)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2007 Vizzini.org. All Rights Reserved. | 2007.12.25.03.00.02 |