cz.cuni.amis.pogamut.ut2004.bot.impl
Class UT2004Bot<WORLD_VIEW extends IVisionWorldView,ACT extends IAct,CONTROLLER extends IUT2004BotController>

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.agent.impl.AbstractAgent
      extended by cz.cuni.amis.pogamut.base.agent.impl.AbstractObservingAgent<WORLD_VIEW>
          extended by cz.cuni.amis.pogamut.base.agent.impl.AbstractGhostAgent<WORLD_VIEW,ACT>
              extended by cz.cuni.amis.pogamut.base.agent.impl.AbstractEmbodiedAgent<WORLD_VIEW,ACT>
                  extended by cz.cuni.amis.pogamut.base3d.agent.AbstractAgent3D<WORLD_VIEW,ACT>
                      extended by cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot<WORLD_VIEW,ACT,CONTROLLER>
All Implemented Interfaces:
IAgent, IEmbodiedAgent, IGhostAgent, IObservingAgent, IComponent, IComponentAware, IControllable, IAgent3D, ILocated, ILocomotive, IRotable, IUnrealBot, IUT2004Bot

public class UT2004Bot<WORLD_VIEW extends IVisionWorldView,ACT extends IAct,CONTROLLER extends IUT2004BotController>
extends AbstractAgent3D<WORLD_VIEW,ACT>
implements IUT2004Bot

Ancestor of all UT2004 bots.

TODO: [comment me!]


Nested Class Summary
 
Nested classes/interfaces inherited from interface cz.cuni.amis.pogamut.ut2004.bot.IUT2004Bot
IUT2004Bot.BoolBotParam
 
Field Summary
protected  java.lang.Thread botDisconnectorThread
          Disconnector thread serves as a last resort for shutting down the bot inside GB2004 in case of JVM failures.
 
Fields inherited from class cz.cuni.amis.pogamut.base.agent.impl.AbstractAgent
events, INTROSPECTION_ROOT_NAME, log
 
Constructor Summary
UT2004Bot(UT2004AgentParameters parameters, IComponentBus eventBus, IAgentLogger logger, IWorldView worldView, IAct act, IUT2004BotController init)
           
 
Method Summary
protected  void addBotDisconnector()
          Initializes & registers botDisconnectorThread as a Runtime.addShutdownHook(Thread).
protected  AgentJMXComponents createAgentJMX()
           
protected  Folder createIntrospection()
          Create introspection root object.
 boolean getBoolConfigure(IUT2004Bot.BoolBotParam param)
          Get configuration parameter value.
 CONTROLLER getController()
          Returns the bot controller passed inside UT2004Bot#AbstractUT2004Bot(IAgentId, IComponentBus, IAgentLogger, IVisionWorldView, IAct, IUT2004BotInitialization).
 Location getLocation()
          Retreives current location of the object.
 UT2004AgentParameters getParams()
          Returns parameters that were passed into the agent during the construction.
 Rotation getRotation()
          Retreives current rotation of the object.
 Velocity getVelocity()
          Retreives current direction and velocity of movement of the object.
 WORLD_VIEW getWorldView()
          Returns abstraction for the agent's world.
protected  void initCommandRequested()
          This method is called whenever handshake with GameBots2004 is over - the GameBots2004 is awaiting the bot to reply with Ready command to begin the handshake.
protected  void killAgent()
          Called during kill() method - override to provide custom ruthless stopping (killing) behavior of the agent.
protected  void preKillAgent()
          Called before any ComponentBusEvents.fatalError(String) event is broadcast.
protected  void preStopAgent()
          Called before any ComponentBusEvents.stopping() event is broadcast.
protected  void readyCommandRequested()
          This method is called whenever HelloBot message is parsed - the GameBots2004 is awaiting the bot to reply with Ready command to begin the handshake.
protected  void removeBotDisconnector()
          Removes botDisconnectorThread as a Runtime.removeShutdownHook(Thread) and nullify the field.
 void respawn()
          Restarts the bot in the game.
 void setBoolConfigure(IUT2004Bot.BoolBotParam param, boolean value)
          Configures bot property.
protected  void startAgent()
          Called during start() method - override to provide custom starting behavior of the agent.
protected  void startPausedAgent()
          Called during startPaused() method - override to provide custom starting-paused behavior of the agent.
protected  void stopAgent()
          Called during stop() method - override to provide custom stopping behavior of the agent.
protected  void tryDisconnect()
          Sends DisconnectBot commands to GB2004, eats up all exceptions.
 
Methods inherited from class cz.cuni.amis.pogamut.base.agent.impl.AbstractEmbodiedAgent
getAct
 
Methods inherited from class cz.cuni.amis.pogamut.base.agent.impl.AbstractAgent
addDependency, addDependency, addDependency, addJMXComponents, awaitState, awaitState, componentFatalError, componentStarted, componentStarted, componentStopped, componentStopping, equals, getComponentId, getEventBus, getIntrospection, getJMX, getLog, getLogger, getName, getState, hashCode, inState, kill, notInState, pause, pauseAgent, resetAgent, resetEvent, resume, resumeAgent, setState, start, startPaused, stop, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface cz.cuni.amis.pogamut.base.agent.IEmbodiedAgent
getAct
 
Methods inherited from interface cz.cuni.amis.pogamut.base.agent.IAgent
getComponentId, getIntrospection, getLogger, getName, getState, kill, pause, resume, start, startPaused, stop
 
Methods inherited from interface cz.cuni.amis.pogamut.base.component.IComponentAware
getEventBus
 

Field Detail

botDisconnectorThread

protected java.lang.Thread botDisconnectorThread
Disconnector thread serves as a last resort for shutting down the bot inside GB2004 in case of JVM failures.

Constructor Detail

UT2004Bot

@Inject
public UT2004Bot(UT2004AgentParameters parameters,
                        IComponentBus eventBus,
                        IAgentLogger logger,
                        IWorldView worldView,
                        IAct act,
                        IUT2004BotController init)
Parameters:
agentId -
eventBus -
logger -
worldView - due to Guice nature, this can't be templated with WORLD_VIEW - Guice can't use it as a key for the injection
act - due to Guice nature, this can't be templated with ACT - Guice can't use it as a key for the injection
init - due to Guice nature, this can't be templated with CONTROLLER - Guice can't use it as a key for the injection
Method Detail

getController

public CONTROLLER getController()
Returns the bot controller passed inside UT2004Bot#AbstractUT2004Bot(IAgentId, IComponentBus, IAgentLogger, IVisionWorldView, IAct, IUT2004BotInitialization).

Returns:

getParams

public UT2004AgentParameters getParams()
Returns parameters that were passed into the agent during the construction.

This is a great place to parametrize your agent. Note that you may pass arbitrary subclass of UT2004AgentParameters to the constructor/factory/runner and pick them up here.

Returns:
parameters

startAgent

protected void startAgent()
Description copied from class: AbstractAgent
Called during start() method - override to provide custom starting behavior of the agent.

WARNING: DO NOT CALL ON YOUR OWN, ALWAYS USE PUBLIC INTERFACE (start()), but that should not be needed!

If you override this method don't forget to call super.startAgent() as the first method.

Overrides:
startAgent in class AbstractAgent

startPausedAgent

protected void startPausedAgent()
Description copied from class: AbstractAgent
Called during startPaused() method - override to provide custom starting-paused behavior of the agent.

WARNING: DO NOT CALL ON YOUR OWN, ALWAYS USE PUBLIC INTERFACE (startPaused()), but that should not be needed!

If you override this method don't forget to call super.startPausedAgent() as the first method.

Overrides:
startPausedAgent in class AbstractAgent

preStopAgent

protected void preStopAgent()
Description copied from class: AbstractAgent
Called before any ComponentBusEvents.stopping() event is broadcast. Hook that allows you to implement just-before-death stuff before any of agent component actually dies.

Overrides:
preStopAgent in class AbstractAgent

stopAgent

protected void stopAgent()
Description copied from class: AbstractAgent
Called during stop() method - override to provide custom stopping behavior of the agent.

WARNING: DO NOT CALL ON YOUR OWN, ALWAYS USE PUBLIC INTERFACE (stop()).

If you override this method don't forget to call super.stopAgent() as the first method.

Overrides:
stopAgent in class AbstractAgent

preKillAgent

protected void preKillAgent()
Description copied from class: AbstractAgent
Called before any ComponentBusEvents.fatalError(String) event is broadcast. Hook that allows you to implement just-before-death stuff before any of agent component actually dies.

Overrides:
preKillAgent in class AbstractAgent

killAgent

protected void killAgent()
Description copied from class: AbstractAgent
Called during kill() method - override to provide custom ruthless stopping (killing) behavior of the agent.

WARNING: DO NOT CALL ON YOUR OWN, ALWAYS USE PUBLIC INTERFACE (kill()).

If you override this method don't forget to call super.killAgent() as the first method.

Overrides:
killAgent in class AbstractAgent

tryDisconnect

protected void tryDisconnect()
Sends DisconnectBot commands to GB2004, eats up all exceptions.


addBotDisconnector

protected void addBotDisconnector()
Initializes & registers botDisconnectorThread as a Runtime.addShutdownHook(Thread).


removeBotDisconnector

protected void removeBotDisconnector()
Removes botDisconnectorThread as a Runtime.removeShutdownHook(Thread) and nullify the field.


readyCommandRequested

protected void readyCommandRequested()
This method is called whenever HelloBot message is parsed - the GameBots2004 is awaiting the bot to reply with Ready command to begin the handshake.


initCommandRequested

protected void initCommandRequested()
This method is called whenever handshake with GameBots2004 is over - the GameBots2004 is awaiting the bot to reply with Ready command to begin the handshake. It calls setUpInit() method to obtains Initialize message that is then sent to GameBots2004.

Left as protected if you need to override it - but you probably wouldn't.


getLocation

public Location getLocation()
Description copied from interface: ILocated
Retreives current location of the object.

Specified by:
getLocation in interface ILocated
Returns:
Location of the agent. Null if not set yet.

getRotation

public Rotation getRotation()
Description copied from interface: IRotable
Retreives current rotation of the object.

Specified by:
getRotation in interface IRotable
Returns:
Rotation of the agent. Null if not set yet.

getVelocity

public Velocity getVelocity()
Description copied from interface: ILocomotive
Retreives current direction and velocity of movement of the object.

Specified by:
getVelocity in interface ILocomotive
Returns:
Velocity of the agent. Null if not set yet.

respawn

public void respawn()
             throws PogamutException
Description copied from interface: IUnrealBot
Restarts the bot in the game. Issues RESPAWN command.

Specified by:
respawn in interface IUnrealBot
Throws:
PogamutException

createAgentJMX

protected AgentJMXComponents createAgentJMX()
Overrides:
createAgentJMX in class AbstractAgent3D<WORLD_VIEW extends IVisionWorldView,ACT extends IAct>

setBoolConfigure

public void setBoolConfigure(IUT2004Bot.BoolBotParam param,
                             boolean value)
Description copied from interface: IUT2004Bot
Configures bot property.

Specified by:
setBoolConfigure in interface IUT2004Bot

getBoolConfigure

public boolean getBoolConfigure(IUT2004Bot.BoolBotParam param)
Description copied from interface: IUT2004Bot
Get configuration parameter value.

Specified by:
getBoolConfigure in interface IUT2004Bot
Returns:

createIntrospection

protected Folder createIntrospection()
Description copied from class: AbstractAgent
Create introspection root object.

Overrides:
createIntrospection in class AbstractAgent
Returns:

getWorldView

public WORLD_VIEW getWorldView()
Description copied from class: AbstractObservingAgent
Returns abstraction for the agent's world. That can be anything the range is broad ... from chess board to the UT2004 3D environment.

The implementation may be different as the user needs.

Specified by:
getWorldView in interface IObservingAgent
Overrides:
getWorldView in class AbstractObservingAgent<WORLD_VIEW extends IVisionWorldView>