cz.cuni.amis.pogamut.ut2004.agent.module.sensor
Class Senses

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.agent.module.AgentModule<AGENT>
      extended by cz.cuni.amis.pogamut.base.agent.module.SensorModule<UT2004Bot>
          extended by cz.cuni.amis.pogamut.ut2004.agent.module.sensor.Senses
All Implemented Interfaces:
IComponent

public class Senses
extends SensorModule<UT2004Bot>

Memory module specialized on agent's senses.

This module hooks up a LOT OF LISTENERS and provide you with lot of methods to query current state of bot's sensors.

There are two types of methods:

  1. general - providing sensors 500ms back to the history
  2. once - providing sensors 500ms back to the history + queriable only once (first call may return true, next will report false until another sense arrive), this allows you to create simple if-then rules that won't fire twice.

If you are missing some methods that you think should be incorporated to the module, post to Pogamut 3 forum and we may then discuss the implementation.

It is designed to be initialized inside IUT2004BotController.prepareBot(UT2004Bot) method call and may be used since IUT2004BotController.botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage) is called.


Field Summary
protected  AgentInfo agentInfo
          AgentInfo memory module.
static double SENSE_THRESHOLD
          Specifies amount of time after which the sense (event) is considered to be invalid/old/discarded.
 
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.SensorModule
worldView
 
Fields inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule
agent, controller, eventBus, log
 
Constructor Summary
Senses(UT2004Bot bot)
          Constructor.
Senses(UT2004Bot bot, AgentInfo agentInfo, Players players)
          Constructor.
Senses(UT2004Bot bot, AgentInfo agentInfo, Players players, java.util.logging.Logger log)
          Constructor.
 
Method Summary
protected  void cleanUp()
          Hook where to perform clean up of data structures of the module.
 BotKilled getBotDeath()
          Provides information about the way this bot has died.
 Player getBumpingPlayer()
          Returns tha Player object of the player the bot has bumped into (if it was a bot).
 Location getBumpLocation()
          Returns location where bumping occurred.
 Location getCollisionLocation()
          Tells where the agent has collided.
 Vector3d getCollisionNormal()
          Tells the normal of last agent's collision.
 ItemPickedUp getItemPickedUp()
          Provides information about the last item the bot has picked up.
 PlayerDamaged getLastCausedDamage()
          Returns the description of the last damage caused by the bot.
 BotDamaged getLastDamage()
          Returns the description of the last damage done to the bot.
 PlayerDamaged getLastHitPlayer()
          Returns the description of the last hit of another player.
 IncomingProjectile getLastIncomingProjectile()
          Provides access to the last incoming-projectile object.
 BotDamaged getLastShot()
          Returns the description of the last shot that has hit the bot.
 Rotation getNoiseRotation()
          Tells where the noise is coming from.
 UnrealId getNoiseSource()
          Tells what has caused a noise (may be null).
 java.lang.String getNoiseType()
          Tells what type the noise is.
 Rotation getPickupNoiseRotation()
          Tells where the pickup noise is coming from.
 UnrealId getPickupNoiseSource()
          Tells what has caused the pickup noise (may be null).
 java.lang.String getPickupNoiseType()
          Tells what type the pickup noise is.
 PlayerKilled getPlayerKilled(Player player)
          Returns detail information about the way the player has died.
 PlayerKilled getPlayerKilled(UnrealId playerId)
          Returns detail information about the way the player of id 'playerId' has died.
 java.lang.Double getTimeDelta()
          Returns UT2004 time delta.
 boolean hasDied()
          Tells whether this bot has recently died.
 boolean hasDiedOnce()
          Tells whether this bot has recently died.
 boolean isAdrenalineGained()
          Tells whether the bot has recently got an adrenaline.
 boolean isAdrenalineGainedOnce()
          Tells whether the bot has recently got an adrenaline.
 boolean isBeingDamaged()
          Tells, whether the agent is being damaged.
 boolean isBeingDamagedOnce()
          Tells, whether the agent is being damaged.
 boolean isBumping()
          Tells whether the bot is bumping another player/other map geometry.
 boolean isBumpingOnce()
          Tells, whether the agent is bumping with another player/other map geometry.
 boolean isBumpingPlayer()
          Tells whether the bot is bumping another player (bot or human).
 boolean isBumpingPlayerOnce()
          Tells whether the bot is bumping another player (bot or human).
 boolean isCausingDamage()
          Tells, whether the agent is causing any damage.
 boolean isCausingDamageOnce()
          Tells, whether the agent is causing any damage.
 boolean isColliding()
          Tells, whether the agent is colliding with map geometry.
 boolean isCollidingOnce()
          Tells, whether the agent is colliding with map geometry.
 boolean isFallEdge()
          Tells whether the bot has just fall of the ledge
 boolean isFallEdgeOnce()
          Tells whether the bot has just fall of the ledge
 boolean isHearingNoise()
          Tells whether the bot is hearing noise.
 boolean isHearingNoiseOnce()
          Tells whether the bot is hearing noise.
 boolean isHearingPickup()
          Tells whether the bot is hearing pickup.
 boolean isHearingPickupOnce()
          Tells whether the bot is hearing pickup.
 boolean isHitPlayer()
          Tells, whether the agent hit another player (i.e..
 boolean isHitPlayerOnce()
          Tells, whether the agent hit another player (i.e..
 boolean isItemPickedUp()
          Tells whether this bot has picked up some item recently.
 boolean isItemPickedUpOnce()
          Tells whether this bot has picked up some item recently.
 boolean isPlayerKilled()
          Tells whether some other player has just died (we do not care which one).
 boolean isPlayerKilled(Player player)
          Tells whether some other player has just died.
 boolean isPlayerKilled(UnrealId playerId)
          Tells whether some other player of id 'playerId' has just died.
 boolean isPlayerKilledOnce()
          Tells whether some other player has just died (we do not care which one).
 boolean isPlayerKilledOnce(Player player)
          Tells whether some other player has just died.
 boolean isPlayerKilledOnce(UnrealId playerId)
          Tells whether some other player of id 'playerId' has just died.
 boolean isShot()
          Tells, whether the agent is being damaged by another player (i.e.
 boolean isShotOnce()
          Tells, whether the agent is being damaged by another player (i.e.
 boolean seeIncomingProjectile()
          Tells whether the bot see any incoming projectiles.
 boolean seeIncomingProjectileOnce()
          Tells whether the bot see any incoming projectiles.
 
Methods inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule
getComponentId, getLog, getState, initComponentId, isRunning, kill, pause, reset, resume, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SENSE_THRESHOLD

public static final double SENSE_THRESHOLD
Specifies amount of time after which the sense (event) is considered to be invalid/old/discarded.

See Also:
Constant Field Values

agentInfo

protected AgentInfo agentInfo
AgentInfo memory module.

Constructor Detail

Senses

public Senses(UT2004Bot bot)
Constructor. Setups the memory module based on bot's world view.

Parameters:
bot - owner of the module that is using it

Senses

public Senses(UT2004Bot bot,
              AgentInfo agentInfo,
              Players players)
Constructor. Setups the memory module based on bot's world view.

Parameters:
bot - owner of the module that is using it
agentInfo - AgentInfo memory module
players - Players memory module

Senses

public Senses(UT2004Bot bot,
              AgentInfo agentInfo,
              Players players,
              java.util.logging.Logger log)
Constructor. Setups the memory module based on bot's world view.

Parameters:
bot - owner of the module that is using it
agentInfo - AgentInfo memory module.
log - Logger to be used for logging runtime/debug info. If null, module creates its own logger.
Method Detail

isCollidingOnce

public boolean isCollidingOnce()
Tells, whether the agent is colliding with map geometry.

Note: This method clears the collision flag upon invocation. This is to prevent taking more action because of one collision.

Returns:
True, if the agent is colliding with map geometry.

isColliding

public boolean isColliding()
Tells, whether the agent is colliding with map geometry.

Returns:
True, if the agent is colliding with map geometry.

getCollisionLocation

public Location getCollisionLocation()
Tells where the agent has collided.

Returns:
location of the last collision

getCollisionNormal

public Vector3d getCollisionNormal()
Tells the normal of last agent's collision.

Returns:
normal vector of the triangle the bot has collided with

isBumping

public boolean isBumping()
Tells whether the bot is bumping another player/other map geometry.

Returns:
True, if the bot bumped another player/other map geometry.

isBumpingOnce

public boolean isBumpingOnce()
Tells, whether the agent is bumping with another player/other map geometry.

Note: This method clears the bumping flag upon invocation. This is to prevent taking more action because of one bumping.

Returns:
True, if the agent is bumping another player/other map geometry.

isBumpingPlayer

public boolean isBumpingPlayer()
Tells whether the bot is bumping another player (bot or human).


isBumpingPlayerOnce

public boolean isBumpingPlayerOnce()
Tells whether the bot is bumping another player (bot or human).

Note: This method clears the bumping flag upon invocation. This is to prevent taking more action because of one collision.

Returns:
True, if the agent is bumping to a player

getBumpingPlayer

public Player getBumpingPlayer()
Returns tha Player object of the player the bot has bumped into (if it was a bot).

Returns:
player the bot has bumped into (if it bumped the player)

getBumpLocation

public Location getBumpLocation()
Returns location where bumping occurred.

Returns:
location where the bumping has occurred

isFallEdge

public boolean isFallEdge()
Tells whether the bot has just fall of the ledge

Returns:
whether the bot has just fall of the ledge

isFallEdgeOnce

public boolean isFallEdgeOnce()
Tells whether the bot has just fall of the ledge

Note: This method clears the fall-edge flag upon invocation. This is to prevent taking more action because of one fall.

Returns:
whether the bot has just fall of the ledge

isHearingNoise

public boolean isHearingNoise()
Tells whether the bot is hearing noise.

Returns:
True, if the bot is hearing noise.

isHearingNoiseOnce

public boolean isHearingNoiseOnce()
Tells whether the bot is hearing noise.

Note: This method clears the hearing-noise flag upon invocation. This is to prevent taking more action because of hearing the noise.

Returns:
True, if the bot is hearing noise.

getNoiseRotation

public Rotation getNoiseRotation()
Tells where the noise is coming from.

Returns:
way where the noise has happened

getNoiseSource

public UnrealId getNoiseSource()
Tells what has caused a noise (may be null).

Returns:
what has caused a noise

getNoiseType

public java.lang.String getNoiseType()
Tells what type the noise is.

Returns:
noise type

isHearingPickup

public boolean isHearingPickup()
Tells whether the bot is hearing pickup.

Returns:
True, if the bot is hearing pickup.

isHearingPickupOnce

public boolean isHearingPickupOnce()
Tells whether the bot is hearing pickup.

Note: This method clears the hearing-pickup flag upon invocation. This is to prevent taking more action because of hearing the pickup.

Returns:
True, if the bot is hearing pickup.

getPickupNoiseRotation

public Rotation getPickupNoiseRotation()
Tells where the pickup noise is coming from.

Returns:
way where the noise has happened

getPickupNoiseSource

public UnrealId getPickupNoiseSource()
Tells what has caused the pickup noise (may be null).

Returns:
what has caused a noise

getPickupNoiseType

public java.lang.String getPickupNoiseType()
Tells what type the pickup noise is.

Returns:
noise type

isBeingDamaged

public boolean isBeingDamaged()
Tells, whether the agent is being damaged.

Returns:
True, if the agent is being damaged.

isBeingDamagedOnce

public boolean isBeingDamagedOnce()
Tells, whether the agent is being damaged.

Note: This method clears the being-damaged flag upon invocation. This is to prevent taking more action because of taking the damage.

Returns:
True, if the agent is being damaged.

getLastDamage

public BotDamaged getLastDamage()
Returns the description of the last damage done to the bot.

Returns:

isShot

public boolean isShot()
Tells, whether the agent is being damaged by another player (i.e. was shot).

Returns:
True, if the agent is being damaged.

isShotOnce

public boolean isShotOnce()
Tells, whether the agent is being damaged by another player (i.e. was shot).

Note: This method clears the shot flag upon invocation. This is to prevent taking more action because of taking the damage.

Returns:
True, if the agent is being damaged.

getLastShot

public BotDamaged getLastShot()
Returns the description of the last shot that has hit the bot.

Returns:
last shot the bot has taken

seeIncomingProjectile

public boolean seeIncomingProjectile()
Tells whether the bot see any incoming projectiles.

Returns:
whether the bot see any incoming projectile

seeIncomingProjectileOnce

public boolean seeIncomingProjectileOnce()
Tells whether the bot see any incoming projectiles.

Returns:
whether the bot see any incoming projectile

getLastIncomingProjectile

public IncomingProjectile getLastIncomingProjectile()
Provides access to the last incoming-projectile object.

Returns:
incoming projectile object

isCausingDamage

public boolean isCausingDamage()
Tells, whether the agent is causing any damage.

Returns:
True, if the agent is causing any damage.

isCausingDamageOnce

public boolean isCausingDamageOnce()
Tells, whether the agent is causing any damage.

Note: This method clears the causing-damage flag upon invocation. This is to prevent taking more action because of causing the damage.

Returns:
True, if the agent is being damaged.

getLastCausedDamage

public PlayerDamaged getLastCausedDamage()
Returns the description of the last damage caused by the bot.

Returns:

isHitPlayer

public boolean isHitPlayer()
Tells, whether the agent hit another player (i.e.. shot it).

Returns:
True, if the agent shot another player.

isHitPlayerOnce

public boolean isHitPlayerOnce()
Tells, whether the agent hit another player (i.e.. shot it).

Note: This method clears the player-hit flag upon invocation. This is to prevent taking more action because of hitting a player.

Returns:
True, if the agent hit another player.

getLastHitPlayer

public PlayerDamaged getLastHitPlayer()
Returns the description of the last hit of another player.

Returns:
last hit the bot has dealt

isPlayerKilled

public boolean isPlayerKilled()
Tells whether some other player has just died (we do not care which one).

Returns:
True, if some other player has just died.

isPlayerKilledOnce

public boolean isPlayerKilledOnce()
Tells whether some other player has just died (we do not care which one).

Note: This method clears the arbitrary-player-killed flag upon invocation. This is to prevent taking more action because of killing a player.

Returns:
True, if some other player has just died.

isPlayerKilled

public boolean isPlayerKilled(UnrealId playerId)
Tells whether some other player of id 'playerId' has just died.

Returns:
True, the player of id 'playerId' has just died.

isPlayerKilled

public boolean isPlayerKilled(Player player)
Tells whether some other player has just died.

Returns:
True, the player has just died.

isPlayerKilledOnce

public boolean isPlayerKilledOnce(UnrealId playerId)
Tells whether some other player of id 'playerId' has just died.

Note: This method clears the specific-player-killed flag upon invocation. This is to prevent taking more action because of killing a player.

Parameters:
playerId -
Returns:
True, the player of id 'playerId' has just died.

isPlayerKilledOnce

public boolean isPlayerKilledOnce(Player player)
Tells whether some other player has just died.

Note: This method clears the specific-player-killed flag upon invocation. This is to prevent taking more action because of killing a player.

Parameters:
player -
Returns:
True, the player has just died.

getPlayerKilled

public PlayerKilled getPlayerKilled(UnrealId playerId)
Returns detail information about the way the player of id 'playerId' has died.

Parameters:
playerId -
Returns:
detail info about player's death

getPlayerKilled

public PlayerKilled getPlayerKilled(Player player)
Returns detail information about the way the player has died.

Parameters:
player -
Returns:
detail info about player's death

isAdrenalineGained

public boolean isAdrenalineGained()
Tells whether the bot has recently got an adrenaline.

Returns:
whether the bot has recently got any adrenaline

isAdrenalineGainedOnce

public boolean isAdrenalineGainedOnce()
Tells whether the bot has recently got an adrenaline.

Note: This method clears the adrenaline-gained flag upon invocation. This is to prevent taking more action because of adrenaline gain.

Returns:
whether the bot has recently got any adrenaline

hasDied

public boolean hasDied()
Tells whether this bot has recently died.

Returns:
whether the bot has recently died.

hasDiedOnce

public boolean hasDiedOnce()
Tells whether this bot has recently died.

Note: This method clears the bot-died flag upon invocation. This is to prevent taking more action because of bot death.

Returns:
whether the bot has recently got any adrenaline

getBotDeath

public BotKilled getBotDeath()
Provides information about the way this bot has died.

Returns:
info about last bot death

isItemPickedUp

public boolean isItemPickedUp()
Tells whether this bot has picked up some item recently.

Returns:
whether the has picked up an item recently

isItemPickedUpOnce

public boolean isItemPickedUpOnce()
Tells whether this bot has picked up some item recently.

Note: This method clears the pick-up flag upon invocation. This is to prevent taking more action because of item pickup.

Returns:
whether the bot has recently got any adrenaline

getItemPickedUp

public ItemPickedUp getItemPickedUp()
Provides information about the last item the bot has picked up.

Returns:
last picked item

getTimeDelta

public java.lang.Double getTimeDelta()
Returns UT2004 time delta. Note that first logic tick it returns NULL as it does not have enough info to work with.

Returns:

cleanUp

protected void cleanUp()
Description copied from class: AgentModule
Hook where to perform clean up of data structures of the module.

Called from AgentModule.stop(), AgentModule.kill(), AgentModule.reset().

Overrides:
cleanUp in class AgentModule<UT2004Bot>