cz.cuni.amis.pogamut.unreal.bot.impl
Class NativeUnrealBotAdapter

java.lang.Object
  extended by cz.cuni.amis.pogamut.unreal.bot.impl.NativeUnrealBotAdapter
All Implemented Interfaces:
IAgent, IEmbodiedAgent, IObservingAgent, IComponent, IComponentAware, IControllable, IAgent3D, ILocated, ILocomotive, IRotable, IUnrealBot
Direct Known Subclasses:
NativeUT2004BotAdapter

public abstract class NativeUnrealBotAdapter
extends java.lang.Object
implements IUnrealBot

IUnrealAgent adapter for native players. Not all operations are supported.


Field Summary
protected  IAct act
           
protected  IPlayer player
           
protected  IUnrealServer server
           
protected  IWorldView worldView
           
 
Constructor Summary
NativeUnrealBotAdapter(IPlayer player, IUnrealServer server, IAct act, IWorldView worldView)
           
 
Method Summary
 boolean equals(java.lang.Object other)
           
 IAct getAct()
           
 IAgentId getComponentId()
          Returns agent id - contains also a human-readable name that can be changed
 IComponentBus getEventBus()
          IComponentBus that the instance is working with.
 Folder getIntrospection()
          Returns folder with introspection information.
 Location getLocation()
          Retreives current location of the object.
 IAgentLogger getLogger()
          Returns AgentLogger for the instance allowing creating new log categories or adding new handlers to them.
 java.lang.String getName()
          Returns human-readable agent's name.
 Rotation getRotation()
          Retreives current rotation of the object.
 ImmutableFlag<IAgentState> getState()
          Returns the state of the agent (whether it's running / dead / etc.).
 Velocity getVelocity()
          Retreives current direction and velocity of movement of the object.
 IWorldView getWorldView()
           
 int hashCode()
           
 void kill()
          Stops the agent (unconditionally), closing whatever connection it may have, this method must be non-blocking + interrupting all the communication, logic or whatever threads the agent may have.
 void pause()
          This should pause the the agent.
 void resume()
          This should resume the logic of the agent.
 void start()
          Attempt to launch the agent.
 void startPaused()
          Attempt to launch the agent.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cz.cuni.amis.pogamut.unreal.bot.IUnrealBot
respawn
 
Methods inherited from interface cz.cuni.amis.pogamut.base.agent.IAgent
stop
 

Field Detail

player

protected IPlayer player

server

protected IUnrealServer server

act

protected IAct act

worldView

protected IWorldView worldView
Constructor Detail

NativeUnrealBotAdapter

public NativeUnrealBotAdapter(IPlayer player,
                              IUnrealServer server,
                              IAct act,
                              IWorldView worldView)
Method Detail

getAct

public IAct getAct()
Specified by:
getAct in interface IEmbodiedAgent

getWorldView

public IWorldView getWorldView()
Specified by:
getWorldView in interface IObservingAgent

getComponentId

public IAgentId getComponentId()
Description copied from interface: IAgent
Returns agent id - contains also a human-readable name that can be changed

Specified by:
getComponentId in interface IAgent
Specified by:
getComponentId in interface IComponent
Returns:

getName

public java.lang.String getName()
Description copied from interface: IAgent
Returns human-readable agent's name.

Do not use as unique id of the agent:

1) the name might change during the life of agent

2) we do not ensure it's unique

Use getComponentId().getToken() instead!

Use getComponentId().getName().setFlag() to change the name of the agent.

Specified by:
getName in interface IAgent
Returns:

getLogger

public IAgentLogger getLogger()
Description copied from interface: IAgent
Returns AgentLogger for the instance allowing creating new log categories or adding new handlers to them.

Specified by:
getLogger in interface IAgent
Returns:

getEventBus

public IComponentBus getEventBus()
Description copied from interface: IComponentAware
IComponentBus that the instance is working with.

Note that by design-choice - the IComponentBus is a singleton inside AgentScoped, therefore you don't have to necessarily obtain the instance through the component, it suffice to obtain it using injection into your object.

Specified by:
getEventBus in interface IComponentAware
Returns:

getState

public ImmutableFlag<IAgentState> getState()
Description copied from interface: IAgent
Returns the state of the agent (whether it's running / dead / etc.).

Note that the type AgentState wraps two things:

Specified by:
getState in interface IAgent
Returns:

start

public void start()
           throws AgentException
Description copied from interface: IAgent
Attempt to launch the agent. If it does not throw an exception, agent has been successfully started, also the state of the agent state is changed into Running state.

This method is not suitable for simultaneous start of multiple agents that should start working together in the environment. (I.e., during tournaments of agents when you need to synchronize their start in the environment.) In such cases use IAgent.startPaused() and then multiple threads+barrier to execute IAgent.resume() of all agents at once.

Specified by:
start in interface IAgent
Specified by:
start in interface IControllable
Throws:
AgentException

startPaused

public void startPaused()
                 throws AgentException
Description copied from interface: IAgent
Attempt to launch the agent. If it does not throw an exception, agent has been successfully started (paused).

In contrast with IAgent.start() this method will initialize the agent inside the environment but pauses it after the start (i.e., its reasoning should not run, the action should not do any decisions).

To fully start the agent, you need to IAgent.resume() it.

It is designed to provide safe synchronization of multiple agent simulations when you need to start the reasoning of agents synchronously.

Specified by:
startPaused in interface IAgent
Throws:
AgentException

pause

public void pause()
           throws AgentException
Description copied from interface: IAgent
This should pause the the agent. If it does not throw an exception, agent has been successfully started, also the state of the agent state is changed into Paused state.

If your agent can't be paused, throw OperationNotSupportedException.

Specified by:
pause in interface IAgent
Throws:
AgentException

resume

public void resume()
            throws AgentException
Description copied from interface: IAgent
This should resume the logic of the agent. If it does not throw an exception, agent has been successfully resumed, also the state of the agent state is changed into Running state.

If your agent can't be paused therefore can't be resumed, throw OperationNotSupportedException.

Specified by:
resume in interface IAgent
Throws:
AgentException

kill

public void kill()
Description copied from interface: IAgent
Stops the agent (unconditionally), closing whatever connection it may have, this method must be non-blocking + interrupting all the communication, logic or whatever threads the agent may have.

After calling kill() method, the only method that may be called is getState() to examine state of the agent.

This also equals to "exception happened outside the agent" and "IFatalErrorEvent should be propagated inside the agent"

Specified by:
kill in interface IAgent
Specified by:
kill in interface IControllable

getIntrospection

public Folder getIntrospection()
Description copied from interface: IAgent
Returns folder with introspection information. Useful for showing agent model variables and parameters.

Specified by:
getIntrospection in interface IAgent
Returns:
Folder with introspection info

getLocation

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

Specified by:
getLocation in interface ILocated
Returns:
Current location of the object, represented as a point within the world's coordinates.

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:
Current direction in which the object is moving and absolute velocity of the object within the world. The direction is represented as a vector within the world's coordinates. The size of velocity is represented by length of that vector.

getRotation

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

Specified by:
getRotation in interface IRotable
Returns:
Current rotation of the object, represented as yaw, roll and pitch.

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object