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

Package class diagram package 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:
cz.cuni.amis.pogamut.base.component.IComponent

public class Players
extends cz.cuni.amis.pogamut.base.agent.module.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.

Author:
Juraj 'Loque' Simlovic, Jimmy

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, Logger log)
          Constructor.
 
Method Summary
 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()
           
 Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Player> getEnemies()
          Retreives a Map of all enemies.
 Map<cz.cuni.amis.pogamut.unreal.communication.messages.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(Collection<Player> players)
          Returns nearest-visible player to the bot from the collection of 'players' - if no player is visible returns null.
 Player getPlayer(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId UnrealId)
          Retreives last known info about given player.
 Map<cz.cuni.amis.pogamut.unreal.communication.messages.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.
 Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Player> getVisibleEnemies()
          Retreives a Map of all visible enemies.
 Map<cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId,Player> getVisibleFriends()
          Retreives a Map of all visible friends.
 Player getVisiblePlayer(cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId UnrealId)
          Retreives info about given player, but only it the player is visible.
 Map<cz.cuni.amis.pogamut.unreal.communication.messages.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,
               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(cz.cuni.amis.pogamut.unreal.communication.messages.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(cz.cuni.amis.pogamut.unreal.communication.messages.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)

getPlayers

public Map<cz.cuni.amis.pogamut.unreal.communication.messages.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 Map<cz.cuni.amis.pogamut.unreal.communication.messages.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 Map<cz.cuni.amis.pogamut.unreal.communication.messages.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 Map<cz.cuni.amis.pogamut.unreal.communication.messages.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 Map<cz.cuni.amis.pogamut.unreal.communication.messages.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 Map<cz.cuni.amis.pogamut.unreal.communication.messages.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()

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:
recently - how long the player may be non-visible. IN MILISECONDS!
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 IN MILISECONDS!
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 IN MILISECONDS!
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(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()

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()
Overrides:
cleanUp in class cz.cuni.amis.pogamut.base.agent.module.AgentModule<UT2004Bot>


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