nl.tudelft.goal.ut2004.agent
Class UT2004BotBehavior

Package class diagram package UT2004BotBehavior
java.lang.Object
  extended by cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotController<BOT>
      extended by cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotLogicController<BOT>
          extended by cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotModuleController<UT2004Bot>
              extended by nl.tudelft.goal.ut2004.agent.UT2004BotBehavior
All Implemented Interfaces:
cz.cuni.amis.pogamut.base.agent.module.IAgentLogic<cz.cuni.amis.pogamut.base.agent.module.LogicModule>, IUT2004BotController<UT2004Bot>, IUT2004BotLogicController<UT2004Bot,cz.cuni.amis.pogamut.base.agent.module.LogicModule>, eis.eis2java.util.AllPerceptsProvider

public class UT2004BotBehavior
extends UT2004BotModuleController<UT2004Bot>
implements eis.eis2java.util.AllPerceptsProvider


Field Summary
protected  long actionCount
           
protected  nl.tudelft.pogamut.ut2004.agent.module.shooting.util.OrderedFocusProvider focus
           
protected  long logicIteration
           
protected  nl.tudelft.pogamut.ut2004.agent.module.shooting.util.FocusProvider lookFocus
           
protected  List<ContextSelector> lookSelector
           
protected  nl.tudelft.goal.unreal.messages.BotParameters parameters
          Settings for the bot.
protected  eis.eis2java.util.AllPerceptsModule percepts
           
protected  nl.tudelft.pogamut.ut2004.agent.module.sensor.Projectiles projectiles
           
protected  SharedFloydWarshallMap sfwMap
          Path-planner (IPathPlanner using NavPoints), you may use it to find paths inside the environment wihtout waiting for round-trip of GetPath command and PathLists response from UT2004.
protected  List<ContextSelector> targetSelector
           
protected  nl.tudelft.pogamut.ut2004.agent.module.shooting.WeaponryShooting weaponShooting
           
 
Fields inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotModuleController
act, aStar, body, combo, config, ctf, descriptors, fwMap, game, getBackToNavGraph, info, items, listenerRegistrator, move, navBuilder, navigation, navPoints, pathExecutor, pathPlanner, players, random, raycasting, runStraight, senses, shoot, stats, visibility, weaponPrefs, weaponry, world
 
Fields inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotLogicController
logicModule
 
Fields inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotController
bot, log, USER_LOG_CATEGORY_ID
 
Constructor Summary
UT2004BotBehavior()
           
 
Method Summary
 Percept actionCount()
          Deprecated. 
 void addAction(Action action)
          Queues up the action to be executed on the first evaluation of the logic cycle.
 Collection<Percept> base()
           Information about the location of the base.
 void beforeFirstLogic()
          Called before the evaluation of the first logic.
 Collection<Percept> bot()
           Percept provided when another bot becomes visible to this bot.
 void combo(Combo combo)
           When called the bot will use the given combo.
 Percept currentWeapon()
           Information about weapon the bot is currently holding.
 void dropWeapon()
           Drops the weapon the bot is currently holding.
 void finishControllerInitialization()
          Finish controller initialisation.
 Collection<Percept> flag()
           Description: Percept provided when the flag is visible.
 Collection<Percept> flagState()
           Description: Percept that provides information about the current state of the flag.
 List<Percept> fragged()
           This percept is provided when one bot is violently fragmented by another.
 Percept game()
           Information about the type of game being played, the map and the score required for winning the game.
 Map<Method,Object> getAllPercepts()
          Returns a previously prepared batch of percepts.
 Initialize getInitializeCommand()
          Prepares the initialization message for Gamebots using the BotParameters provided to the UT2004BotRunner.
 void initializeController(UT2004Bot bot)
           
protected  void initializeModules(UT2004Bot bot)
          Initialize projectiles and weaponshooting modules.
protected  void initializePathFinding(UT2004Bot bot)
          Initializes path-finding modules: UT2004BotModuleControllerNew#pathPlanner, UT2004BotModuleController.fwMap and UT2004BotModuleControllerNew#pathExecutor.
protected  void initializeWeaponShootings()
          Adds handlers to deal with different weapons.
 Collection<Percept> item()
           Description: Provides information items the bot sees in the world.
 void logic()
          The bot will evaluate its the logic every 100ms.
 Percept logicIteration()
          Deprecated. 
 void look(SelectorList targets)
           Tells the bot how to prioritize what it looks at.
 void msgBotKilled(BotKilled msg)
          Event listener for deaths of this bot.
 void msgPlayerKilled(PlayerKilled msg)
          Event listener for deaths of other bots & players.
 void navigate(UnrealIdOrLocation destination)
          When called the bot will make a best effort attempt to navigate to requested destination.
 Percept navigation()
           Information about the state of the navigation.
 Collection<Percept> navPoint()
           Information about point in the map.
 Percept orientation()
           Information about the bot's position, rotation and velocity.
 Percept path(UnrealIdOrLocation from, UnrealIdOrLocation to)
           The bot computes a path from a to b.
 Collection<Percept> pickup()
           Information indicating at which navpoint weapons, ammo, and health can be found.
 void prefer(WeaponPrefList weaponList)
           Tells the bot which weapon it should prefer.
 void respawn()
          When called the bot will respawn in at a random spawn point of its team.
 Percept score()
           Information about the number of kills, deaths, and suicides this bot accumulated.
 Percept self()
           Information about the bot's identity and team.
 void shoot(SelectorList targets)
           Tells the bot how to prioritize who it shoots.
 void skip()
           Does nothing.
 Percept status()
           Information about the bot's current physical state.
 void stop()
          When called the bot will stop.
 void stopShooting()
          *
 Percept teamScore()
           Percept that provides information about the current state of the game.
 Collection<Percept> visibleNavPoint()
          TODO: Doc this
 Collection<Percept> weapon()
           Information about weapons the bot has in its inventory.
 
Methods inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotModuleController
getAStar, getBody, getCombo, getConfig, getDescriptors, getFwMap, getGame, getInfo, getItems, getMove, getNavBuilder, getNavigation, getPathExecutor, getPathPlanner, getPlayers, getRandom, getRaycasting, getSenses, getShoot, getStats, getVisibility, getWeaponPrefs, getWeaponry, getWorld, initializeListeners
 
Methods inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotLogicController
getLogicInitializeTime, getLogicShutdownTime, initializeLogic, logicInitialize, logicShutdown
 
Methods inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotController
botFirstSpawn, botInitialized, botKilled, botShutdown, getAct, getBot, getLog, getName, getPassword, getWorldView, prepareBot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController
botFirstSpawn, botInitialized, botKilled, botShutdown, getAct, getBot, getLog, getPassword, getWorldView, prepareBot
 

Field Detail

targetSelector

protected List<ContextSelector> targetSelector

lookSelector

protected List<ContextSelector> lookSelector

projectiles

protected nl.tudelft.pogamut.ut2004.agent.module.sensor.Projectiles projectiles

weaponShooting

protected nl.tudelft.pogamut.ut2004.agent.module.shooting.WeaponryShooting weaponShooting

lookFocus

protected nl.tudelft.pogamut.ut2004.agent.module.shooting.util.FocusProvider lookFocus

focus

protected nl.tudelft.pogamut.ut2004.agent.module.shooting.util.OrderedFocusProvider focus

percepts

protected eis.eis2java.util.AllPerceptsModule percepts

parameters

protected nl.tudelft.goal.unreal.messages.BotParameters parameters
Settings for the bot.


logicIteration

protected long logicIteration

actionCount

protected long actionCount

sfwMap

protected SharedFloydWarshallMap sfwMap
Path-planner (IPathPlanner using NavPoints), you may use it to find paths inside the environment wihtout waiting for round-trip of GetPath command and PathLists response from UT2004. It is much faster than UT2004BotModuleController.pathPlanner but you need to pass NavPoint instances to planner instead of ILocated ... to find the nearest NavPoint instance, DistanceUtils is a handy, check especially DistanceUtils.getNearest(java.util.Collection, ILocated).

Constructor Detail

UT2004BotBehavior

public UT2004BotBehavior()
Method Detail

initializeController

public void initializeController(UT2004Bot bot)
Specified by:
initializeController in interface IUT2004BotController<UT2004Bot>
Overrides:
initializeController in class UT2004BotModuleController<UT2004Bot>

initializeModules

protected void initializeModules(UT2004Bot bot)
Initialize projectiles and weaponshooting modules.

Overrides:
initializeModules in class UT2004BotModuleController<UT2004Bot>

initializeWeaponShootings

protected void initializeWeaponShootings()
Adds handlers to deal with different weapons.


initializePathFinding

protected void initializePathFinding(UT2004Bot bot)
Initializes path-finding modules: UT2004BotModuleControllerNew#pathPlanner, UT2004BotModuleController.fwMap and UT2004BotModuleControllerNew#pathExecutor. If you need different path planner / path executor - override this method and initialize your own modules.

Overrides:
initializePathFinding in class UT2004BotModuleController<UT2004Bot>
Parameters:
bot -

getInitializeCommand

public Initialize getInitializeCommand()
Prepares the initialization message for Gamebots using the BotParameters provided to the UT2004BotRunner.

Specified by:
getInitializeCommand in interface IUT2004BotController<UT2004Bot>
Overrides:
getInitializeCommand in class UT2004BotController<UT2004Bot>

finishControllerInitialization

public void finishControllerInitialization()
Finish controller initialisation. Connects the weaponshooting to the navigation.

Specified by:
finishControllerInitialization in interface IUT2004BotController<UT2004Bot>
Overrides:
finishControllerInitialization in class UT2004BotModuleController<UT2004Bot>

beforeFirstLogic

public void beforeFirstLogic()
Called before the evaluation of the first logic. Use this to set up elements that need information about the world.

Specified by:
beforeFirstLogic in interface cz.cuni.amis.pogamut.base.agent.module.IAgentLogic<cz.cuni.amis.pogamut.base.agent.module.LogicModule>
Overrides:
beforeFirstLogic in class UT2004BotLogicController<UT2004Bot>

logic

public void logic()
The bot will evaluate its the logic every 100ms. In each evaluation it will do the following:
  1. Execute all outstanding action.
  2. Determine a target to shoot and look at. The target is determined by the first Selector in the list set by UT2004BotBehavior#target(SelectorList) that returns a valid target.
  3. Determine a target to look at. The target is determined by the first Selector in the list set by look(SelectorList) that returns a valid target.
  4. Look at something
    1. If we are navigating, navigation will ensure that we look at either our target or at the path ahead.
    2. If we have a target to look at, we turn to that target.
    3. If we don't have a target to look at, we turn around looking for a target.
  5. Prepare a batch of percepts for the Environment.

Specified by:
logic in interface cz.cuni.amis.pogamut.base.agent.module.IAgentLogic<cz.cuni.amis.pogamut.base.agent.module.LogicModule>
Overrides:
logic in class UT2004BotLogicController<UT2004Bot>

addAction

public void addAction(Action action)
               throws InterruptedException
Queues up the action to be executed on the first evaluation of the logic cycle. When the queue is full, this action will block until the queue is free.

Parameters:
action -
Throws:
InterruptedException

getAllPercepts

public Map<Method,Object> getAllPercepts()
Returns a previously prepared batch of percepts.

Specified by:
getAllPercepts in interface eis.eis2java.util.AllPerceptsProvider
Returns:
a previously prepared batch of percepts.

navigate

public void navigate(UnrealIdOrLocation destination)
              throws InterruptedException
When called the bot will make a best effort attempt to navigate to requested destination. The destination either be a Location or the UnrealId of an ILocated such as NavPoint or Player. When provided with a player the bot will actively pursue the player provided the player remains visible. The destination is considered reached when the bot is within 50 UT units from the destination. Or 100 UT units when trying to navigate to a player. The navigation can fail when there is no path to the destination, when the bot gets stuck. A bot can be considered stuck by three heuristics. Either the UT2004DistanceStuckDetector when the bot has not be closing in on its target enough, UT2004PositionStuckDetector when it has not been moving at all, or the UT2004TimeStuckDetector when it has not moved enough over time. When the bot dies or respawns the navigation will reset to waiting.

Parameters:
destination - where the bot should go.
Throws:
InterruptedException

stop

public void stop()
          throws InterruptedException
When called the bot will stop. Navigation will reset to waiting.

Throws:
InterruptedException

respawn

public void respawn()
             throws InterruptedException
When called the bot will respawn in at a random spawn point of its team. When the bot respawns he will have 100 health, 0 adrenaline, 0 armor, a shield gun and an assault rifle with 100 bullets and 4 grenades. The navigating will be reset to waiting.

Throws:
InterruptedException

combo

public void combo(Combo combo)
           throws InterruptedException

When called the bot will use the given combo.

Syntax: combo(Combo)

A combo can only be activated when the bot has 100 or more adrenaline. When active the combo will give the bot a small powerup and consume the bots adrenaline until none remains. When the adrenaline runs out the combo will stop.

For more information about the effects of a combo see: http://liandri.beyondunreal.com/Adrenaline

Parameters:
combo - to be activated.
Throws:
InterruptedException

dropWeapon

public void dropWeapon()
                throws InterruptedException

Drops the weapon the bot is currently holding.

Syntax: dropWeapon

The weapon will be dropped a few UT hundred units in the direction the bot is looking. When a weapon is dropped it can be picked up again, either by this bot or other other bots.

Note: The translocator and the shield gun can not be dropped.

Throws:
InterruptedException

path

public Percept path(UnrealIdOrLocation from,
                    UnrealIdOrLocation to)

The bot computes a path from a to b.

Syntax: path(From,To)

The action results in a path percept containing the path from a to b.

Syntax: path(Length,[NavPointId])

Parameters:
from - the navpoint from which the path starts.
to - the navpoint where the path should go to
Returns:
the path between from and to, including the distance of the path.

shoot

public void shoot(SelectorList targets)
           throws InterruptedException

Tells the bot how to prioritize who it shoots.

Syntax: shoot([Selector])
Syntax: shoot(Selector)

Note:

  1. To stop shooting, use shoot([]) or stopShooting.
  2. By default the bot will shoot the nearest visible enemy.

Throws:
InterruptedException

stopShooting

public void stopShooting()
                  throws InterruptedException
*

Tells the bot to stop shooting.

Syntax: stopShoot

Note: Executes shoot([])

Throws:
InterruptedException

prefer

public void prefer(WeaponPrefList weaponList)
            throws InterruptedException

Tells the bot which weapon it should prefer. The bot will select the first weapon from the list it can use. A weapon can be used when the bot has the and the ammo for it.

Syntax: prefer([weapon(WeaponId, FireMode)])
Syntax: prefer(weapon(WeaponId, FireMode))

Note: By Default the bot prefers the weapons in this order:

  1. weapon(shock_rifle, secondary)
  2. weapon(rocket_launcher, primary)
  3. weapon(flack_cannon, primary)
  4. weapon(sniper_rifle, primary)
  5. weapon(lightning_gun, primary)
  6. weapon(mini_gun, primary)
  7. weapon(link_gun, primary)
  8. weapon(bio_rifle, secondary)
  9. weapon(assault_rifle, primary)
  10. weapon(assault_rfile, secondary)
  11. weapon(shield_gun, secondary)
  12. weapon(shield_gun, primary)

Throws:
InterruptedException

look

public void look(SelectorList targets)
          throws InterruptedException

Tells the bot how to prioritize what it looks at.

Syntax: look([Selector])
Syntax: look(Selector)

Note:

  1. To to start looking around, use look([]).
  2. By default the bot will look at the nearest visible enemy.

Throws:
InterruptedException

skip

public void skip()

Does nothing.

Syntax: skip

TODO: Check DOC


logicIteration

@Deprecated
public Percept logicIteration()
Deprecated. 

Information about iteration of the bots logic.

Type: On Change

Syntax: logic(Iteration)

Notes:

  1. While the bot is capable of executing multiple actions in single logic iteration, it does not always make sense. Use this iteration to check if the bot is clear again.


actionCount

@Deprecated
public Percept actionCount()
Deprecated. 


self

public Percept self()

Information about the bot's identity and team.

Type: On Change

Syntax: self(UnrealId, NickName, Team)


orientation

public Percept orientation()

Information about the bot's position, rotation and velocity.

Type: On Change

Syntax: orientation(location(X,Y,Z), rotation(Pitch,Yaw,Roll), velocity(Vx, Vy,Vz))


status

public Percept status()

Information about the bot's current physical state.

Type: On Change

Syntax status(Health, Armour, Adrenaline,ActiveCombo)


score

public Percept score()

Information about the number of kills, deaths, and suicides this bot accumulated.

Type: On Change

Syntax: score(Kills, Deaths, Suicides)

Note: Using the respawn action and being fragged by an opponent both count as a death. Being killed by the your own weapon counts as a suicide.


currentWeapon

public Percept currentWeapon()

Information about weapon the bot is currently holding.

Type: On Change

Syntax: currentWeapon(WeaponType,FireMode)

TODO: List available weapons.


weapon

public Collection<Percept> weapon()

Information about weapons the bot has in its inventory.

Type: On change

Syntax: weapon(WeaponType, PriAmmo, SecAmmo)

Note: The Shield Gun has infinite primary ammo. Its secondary ammo recharges when not used.

TODO: List available weapons.


msgBotKilled

public void msgBotKilled(BotKilled msg)
Event listener for deaths of this bot.

Parameters:
msg -

msgPlayerKilled

public void msgPlayerKilled(PlayerKilled msg)
Event listener for deaths of other bots & players.

Parameters:
msg -

fragged

public List<Percept> fragged()

This percept is provided when one bot is violently fragmented by another.

Type: Always

Syntax: fragged(Time,KillerID,VictemID,Weapon)

Notes:

  1. When the killer and victim id are equal, the bot committed suicide.
  2. When the killer is none, the bot respawned.


navigation

public Percept navigation()

Information about the state of the navigation. The available states are:

Type: On Change

Syntax: navigation(State,Destination)


navPoint

public Collection<Percept> navPoint()

Information about point in the map. Together these form a directed graph that spans the entire map.

Type: Once

Syntax: navPoint(UnrealID, location(X,Y,Z), [NeigsUnrealID])

  1. UnrealID: The unique id of this navpoint.
  2. Location: The location of this navpoint in the map.
  3. [NeigsUnrealID]: A list of Id's for the neighbouring navpoints that are reachable from this navpoint.

*


visibleNavPoint

public Collection<Percept> visibleNavPoint()
TODO: Doc this

Returns:

pickup

public Collection<Percept> pickup()

Information indicating at which navpoint weapons, ammo, and health can be found.

Type: Once

Syntax: pickup(UnrealID, Label, ItemType)

Notes:

  1. Depending on the game setting "weapon stay", there may not always be a weapon present on a pick up point.
  2. If "weapon stay" is enabled, a weapon can only be picked up if one of the same type is not present in the bots inventory yet.
  3. TODO: A full overview of which category Label belongs to which item type.


base

public Collection<Percept> base()

Information about the location of the base. The opposing team will try to steal the flag from this location. Your team must deliver any capture flags to the base.

Type: Once

Syntax: base(Team, UnrealID)


game

public Percept game()

Information about the type of game being played, the map and the score required for winning the game.

Type: On Change

Syntax: game(Gametype, Map, TeamScoreLimit, RemainingTime)


teamScore

public Percept teamScore()

Percept that provides information about the current state of the game.

Type: On change

Syntax: teamScore(TeamScore, OpponentTeamScore)

Notes

  1. For CTF the score is the number of times the ag has been captured.
  2. Once either team reaches the goal score from the Game- info percept, the game is over.


flagState

public Collection<Percept> flagState()

Description: Percept that provides information about the current state of the flag.

Type: On change with negation.

Syntax: flagState(Team,FlagState)

Notes:

  1. See also the flag percept


item

public Collection<Percept> item()

Description: Provides information items the bot sees in the world.

Type: On change with negation.

Syntax: item(UnrealID, Label, ItemType, NavPointId)

Syntax: item(UnrealID, Label, ItemType, location(X,Y,Z)) when dropped.

Notes:

  1. TODO: A full over view of which category Label belongs to which item type.


flag

public Collection<Percept> flag()

Description: Percept provided when the flag is visible.

Type: On change with negation.

Syntax: flag(Team, UnrealId, location(X,Y,Z))

Notes:

  1. See also the flagStatus percept.


bot

public Collection<Percept> bot()

Percept provided when another bot becomes visible to this bot.

Type: On change with negation.

Syntax: bot(UnrealId, Team, location(X,Y,Z), Weapon, FireMode)



Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.