cz.cuni.pogamut.Client
Class AgentBody

java.lang.Object
  extended by cz.cuni.pogamut.Client.AgentBody
All Implemented Interfaces:
Commands, MediatorClientInterface

public class AgentBody
extends java.lang.Object
implements MediatorClientInterface, Commands

AgentBody is wrapping up communication with parser and execution of commands it receives messages, some of them are compressed and AgentBody provides their completion according to recent messages stored in knownObjects

Commands are available using methods of AgentBody like RunTo(navPoint)

AgentBody is also hidding difference between Remote and Local Parser

TODO: to throw exception or not to throw exception


Field Summary
private  java.util.ArrayList<SendCmdListener> commandListeners
          listeners for commands - event fires when the command is sent)
protected  Flag<CommunicationState> communicationState
          This is multiple-state flag, which is signalizing a communication state.
protected  java.lang.String desiredName
          Name which we will send with INIT command to GB.
protected  Flag<java.lang.Boolean> exceptionOccured
          Flag which indicates whether an exception occured in agent body.
protected  java.util.concurrent.CountDownLatch fireLogicLatch
          This is used for awaiting start order from agent.
 AgentInitializer initializer
          agent initializer obviously initializes agent - it contains all parameters which can be set before agent is spawned into the environment, so it fills actualy the GB INIT message
 KnownObjects knownObjects
          knownObjects are used for composition of incoming message from old message and new (which got set only modified properties) knownObjects store old objects
protected  java.lang.String lastSentCommand
          Last sent command - if the string in next command is the same, don't send it works only for MOVE command - it is either not necessary and more good looking to sent it so often so every 5th is sent
protected  Mediator mediator
          Mediator through which we send messages to GB.
private  java.util.ArrayList<RcvMsgListener> messageListeners
          messageListeners is a structure to hold registered listeners AgentBody is therefore able to notify all listening object about incomming message
private  java.util.concurrent.CountDownLatch messageProcessingLatch
           
private  java.lang.Object messageProcessingMutex
          Mutex for everything aroung message processing...
private  boolean messageProcessingShouldStop
           
private  boolean messageProcessingStopped
           
private  java.util.concurrent.BlockingQueue<MessageObject> messageQueue
          Here we will store messages from the server when the message-processing is paused.
protected  int moveCounter
           
protected  java.util.concurrent.CountDownLatch navpointsItemsReceivedLatch
          This latch is raised whenever navpoints and items are received allowing agent's logic to continue.
protected  java.util.logging.Logger platformLog
          bodyLogger is a pointer on global agentLogger and serves as a place to got warnings, info, etc.
private  java.util.HashMap<MessageType,java.util.ArrayList<RcvMsgListener>> typeMessageListeners
          typedMessageListeners is a structure to hold listeners registred to single events (Messages)
 
Constructor Summary
AgentBody(java.util.logging.Logger logger)
          initialize AgentBody - mainly Parser Parser - there are two possibilities: Parser on remote computer and Parser on same computer Remote Parser - Parser is on the same machine as Unreal Tournament - advantages - low network traffic - part of the load is on remote server, more of the system is available for agent logic - disadvantages - it is necessary to run Parser on another machine Local Parser - Parser is on the same machine as Client - advantages - we can run all on one machine - when on one machine, there is no unnecessary traffic - disadvantages - CPU load
 
Method Summary
 void addInventory(java.lang.String inventoryClass)
          add inventory of specified inventoryClass example of class: 'xWeapons.FlakCannon'
 void addRayToAutoTrace(int ID, Triple direction, java.lang.Double length, boolean fastTrace, boolean traceActors)
          add ray to the array of rays emitted from the agent - see GB2004 documentation
 void addRcvMsgListener(RcvMsgListener listener)
          add ReceiveMessageListener for all messages comming through body from Parser
 void addRcvMsgListener(RcvMsgListener listener, java.util.Collection<MessageType> types)
          Takes a collection of types (collection must be filled by MessageTypes) and adds listener to all specified types
 void addRcvMsgListener(RcvMsgListener listener, MessageType[] types)
          Takes an array of types (collection must be filled by MessageTypes) and adds listener to all specified types
 void addSendCmdListener(SendCmdListener listener)
          add command listener to commandListeners
 void addTypedRcvMsgListener(RcvMsgListener listener, MessageType type)
          add listener to specified type of message common use when you want to listen only for instance to dead message, you add listener with proper message type
protected  void bindMediator(Mediator mediator)
          Use this to attach mediator (receiver of messages / senders of commands) to the AgentBody.
protected  void bindName(java.lang.String name)
           
protected  void clearListeners()
          Call at the end of the agent run to remove all listeners inside objects flags.
 void closeClient()
          Close the connection (if any exists).
 void configure(boolean autoTrace, boolean manualSpawn, java.lang.String name, boolean invulnerable, double visionTime, boolean showFocalPoint, boolean drawTraceLines, boolean synchronousOff)
          configure agent: autoTrace - start/stop autoTracing name - name of the agent - could be changed this way to for instance carry some additional info about agent (e.g. role in the team, mood etc.) -> good for visual observation - debugging and presentation of work manualSpawn - start/stop automatic spawn of agent after death - when true, you must spawn him manualy invulnerable - makes agent invulnerable from any threat visionTime - a frequency of synchronous batches - from 0.1 up to 2 - means from 10 per second to 1 per two seconds showFocalPoint - if the FocalPoint of the bot should be visible or not drawTraceLines - if the autoTracing lines should be visible in game or not synchronousOff - if all synchronous messages should be disabled for the agent or not
 void configureAutoTrace(boolean autoTrace)
          configure autoTrace
autoTrace - start/stop autoTracing
 void configureDrawTraceLines(boolean drawTraceLines)
           
 void configureInvulnerable(boolean invulnerable)
          configure invulnerable
invulnerable - makes agent invulnerable from any threat
 void configureManualSpawn(boolean manualSpawn)
          configure manualSpawn
manualSpawn - start/stop automatic spawn of agent after death - when true, you must spawn him manualy
 void configureName(java.lang.String name)
          configure name
name - name of the agent - could be changed this way to for instance carry some additional info about agent (e.g. role in the team, mood etc.) -> good for visual observation - debugging and presentation of work
 void configureVisionTime(double visionTime)
          configure visionTime
visionTime - a frequency of synchronous batches - from 0.1 up to 2 - means from 10 per second to 1 per two seconds
 void contMove(float speed)
           
 void dodge(Triple direction)
          Dodge to the direction.
 void doubleJump()
          just makes agent jump higher than jump, useful as a reflex action when hitting the wall sometimes agent encounter some obstacles, which could be jumped over (like girders etc.)
 void fastTrace(int id, Triple to)
          emit ray to specified location, returns message with a first actor it hits in that direction
 void fastTrace(int id, Triple from, Triple to)
          emit ray to specified location, returns message with a first actor it hits in that direction
 void fireCommandEvent(SendCmdEvent e)
          fire command event
 void fireEvent(RcvMsgEvent e)
          Method to fire event - listener is History at the moment (4.1.2007)
protected  void fixNeighNavs()
          Called after nav points are received from GameBot in state MAP_RECEIVE fix NeighNav.neighbour references (can't be fixed before, because we're receiveing identifiers to non-existing objects)
protected  void generalRunToLocation(Triple location)
          general run to location sets general agent's speed and acceleration for all runTo commands the default settings are: Speed: 700 Acceleration: 450 therefore you can use those or choose your own settings
protected  java.lang.String getBindedName()
           
 Flag<CommunicationState> getCommunicationStateFlag()
          get communication state
 void getPath(Triple location, int ID)
          GetPath - calls Gamebots GETPATH - returns PTH with specified ID to match the query properly takes two parameters location - location the agent want to go to and ID for matching the queries together
 void getPathToLocation(int ID, Triple location)
          sends GETPATH to Gamebots - that will result with PATH sended back in PATH will be list of NavPoints and the path will be identified by the ID specified in this method
 void getPathToNavPoint(int ID, NavPoint navPoint)
          sends GETPATH to Gamebots - that will result with PATH sended back in PATH will be list of NavPoints and the path will be identified by the ID specified in this method
 void changeToBestWeapon()
          changes agent's weapon to the best he has
 void changeWeapon(AddWeapon newWeapon)
          changes to specified weapon - note it doesn't check whether he has it so it is recommended to be used with the AgentInventory - Inventory methods
 void init(java.lang.String name)
          parametrized init - sets name and location where the bot will spawn
 void init(java.lang.String name, int team, boolean manualSpawn, Triple location, Triple rotation)
          parametrized init - sets name, team and location, rotation where the bot will spawn sets as well manualSpawn - identifies whether bot will be spawned manualy or automaticaly after his death
 void init(java.lang.String name, int team, boolean manualSpawn, Triple location, Triple rotation, java.lang.String skin, double accuracy, boolean targetLead)
          most parametrized init
 void init(java.lang.String name, int team, Triple location)
          parametrized init - sets name, team and location where the bot will spawn
 void init(java.lang.String name, Triple location)
          parametrized init - sets name and location where the bot will spawn
 boolean isNameBinded()
           
 void jump()
          just makes agent jump, useful as a reflex action when hitting the wall sometimes agent encounter some obstacles, which could be jumped over (like girders etc.)
 void jumpCustom(int height)
          If we want to jump by an exact force.
protected  void messageReceived(MessageObject msg)
          This is called from sendMessageToClient() when message which should be registered in agent memory is received (== other then communication info message).
 void move(double speed, Triple location1, Triple location2)
          move along 2 locations - should result in more smooth move when following the path - recommended use = when the agent follows the path to the item for instance, do not move him by runTo but this method and suply it with next two locations instead of one in the case of runTo
 void moveAlongNavPoints(double speed, NavPoint nav1, NavPoint nav2)
          move along 2 nav points (locations) - should result in more smooth move when following the path - recommended use = when the agent follows the path to the item for instance, do not move him by runTo but this method and suply it with next two navpoints instead of one in the case of runTo
 void moveContinuous()
          continuously move agent to the direction to which he is faced
 void moveInch()
          Sends INCH command to the bot -> move a little bit forward.
protected  void pauseMessageProcessing()
           
 void pauseTheGame()
          pause the game - all agents, not spectators and human players
 void ping()
          ping to server
 AddItem processAddItem(AddItem newMessage)
          parse name of the item from class, then exploit information from databasis stored in ItemCathegories and use those to create proper item object new message is then returned and fired as an event, so you can register listener for ADD_WEAPON etc.
 AddItem processAddItem(Item newMessage)
          parse name of the item from class, then exploit information from databasis stored in ItemCathegories and use those to create proper item object new message is then returned and fired as an event, so you can register listener for ADD_WEAPON etc.
 Item processItem(Item newMessage)
          parse name of the item from class, then exploit information from databasis stored in ItemCathegories and use those to create proper item object new message is then returned and fired as an event, so you can register listener for WEAPON etc.
 MessageObject processNewMessage(MessageObject newMessage)
          Takes care about withdrawing old object from KnownObjects, update this object using new compressed object returns updated object with all properties
 java.lang.String receiveMessageFromClient()
          From MediatorClientInterface ... has no meaning - we're passing commands to GB directly.
 void removeAllRaysFromAutoTrace()
          removes all rays from auto trace - event default ones
 void removeRayFromAutoTrace(int ID)
          remove ray of specified id from the array of auto trace rays
 void removeRcvMsgListener(RcvMsgListener listener)
          remove ReceiveMessageListener
 void removeSendCmdListener(SendCmdListener listener)
          remove command listener to commandListeners
 void removeTypedRcvMsgListener(RcvMsgListener listener, MessageType type)
          remove ReceiveMessageListener of specified type (note, type is not a part of listener and must be specified separatedly)
 void requestReachcheckLocation(int ID, Triple to, Triple from)
          request whether location to is reachable from location from ID is for identifying the query when Gamebots send information back
 void requestReachcheckTargetFrom(int ID, MessageObject target, Triple from)
          request whether location to is reachable from location from ID is for identifying the query when Gamebots send information back
 void respawn()
          Respawns agent on random PlayerStart navpoint.
 void respawn(Triple location, Triple rotation)
          respawns agent on the specified place with specified rotation
 void restartAutoTraceRays()
          set auto traces to default settings - 4 perpendicular rays
protected  void resumeMessageProcessing()
           
 void runToLocation(Triple location)
          sends RUNTO command with specified location as a parameter
 void runToNavPoint(NavPoint target)
          runToNavPoint accepts NavPoint and sends command that makes bot to run to it
 void runToTarget(Item target)
          similar to run to runToNavPoint
 void runToTarget(MessageObject target)
          similar to run to runToNavPoint, target could be anything with UnrealID
 void runToTarget(Player target)
          similar to run to runToNavPoint
private  void searchNavsForItems()
          search through known navigation points (received at the beginning of the connection) and if the navpoint has itemID not equal to 0, get the item, set its properties and fire event
 void sendCommand(Command content)
          send command is general method used to propagate command string via Parser to Gamebots
 void sendGlobalMessage(java.lang.String text)
          sends message to the game global communication channel
 void sendMessageToClient(MessageObject msg)
          From MediatorClientInterface (Sends message object to the client).
private  void sendMessageToClientUnsync(MessageObject msg)
          Unsync method (messageProcessingMutex) of the sendMessageToClient().
 void sendPrivateMessage(java.lang.String text)
          sends message to the game team communication channel
 void setCrouch(boolean crouch)
          set crouch
 void setLenghtOAutoTrace(int lenght, int ID)
          change lenght of all traces at once
 void setRun()
          makes agent to run when moving
 void setSkin(java.lang.String name)
          set skin of the agent to the skin of specified name
 void setWalk()
          makes agent to walk when moving (he seems more like in cautious mode:))
 void shoot(Player target)
          agent start to shoot at location - target is optional, if it is provided server provides aim correction
 void shoot(Triple location)
          agent start to shoot at location - target is optional, if it is provided server provides aim correction, so this method is without aim correction
 void shootAlternate(Player target)
          agent start to shoot at location using alternate fire - target is optional, if it is provided server provides aim correction
 void shootAlternate(Triple location)
          agent start to shoot at location using alternate fire - target is optional, if it is provided server provides aim correction, so this method is without aim correction
 void startAutoTrace()
          start auto tracing - 3 default traces - left, front, right
 void startRecording(java.lang.String fileName)
          start demo recording, it will be saved to the file with specified fileName the file will be located at the same machine as the server of the game for remote server use FTP (for instance) to get it
 void stop()
          stops the move of agent
 void stopAutoTrace()
          stop auto tracing
 void stopRecording()
          stop recording of current record
 void stopShoot()
          stops agent's fire
 void strafeToLocation(Triple whereToGo, Triple whereToStrafeTo)
          strafe is like RUNTO, but you move towards a destination while facing another point/object whereToGo is for location agent is running to, whereToStrafeTo is for location to face to
 void strafeToLocation(Triple whereToGo, Triple whereToStrafeTo, double speed)
          strafe is like RUNTO, but you move towards a destination while facing another point/object whereToGo is for location agent is running to, whereToStrafeTo is for location to face to
 void strafeToTarget(MessageObject target, Triple whereToGo)
          strafe is like RUNTO, but you move towards a destination while facing another point/object whereToGo is for location agent is running to, target is for target to face to
 void throwWeapon()
          throws away weapon the agent is carrying could be use for an exchange of weapons between agents as well as for trade and other applications
 void trace(int id, Triple to, boolean traceActors)
          emit ray to specified location, returns message with a first actor it hits in that direction TraceActors is true if we want to take players to account
 void trace(int id, Triple from, Triple to, boolean traceActors)
          emit ray to specified location, returns message with a first actor it hits in that direction TraceActors is true if we want to take players to account
 void turn(int pitch, int yaw, int roll)
          turn makes bot to turn in three specified directions pitch - yaw - roll -
 void turnHorizontal(int amount)
          turn agent in horizontal way positive amount -> turn to right negative amount -> turn to left
 void turnToLocation(Triple location)
          makes bot turn to specified location
 void turnToTarget(MessageObject target)
          makes bot to turn towards specified target (e.g. another actor - player)
 void turnVertical(int amount)
          turn agent in vertical way
 void unpauseTheGame()
          pause the game - all agents, not spectators and human players
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mediator

protected Mediator mediator
Mediator through which we send messages to GB.

It must me binded before agent is started! See Agent.startAgentXXX where it's done.


desiredName

protected java.lang.String desiredName
Name which we will send with INIT command to GB. Doesn't reflect the real name in the game as it can be changed using CONF command via GameBots.


initializer

public AgentInitializer initializer
agent initializer obviously initializes agent - it contains all parameters which can be set before agent is spawned into the environment, so it fills actualy the GB INIT message


lastSentCommand

protected java.lang.String lastSentCommand
Last sent command - if the string in next command is the same, don't send it works only for MOVE command - it is either not necessary and more good looking to sent it so often so every 5th is sent


moveCounter

protected int moveCounter

communicationState

protected Flag<CommunicationState> communicationState
This is multiple-state flag, which is signalizing a communication state.


fireLogicLatch

protected java.util.concurrent.CountDownLatch fireLogicLatch
This is used for awaiting start order from agent.

Note that upon connection to GameBots a map is received (navpoints, items) and the user is given chance to preprocess those informations before the bot is spawned within the game of UT (before INIT is sent).


navpointsItemsReceivedLatch

protected java.util.concurrent.CountDownLatch navpointsItemsReceivedLatch
This latch is raised whenever navpoints and items are received allowing agent's logic to continue.


exceptionOccured

protected Flag<java.lang.Boolean> exceptionOccured
Flag which indicates whether an exception occured in agent body.
It may happen: Agent is registering the listener here to catch whether exception occured, if that happens it will stop itself.


knownObjects

public KnownObjects knownObjects
knownObjects are used for composition of incoming message from old message and new (which got set only modified properties) knownObjects store old objects


platformLog

protected java.util.logging.Logger platformLog
bodyLogger is a pointer on global agentLogger and serves as a place to got warnings, info, etc.


messageListeners

private java.util.ArrayList<RcvMsgListener> messageListeners
messageListeners is a structure to hold registered listeners AgentBody is therefore able to notify all listening object about incomming message


typeMessageListeners

private java.util.HashMap<MessageType,java.util.ArrayList<RcvMsgListener>> typeMessageListeners
typedMessageListeners is a structure to hold listeners registred to single events (Messages)


commandListeners

private java.util.ArrayList<SendCmdListener> commandListeners
listeners for commands - event fires when the command is sent)


messageProcessingMutex

private java.lang.Object messageProcessingMutex
Mutex for everything aroung message processing...

Used in resumeMessageProcessing(), sendMessageToClient(MessageObject msg)


messageQueue

private java.util.concurrent.BlockingQueue<MessageObject> messageQueue
Here we will store messages from the server when the message-processing is paused.


messageProcessingShouldStop

private boolean messageProcessingShouldStop

messageProcessingStopped

private boolean messageProcessingStopped

messageProcessingLatch

private java.util.concurrent.CountDownLatch messageProcessingLatch
Constructor Detail

AgentBody

public AgentBody(java.util.logging.Logger logger)
initialize AgentBody - mainly Parser Parser - there are two possibilities: Parser on remote computer and Parser on same computer

Remote Parser - Parser is on the same machine as Unreal Tournament - advantages - low network traffic - part of the load is on remote server, more of the system is available for agent logic - disadvantages - it is necessary to run Parser on another machine

Local Parser - Parser is on the same machine as Client - advantages - we can run all on one machine - when on one machine, there is no unnecessary traffic - disadvantages - CPU load

Parameters:
logger -
Method Detail

bindMediator

protected void bindMediator(Mediator mediator)
Use this to attach mediator (receiver of messages / senders of commands) to the AgentBody.

Called from Agent class.

Parameters:
mediator -

addRcvMsgListener

public void addRcvMsgListener(RcvMsgListener listener)
add ReceiveMessageListener for all messages comming through body from Parser

Parameters:
listener -

addTypedRcvMsgListener

public void addTypedRcvMsgListener(RcvMsgListener listener,
                                   MessageType type)
add listener to specified type of message common use when you want to listen only for instance to dead message, you add listener with proper message type

Parameters:
listener -
type -

addRcvMsgListener

public void addRcvMsgListener(RcvMsgListener listener,
                              java.util.Collection<MessageType> types)
Takes a collection of types (collection must be filled by MessageTypes) and adds listener to all specified types

Parameters:
listener -
types -

addRcvMsgListener

public void addRcvMsgListener(RcvMsgListener listener,
                              MessageType[] types)
Takes an array of types (collection must be filled by MessageTypes) and adds listener to all specified types

Parameters:
listener -
types -

removeRcvMsgListener

public void removeRcvMsgListener(RcvMsgListener listener)
remove ReceiveMessageListener

Parameters:
listener -

removeTypedRcvMsgListener

public void removeTypedRcvMsgListener(RcvMsgListener listener,
                                      MessageType type)
remove ReceiveMessageListener of specified type (note, type is not a part of listener and must be specified separatedly)

Parameters:
listener -
type -

addSendCmdListener

public void addSendCmdListener(SendCmdListener listener)
add command listener to commandListeners

Parameters:
listener -

removeSendCmdListener

public void removeSendCmdListener(SendCmdListener listener)
remove command listener to commandListeners

Parameters:
listener -

fireEvent

public void fireEvent(RcvMsgEvent e)
Method to fire event - listener is History at the moment (4.1.2007)


fireCommandEvent

public void fireCommandEvent(SendCmdEvent e)
fire command event

Parameters:
e - - SendCommandEvent

bindName

protected void bindName(java.lang.String name)

getBindedName

protected java.lang.String getBindedName()

isNameBinded

public boolean isNameBinded()

fixNeighNavs

protected void fixNeighNavs()
Called after nav points are received from GameBot in state MAP_RECEIVE fix NeighNav.neighbour references (can't be fixed before, because we're receiveing identifiers to non-existing objects)


searchNavsForItems

private void searchNavsForItems()
search through known navigation points (received at the beginning of the connection) and if the navpoint has itemID not equal to 0, get the item, set its properties and fire event


receiveMessageFromClient

public java.lang.String receiveMessageFromClient()
From MediatorClientInterface ... has no meaning - we're passing commands to GB directly.

Specified by:
receiveMessageFromClient in interface MediatorClientInterface

getCommunicationStateFlag

public Flag<CommunicationState> getCommunicationStateFlag()
get communication state

Returns:
flag of communication state

pauseMessageProcessing

protected void pauseMessageProcessing()
                               throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

resumeMessageProcessing

protected void resumeMessageProcessing()

sendMessageToClient

public void sendMessageToClient(MessageObject msg)
From MediatorClientInterface (Sends message object to the client).

This method is used to pass the MessageObject from Parser to Agent. Here is the place where we have to process new messages according to CommunicationState.

Specified by:
sendMessageToClient in interface MediatorClientInterface
Parameters:
msg -

sendMessageToClientUnsync

private void sendMessageToClientUnsync(MessageObject msg)
Unsync method (messageProcessingMutex) of the sendMessageToClient().

Parameters:
msg -

messageReceived

protected void messageReceived(MessageObject msg)
This is called from sendMessageToClient() when message which should be registered in agent memory is received (== other then communication info message).

Parameters:
msg - deltaObject from Parser

processNewMessage

public MessageObject processNewMessage(MessageObject newMessage)
Takes care about withdrawing old object from KnownObjects, update this object using new compressed object returns updated object with all properties

Parameters:
newMessage -

processItem

public Item processItem(Item newMessage)
parse name of the item from class, then exploit information from databasis stored in ItemCathegories and use those to create proper item object new message is then returned and fired as an event, so you can register listener for WEAPON etc.

Parameters:
newMessage -
Returns:
object of proper item category with all properties set

processAddItem

public AddItem processAddItem(AddItem newMessage)
parse name of the item from class, then exploit information from databasis stored in ItemCathegories and use those to create proper item object new message is then returned and fired as an event, so you can register listener for ADD_WEAPON etc. (like the inventory does)

Parameters:
newMessage -
Returns:
item of proper type according to the class attribute

processAddItem

public AddItem processAddItem(Item newMessage)
parse name of the item from class, then exploit information from databasis stored in ItemCathegories and use those to create proper item object new message is then returned and fired as an event, so you can register listener for ADD_WEAPON etc. (like the inventory does)

Parameters:
newMessage -
Returns:
item of proper type according to the class attribute

sendCommand

public void sendCommand(Command content)
send command is general method used to propagate command string via Parser to Gamebots

Parameters:
content -

turn

public void turn(int pitch,
                 int yaw,
                 int roll)
turn makes bot to turn in three specified directions pitch - yaw - roll -

Specified by:
turn in interface Commands

turnToLocation

public void turnToLocation(Triple location)
makes bot turn to specified location

Specified by:
turnToLocation in interface Commands

turnToTarget

public void turnToTarget(MessageObject target)
makes bot to turn towards specified target (e.g. another actor - player)

Specified by:
turnToTarget in interface Commands

getPath

public void getPath(Triple location,
                    int ID)
GetPath - calls Gamebots GETPATH - returns PTH with specified ID to match the query properly

takes two parameters location - location the agent want to go to and ID for matching the queries together

Parameters:
location -
ID -

changeToBestWeapon

public void changeToBestWeapon()
changes agent's weapon to the best he has

Specified by:
changeToBestWeapon in interface Commands

changeWeapon

public void changeWeapon(AddWeapon newWeapon)
changes to specified weapon - note it doesn't check whether he has it so it is recommended to be used with the AgentInventory - Inventory methods

Specified by:
changeWeapon in interface Commands

getPathToLocation

public void getPathToLocation(int ID,
                              Triple location)
sends GETPATH to Gamebots - that will result with PATH sended back in PATH will be list of NavPoints and the path will be identified by the ID specified in this method

Specified by:
getPathToLocation in interface Commands
Parameters:
ID -
location -

getPathToNavPoint

public void getPathToNavPoint(int ID,
                              NavPoint navPoint)
sends GETPATH to Gamebots - that will result with PATH sended back in PATH will be list of NavPoints and the path will be identified by the ID specified in this method

Specified by:
getPathToNavPoint in interface Commands
Parameters:
ID -
navPoint -

jump

public void jump()
just makes agent jump, useful as a reflex action when hitting the wall sometimes agent encounter some obstacles, which could be jumped over (like girders etc.)

Specified by:
jump in interface Commands

doubleJump

public void doubleJump()
just makes agent jump higher than jump, useful as a reflex action when hitting the wall sometimes agent encounter some obstacles, which could be jumped over (like girders etc.)

Specified by:
doubleJump in interface Commands

jumpCustom

public void jumpCustom(int height)
If we want to jump by an exact force. Can't be higher then double jump limit (680 units) - if higher then set to this limit.

Parameters:
height -

ping

public void ping()
ping to server

Specified by:
ping in interface Commands

requestReachcheckLocation

public void requestReachcheckLocation(int ID,
                                      Triple to,
                                      Triple from)
request whether location to is reachable from location from ID is for identifying the query when Gamebots send information back

Specified by:
requestReachcheckLocation in interface Commands
Parameters:
ID -
to -
from -

requestReachcheckTargetFrom

public void requestReachcheckTargetFrom(int ID,
                                        MessageObject target,
                                        Triple from)
request whether location to is reachable from location from ID is for identifying the query when Gamebots send information back

Specified by:
requestReachcheckTargetFrom in interface Commands
Parameters:
ID -
target - - Player, NavPoint or something else with UnrealID
from -

turnHorizontal

public void turnHorizontal(int amount)
turn agent in horizontal way positive amount -> turn to right negative amount -> turn to left

Specified by:
turnHorizontal in interface Commands
Parameters:
amount - - degrees

turnVertical

public void turnVertical(int amount)
turn agent in vertical way

Specified by:
turnVertical in interface Commands
Parameters:
amount -

generalRunToLocation

protected void generalRunToLocation(Triple location)
general run to location sets general agent's speed and acceleration for all runTo commands the default settings are: Speed: 700 Acceleration: 450

therefore you can use those or choose your own settings

Parameters:
location -

runToLocation

public void runToLocation(Triple location)
sends RUNTO command with specified location as a parameter

Specified by:
runToLocation in interface Commands

runToNavPoint

public void runToNavPoint(NavPoint target)
runToNavPoint accepts NavPoint and sends command that makes bot to run to it

Specified by:
runToNavPoint in interface Commands

runToTarget

public void runToTarget(MessageObject target)
similar to run to runToNavPoint, target could be anything with UnrealID

Specified by:
runToTarget in interface Commands

runToTarget

public void runToTarget(Item target)
similar to run to runToNavPoint


runToTarget

public void runToTarget(Player target)
similar to run to runToNavPoint


sendGlobalMessage

public void sendGlobalMessage(java.lang.String text)
sends message to the game global communication channel

Specified by:
sendGlobalMessage in interface Commands

sendPrivateMessage

public void sendPrivateMessage(java.lang.String text)
sends message to the game team communication channel

Specified by:
sendPrivateMessage in interface Commands

setRun

public void setRun()
makes agent to run when moving

Specified by:
setRun in interface Commands

setWalk

public void setWalk()
makes agent to walk when moving (he seems more like in cautious mode:))

Specified by:
setWalk in interface Commands

shoot

public void shoot(Player target)
agent start to shoot at location - target is optional, if it is provided server provides aim correction

Specified by:
shoot in interface Commands

shootAlternate

public void shootAlternate(Player target)
agent start to shoot at location using alternate fire - target is optional, if it is provided server provides aim correction

Specified by:
shootAlternate in interface Commands

shoot

public void shoot(Triple location)
agent start to shoot at location - target is optional, if it is provided server provides aim correction, so this method is without aim correction

Specified by:
shoot in interface Commands

shootAlternate

public void shootAlternate(Triple location)
agent start to shoot at location using alternate fire - target is optional, if it is provided server provides aim correction, so this method is without aim correction

Specified by:
shootAlternate in interface Commands

stop

public void stop()
stops the move of agent

Specified by:
stop in interface Commands

stopShoot

public void stopShoot()
stops agent's fire

Specified by:
stopShoot in interface Commands

strafeToLocation

public void strafeToLocation(Triple whereToGo,
                             Triple whereToStrafeTo)
strafe is like RUNTO, but you move towards a destination while facing another point/object whereToGo is for location agent is running to, whereToStrafeTo is for location to face to

Specified by:
strafeToLocation in interface Commands

strafeToLocation

public void strafeToLocation(Triple whereToGo,
                             Triple whereToStrafeTo,
                             double speed)
strafe is like RUNTO, but you move towards a destination while facing another point/object whereToGo is for location agent is running to, whereToStrafeTo is for location to face to


strafeToTarget

public void strafeToTarget(MessageObject target,
                           Triple whereToGo)
strafe is like RUNTO, but you move towards a destination while facing another point/object whereToGo is for location agent is running to, target is for target to face to

Specified by:
strafeToTarget in interface Commands
Parameters:
target - - typically player

moveInch

public void moveInch()
Sends INCH command to the bot -> move a little bit forward. Should be used for debugging purposes of the agent.


contMove

public void contMove(float speed)

init

public void init(java.lang.String name)
parametrized init - sets name and location where the bot will spawn


init

public void init(java.lang.String name,
                 Triple location)
parametrized init - sets name and location where the bot will spawn

Specified by:
init in interface Commands

init

public void init(java.lang.String name,
                 int team,
                 Triple location)
parametrized init - sets name, team and location where the bot will spawn

Specified by:
init in interface Commands

init

public void init(java.lang.String name,
                 int team,
                 boolean manualSpawn,
                 Triple location,
                 Triple rotation)
parametrized init - sets name, team and location, rotation where the bot will spawn sets as well manualSpawn - identifies whether bot will be spawned manualy or automaticaly after his death

Specified by:
init in interface Commands
team - - value 0, 1, 2, 3 - red, blue, gold, green (approximately)
manualSpawn - - whether agent respawn automaticaly or is respawned manually

init

public void init(java.lang.String name,
                 int team,
                 boolean manualSpawn,
                 Triple location,
                 Triple rotation,
                 java.lang.String skin,
                 double accuracy,
                 boolean targetLead)
most parametrized init

Specified by:
init in interface Commands
Parameters:
name -
team - - value 0, 1, 2, 3 - red, blue, gold, green (approximately)
manualSpawn - - whether agent respawn automaticaly or is respawned manually
location -
rotation -
skin - - from the supported skins (see SkinTypes)
accuracy - - range [0-1]
targetLead - - boolean for engine if it should lead the bullets according to target movement, see GB doc

move

public void move(double speed,
                 Triple location1,
                 Triple location2)
move along 2 locations - should result in more smooth move when following the path - recommended use = when the agent follows the path to the item for instance, do not move him by runTo but this method and suply it with next two locations instead of one in the case of runTo

Specified by:
move in interface Commands

moveAlongNavPoints

public void moveAlongNavPoints(double speed,
                               NavPoint nav1,
                               NavPoint nav2)
move along 2 nav points (locations) - should result in more smooth move when following the path - recommended use = when the agent follows the path to the item for instance, do not move him by runTo but this method and suply it with next two navpoints instead of one in the case of runTo

Specified by:
moveAlongNavPoints in interface Commands

respawn

public void respawn(Triple location,
                    Triple rotation)
respawns agent on the specified place with specified rotation

Specified by:
respawn in interface Commands

respawn

public void respawn()
Respawns agent on random PlayerStart navpoint.

Specified by:
respawn in interface Commands

setCrouch

public void setCrouch(boolean crouch)
set crouch

Specified by:
setCrouch in interface Commands

startRecording

public void startRecording(java.lang.String fileName)
start demo recording, it will be saved to the file with specified fileName the file will be located at the same machine as the server of the game for remote server use FTP (for instance) to get it

Specified by:
startRecording in interface Commands

stopRecording

public void stopRecording()
stop recording of current record

Specified by:
stopRecording in interface Commands

throwWeapon

public void throwWeapon()
throws away weapon the agent is carrying could be use for an exchange of weapons between agents as well as for trade and other applications

Specified by:
throwWeapon in interface Commands

trace

public void trace(int id,
                  Triple to,
                  boolean traceActors)
emit ray to specified location, returns message with a first actor it hits in that direction TraceActors is true if we want to take players to account

Specified by:
trace in interface Commands
Parameters:
id - - id of request
to - - to where the ray goes
traceActors - - whether to take actors (players) in account

trace

public void trace(int id,
                  Triple from,
                  Triple to,
                  boolean traceActors)
emit ray to specified location, returns message with a first actor it hits in that direction TraceActors is true if we want to take players to account

Specified by:
trace in interface Commands
Parameters:
id - - id of request
from - - from where the ray goes
to - - to where the ray goes
traceActors - - whether to take actors (players) in account

fastTrace

public void fastTrace(int id,
                      Triple from,
                      Triple to)
emit ray to specified location, returns message with a first actor it hits in that direction

Specified by:
fastTrace in interface Commands
Parameters:
id - - id of request
from - - from where the ray goes
to - - to where the ray goes

fastTrace

public void fastTrace(int id,
                      Triple to)
emit ray to specified location, returns message with a first actor it hits in that direction

Specified by:
fastTrace in interface Commands
Parameters:
id - - id of request
to - - to where the ray goes

closeClient

public void closeClient()
                 throws CantCloseConnectionException
Description copied from interface: MediatorClientInterface
Close the connection (if any exists).

Specified by:
closeClient in interface MediatorClientInterface
Throws:
CantCloseConnectionException

addInventory

public void addInventory(java.lang.String inventoryClass)
add inventory of specified inventoryClass example of class: 'xWeapons.FlakCannon'

Specified by:
addInventory in interface Commands

addRayToAutoTrace

public void addRayToAutoTrace(int ID,
                              Triple direction,
                              java.lang.Double length,
                              boolean fastTrace,
                              boolean traceActors)
add ray to the array of rays emitted from the agent - see GB2004 documentation

Specified by:
addRayToAutoTrace in interface Commands
Parameters:
ID - - id of the auto-trace ray
direction - - direction of the ray
length - - ray length
fastTrace - - fast trace or not (fast is faster and is less demanding for server)
traceActors - - trace actors or not

configure

public void configure(boolean autoTrace,
                      boolean manualSpawn,
                      java.lang.String name,
                      boolean invulnerable,
                      double visionTime,
                      boolean showFocalPoint,
                      boolean drawTraceLines,
                      boolean synchronousOff)
configure agent:

Specified by:
configure in interface Commands

configureDrawTraceLines

public void configureDrawTraceLines(boolean drawTraceLines)

configureAutoTrace

public void configureAutoTrace(boolean autoTrace)
configure autoTrace
autoTrace - start/stop autoTracing

Specified by:
configureAutoTrace in interface Commands

configureInvulnerable

public void configureInvulnerable(boolean invulnerable)
configure invulnerable
invulnerable - makes agent invulnerable from any threat

Specified by:
configureInvulnerable in interface Commands

configureManualSpawn

public void configureManualSpawn(boolean manualSpawn)
configure manualSpawn
manualSpawn - start/stop automatic spawn of agent after death - when true, you must spawn him manualy

Specified by:
configureManualSpawn in interface Commands

configureName

public void configureName(java.lang.String name)
configure name
name - name of the agent - could be changed this way to for instance carry some additional info about agent (e.g. role in the team, mood etc.) -> good for visual observation - debugging and presentation of work

Specified by:
configureName in interface Commands

configureVisionTime

public void configureVisionTime(double visionTime)
configure visionTime
visionTime - a frequency of synchronous batches - from 0.1 up to 2 - means from 10 per second to 1 per two seconds

Specified by:
configureVisionTime in interface Commands

removeRayFromAutoTrace

public void removeRayFromAutoTrace(int ID)
remove ray of specified id from the array of auto trace rays

Specified by:
removeRayFromAutoTrace in interface Commands

moveContinuous

public void moveContinuous()
continuously move agent to the direction to which he is faced

Specified by:
moveContinuous in interface Commands

pauseTheGame

public void pauseTheGame()
pause the game - all agents, not spectators and human players

Specified by:
pauseTheGame in interface Commands

unpauseTheGame

public void unpauseTheGame()
pause the game - all agents, not spectators and human players

Specified by:
unpauseTheGame in interface Commands

removeAllRaysFromAutoTrace

public void removeAllRaysFromAutoTrace()
removes all rays from auto trace - event default ones

Specified by:
removeAllRaysFromAutoTrace in interface Commands

restartAutoTraceRays

public void restartAutoTraceRays()
set auto traces to default settings - 4 perpendicular rays

Specified by:
restartAutoTraceRays in interface Commands

startAutoTrace

public void startAutoTrace()
Description copied from interface: Commands
start auto tracing - 3 default traces - left, front, right

Specified by:
startAutoTrace in interface Commands

stopAutoTrace

public void stopAutoTrace()
Description copied from interface: Commands
stop auto tracing

Specified by:
stopAutoTrace in interface Commands

setLenghtOAutoTrace

public void setLenghtOAutoTrace(int lenght,
                                int ID)
Description copied from interface: Commands
change lenght of all traces at once

Specified by:
setLenghtOAutoTrace in interface Commands

setSkin

public void setSkin(java.lang.String name)
set skin of the agent to the skin of specified name

Specified by:
setSkin in interface Commands

clearListeners

protected void clearListeners()
Call at the end of the agent run to remove all listeners inside objects flags.


dodge

public void dodge(Triple direction)
Dodge to the direction. Axis-x is going in the way the bot is looking. (Axis-z has no meaning).

1,0,0 ... dodge forward

0,1,0 ... dodge to the right

0,-1,0 ... dodge to the left

Specified by:
dodge in interface Commands