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

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.Players
All Implemented Interfaces:
IComponent

public class Players
extends SensorModule<UT2004Bot>

Memory module specialized on whereabouts of other players.

Auto updating

All Player objects returned by this memory module are always self-updating throughout the time, until the associated player leaves the game. This means that once a valid Player object is obtained, it is not necessary to call any methods of this memory module to get the object's info updated (e.g. player's location, visibility, reachability, etc.). The object will autoupdate itself.

The same principle is applied to all Maps returned by this memory module. Each returned Map is self-updating throughout the time. Once a specific Map is obtained (e.g. a map of visible enemies) from this memory module, the Map will get updated based on actions of the players (e.g. joining or leaving the game, changing their team, moving around the map, etc.) automatically.

Note: All Maps returned by this memory module are locked and can not be modified outside this memory module. If you need to modify a Map returned by this module (for your own specific purpose), create a duplicate first. Such duplicates, however and of course, will not get updated.

If you need to get info about players' deaths use Senses module.

WARNING:It is totally unclear what UT2004 means by reachable!!!

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
 
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
Players(UT2004Bot bot)
          Constructor.
Players(UT2004Bot bot, java.util.logging.Logger log)
          Constructor.
 
Method Summary
 boolean canReachEnemies()
          Tells, whether the agent can reach any other enemies.
 boolean canReachFriends()
          Tells, whether the agent can reach any other friends.
 boolean canReachPlayers()
          Tells, whether the agent can reach any other players.
 boolean canSeeEnemies()
          Tells, whether the agent sees any other enemies.
 boolean canSeeFriends()
          Tells, whether the agent sees any other friends.
 boolean canSeePlayers()
          Tells, whether the agent sees any other players.
protected  void cleanUp()
          Hook where to perform clean up of data structures of the module.
 java.util.Map<UnrealId,Player> getEnemies()
          Retreives a Map of all enemies.
 java.util.Map<UnrealId,Player> getFriends()
          Retreives a Map of all friends.
 Player getNearestEnemy(double recentlyVisibleTime)
          Returns nearest enemy that is visible or that was 'recently' visible.
 Player getNearestFriend(double recentlyVisibleTime)
          Returns nearest friend that is visible or that was 'recently' visible.
 Player getNearestPlayer(double recently)
          Returns nearest player that is visible or that was 'recently' visible.
 Player getNearestVisibleEnemy()
          Returns nearest-visible enemy - if no enemy is visible returns null.
 Player getNearestVisibleFriend()
          Returns nearest-visible friend - if no friend is visible returns null.
 Player getNearestVisiblePlayer()
          Returns nearest-visible player - if no if no player is visible returns null.
 Player getNearestVisiblePlayer(java.util.Collection<Player> players)
          Returns nearest-visible player to the bot from the collection of 'players' - if no player is visible returns null.
 Player getPlayer(UnrealId UnrealId)
          Retreives last known info about given player.
 java.util.Map<UnrealId,Player> getPlayers()
          Retreives a Map of all players.
 Player getRandomVisibleEnemy()
          Returns random visible enemy - if no enemy is visible returns null.
 Player getRandomVisibleFriend()
          Returns random friend - if no friend is visible returns null.
 Player getRandomVisiblePlayer()
          Returns random visible player - if no if no player is visible returns null.
 java.util.Map<UnrealId,Player> getReachableEnemies()
          Retreives a Map of all reachable enemies.
 java.util.Map<UnrealId,Player> getReachableFriends()
          Retreives a Map of all reachable friends.
 Player getReachablePlayer(UnrealId UnrealId)
          Retreives info about given player, but only it the player is reachable.
 java.util.Map<UnrealId,Player> getReachablePlayers()
          Retreives a Map of all reachable players.
 java.util.Map<UnrealId,Player> getVisibleEnemies()
          Retreives a Map of all visible enemies.
 java.util.Map<UnrealId,Player> getVisibleFriends()
          Retreives a Map of all visible friends.
 Player getVisiblePlayer(UnrealId UnrealId)
          Retreives info about given player, but only it the player is visible.
 java.util.Map<UnrealId,Player> getVisiblePlayers()
          Retreives a Map of all visible players.
 boolean isEnemy(int team)
          Tells, whether a given team is an enemy team to the agent.
 boolean isEnemy(Player player)
          Tells, whether a given player is an enemy to the agent.
 boolean isFriend(int team)
          Tells, whether a given team is a friend team to the agent.
 boolean isFriend(Player player)
          Tells, whether a given player is a friend to the agent.
 
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
 

Constructor Detail

Players

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

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

Players

public Players(UT2004Bot bot,
               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
log - Logger to be used for logging runtime/debug info. If null, module creates its own logger.
Method Detail

getPlayer

public Player getPlayer(UnrealId UnrealId)
Retreives last known info about given player.

Note: The returned Player object is self updating throughout time. Once you have a valid Player object, you do not have to call this method to get updated info about that player.

Parameters:
UnrealId - Player UnrealId to be retreived.
Returns:
Last known player info; or null upon none.
See Also:
getVisiblePlayer(UnrealId), getReachablePlayer(UnrealId)

getVisiblePlayer

public Player getVisiblePlayer(UnrealId UnrealId)
Retreives info about given player, but only it the player is visible.

Note: The returned Player object is self updating throughout time. Once you have a valid Player object, you do not have to call this method to get updated info about visibility of that player.

Parameters:
UnrealId - Player UnrealId to be retrieved.
Returns:
Player info; or null upon none or not visible.
See Also:
getPlayer(UnrealId), getReachablePlayer(UnrealId)

getReachablePlayer

public Player getReachablePlayer(UnrealId UnrealId)
Retreives info about given player, but only it the player is reachable.

WARNING:It is totally unclear what UT2004 means by reachable!!!

Note: The returned Player object is self updating throughout time. Once you have a valid Player object, you do not have to call this method to get updated info about reachability of that player.

Parameters:
UnrealId - Player UnrealId to be retreived.
Returns:
Player info; or null upon none or not reachable.
See Also:
getPlayer(UnrealId), getVisiblePlayer(UnrealId)

getPlayers

public java.util.Map<UnrealId,Player> getPlayers()
Retreives a Map of all players.

Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of players from this memory module, the Map will get updated based on actions of the players (e.g. joining or leaving the game, changing their status, etc.).

Returns:
Map of all players, using their UnrealIds as keys.
See Also:
getEnemies(), getFriends(), getVisiblePlayers(), getReachablePlayers()

getEnemies

public java.util.Map<UnrealId,Player> getEnemies()
Retreives a Map of all enemies.

Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of enemies from this memory module, the Map will get updated based on actions of the players (e.g. joining or leaving the game, changing their team or status, etc.).

Returns:
Map of all enemies, using their UnrealIds as keys.
See Also:
getPlayers(), getFriends(), getVisibleEnemies(), getReachableEnemies()

getFriends

public java.util.Map<UnrealId,Player> getFriends()
Retreives a Map of all friends.

Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of friends from this memory module, the Map will get updated based on actions of the players (e.g. joining or leaving the game, changing their team or status, etc.).

Returns:
Map of all friends, using their UnrealIds as keys.
See Also:
getPlayers(), getEnemies(), getVisibleFriends(), getReachableFriends()

getVisiblePlayers

public java.util.Map<UnrealId,Player> getVisiblePlayers()
Retreives a Map of all visible players.

Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of players from this memory module, the Map will get updated based on actions of the players (e.g. joining or leaving the game, or changing their visibility, etc.).

Returns:
Map of all visible players, using their UnrealIds as keys.
See Also:
getPlayers(), getVisibleEnemies(), getVisibleFriends(), canSeePlayers()

getVisibleEnemies

public java.util.Map<UnrealId,Player> getVisibleEnemies()
Retreives a Map of all visible enemies.

Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of enemies from this memory module, the Map will get updated based on actions of the players (e.g. joining or leaving the game, changing their team, status or visibility, etc.).

Returns:
Map of all visible enemies, using their UnrealIds as keys.
See Also:
getEnemies(), getVisiblePlayers(), getVisibleFriends(), canSeeEnemies()

getVisibleFriends

public java.util.Map<UnrealId,Player> getVisibleFriends()
Retreives a Map of all visible friends.

Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of friends from this memory module, the Map will get updated based on actions of the players (e.g. joining or leaving the game, changing their team, status or visibility, etc.).

Returns:
Map of all visible friends, using their UnrealIds as keys.
See Also:
getFriends(), getVisiblePlayers(), getVisibleEnemies(), canSeeFriends()

getReachablePlayers

public java.util.Map<UnrealId,Player> getReachablePlayers()
Retreives a Map of all reachable players.

WARNING:It is totally unclear what UT2004 means by reachable!!!

Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of players from this memory module, the Map will get updated based on actions of the players (e.g. joining or leaving the game, or changing their visibility, etc.).

Returns:
Map of all reachable players, using their UnrealIds as keys.
See Also:
getPlayers(), getReachableEnemies(), getReachableFriends(), canReachPlayers()

getReachableEnemies

public java.util.Map<UnrealId,Player> getReachableEnemies()
Retreives a Map of all reachable enemies.

WARNING:It is totally unclear what UT2004 means by reachable!!!

Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of enemies from this memory module, the Map will get updated based on actions of the players (e.g. joining or leaving the game, changing their team, status or visibility, etc.).

Returns:
Map of all reachable enemies, using their UnrealIds as keys.
See Also:
getEnemies(), getReachablePlayers(), getReachableFriends(), canReachEnemies()

getReachableFriends

public java.util.Map<UnrealId,Player> getReachableFriends()
Retreives a Map of all reachable friends.

WARNING:It is totally unclear what UT2004 means by reachable!!!

Note: The returned Map is unmodifiable and self updating throughout time. Once you obtain a specific Map of friends from this memory module, the Map will get updated based on actions of the players (e.g. joining or leaving the game, changing their team, status or visibility, etc.).

Returns:
Map of all reachable friends, using their UnrealIds as keys.
See Also:
getFriends(), getReachablePlayers(), getReachableEnemies(), canReachFriends()

getNearestPlayer

public Player getNearestPlayer(double recently)
Returns nearest player that is visible or that was 'recently' visible. If no such player exists, returns null.

Parameters:
recentlyVisibleTime - how long the player may be non-visible
Returns:
nearest visible or 'recentlyVisibleTime' visible player

getNearestEnemy

public Player getNearestEnemy(double recentlyVisibleTime)
Returns nearest enemy that is visible or that was 'recently' visible. If no such enemy exists, returns null.

Parameters:
recentlyVisibleTime - how long the player may be non-visible
Returns:
nearest visible or 'recently' visible enemy

getNearestFriend

public Player getNearestFriend(double recentlyVisibleTime)
Returns nearest friend that is visible or that was 'recently' visible. If no such friend exists, returns null.

Parameters:
recentlyVisibleTime - how long the player may be non-visible
Returns:
nearest visible or 'recently' visible friend

getNearestVisiblePlayer

public Player getNearestVisiblePlayer()
Returns nearest-visible player - if no if no player is visible returns null.

Returns:
nearest visible player

getNearestVisibleEnemy

public Player getNearestVisibleEnemy()
Returns nearest-visible enemy - if no enemy is visible returns null.

Returns:
nearest visible enemy

getNearestVisibleFriend

public Player getNearestVisibleFriend()
Returns nearest-visible friend - if no friend is visible returns null.

Returns:
nearest visible friend

getNearestVisiblePlayer

public Player getNearestVisiblePlayer(java.util.Collection<Player> players)
Returns nearest-visible player to the bot from the collection of 'players' - if no player is visible returns null.

Parameters:
players - collection to go through
Returns:
nearest visible player from the collection

getRandomVisiblePlayer

public Player getRandomVisiblePlayer()
Returns random visible player - if no if no player is visible returns null.

Returns:
random visible player

getRandomVisibleEnemy

public Player getRandomVisibleEnemy()
Returns random visible enemy - if no enemy is visible returns null.

Returns:
random visible enemy

getRandomVisibleFriend

public Player getRandomVisibleFriend()
Returns random friend - if no friend is visible returns null.

Returns:
random visible friend

canSeePlayers

public boolean canSeePlayers()
Tells, whether the agent sees any other players.

Returns:
True, if at least one other player is visible; false otherwise.
See Also:
getVisiblePlayers()

canSeeEnemies

public boolean canSeeEnemies()
Tells, whether the agent sees any other enemies.

Returns:
True, if at least one other enemy is visible; false otherwise.
See Also:
getVisibleEnemies()

canSeeFriends

public boolean canSeeFriends()
Tells, whether the agent sees any other friends.

Returns:
True, if at least one other friend is visible; false otherwise.
See Also:
getVisibleFriends()

canReachPlayers

public boolean canReachPlayers()
Tells, whether the agent can reach any other players.

WARNING:It is totally unclear what UT2004 means by reachable!!!

Returns:
True, if at least one other player is reachable; false otherwise.
See Also:
getReachablePlayers()

canReachEnemies

public boolean canReachEnemies()
Tells, whether the agent can reach any other enemies.

WARNING:It is totally unclear what UT2004 means by reachable!!!

Returns:
True, if at least one other enemy is reachable; false otherwise.
See Also:
getReachableEnemies()

canReachFriends

public boolean canReachFriends()
Tells, whether the agent can reach any other friends.

WARNING:It is totally unclear what UT2004 means by reachable!!!

Returns:
True, if at least one other friend is reachable; false otherwise.
See Also:
getReachableFriends()

isEnemy

public boolean isEnemy(int team)
Tells, whether a given team is an enemy team to the agent.

Parameters:
team - Team number to be tested.
Returns:
True, if the given team is an enemy team.
See Also:
getTeam(), isFriend(int)

isEnemy

public boolean isEnemy(Player player)
Tells, whether a given player is an enemy to the agent.

Parameters:
player - Player to be tested.
Returns:
True, if the given player is an enemy.
See Also:
getTeam(), isFriend(Player)

isFriend

public boolean isFriend(int team)
Tells, whether a given team is a friend team to the agent.

Parameters:
team - Team number to be tested.
Returns:
True, if the given team is a friend team.
See Also:
getTeam(), isEnemy(int)

isFriend

public boolean isFriend(Player player)
Tells, whether a given player is a friend to the agent.

Parameters:
player - Player to be tested.
Returns:
True, if the given player is a friend.
See Also:
getTeam(), isEnemy(Player)

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>