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

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

public class Game
extends SensorModule<UT2004Bot>

Memory module specialized on general info about the game.

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.


Nested Class Summary
static class Game.GameType
          Enums for game types that shields you from Unreal's string ids of game types.
 
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
Game(UT2004Bot bot)
          Constructor.
Game(UT2004Bot bot, java.util.logging.Logger log)
          Constructor.
 
Method Summary
protected  void cleanUp()
          Hook where to perform clean up of data structures of the module.
 java.util.Map<java.lang.Integer,FlagInfo> getAllCTFFlags()
          Returns a map indexed by team numbers, holding all flags in the game.
 java.util.Collection<FlagInfo> getAllCTFFlagsCollection()
          Returns a collection of all the flags in the game.
 FlagInfo getCTFFlag(int team)
          Retrieves FlagInfo object representing the Flag for input team in BotCTFGame.
 java.util.Collection<FlagInfo> getCTFFlags()
          Retrieves all FlagInfo objects in the game (by default two) in BotCTFGame.
 java.util.Collection<NavPoint> getDominationPoints()
          Retrieves all domination points in the game (by default two) in BotDoubleDomination.
 java.lang.Integer getFragLimit()
          BotDeathMatch only:
 java.lang.Integer getFullHealth()
          Retreives maximum level of non-boosted health.
 GameInfo getGameInfo()
          Returns original GameInfo message.
 Game.GameType getGameType()
          Retreives the type of the game.
 java.lang.String getMapName()
          Retreives the name of current map.
 java.lang.Integer getMaxAdrenaline()
          Retreives maximum level of adrenaline that can be gained.
 java.lang.Integer getMaxArmor()
          Retreives maximum level of combined armor.
 java.lang.Integer getMaxHealth()
          Retreives maximum level of boosted health.
 int getMaxHighArmor()
          Retreives maximum level of high armor.
 int getMaxLowArmor()
          Retreives maximum level of low armor.
 java.lang.Integer getMaxMultiJump()
          Retreives the maximum number of multi-jumping combos.
 java.lang.Integer getMaxTeams()
          BotTeamGame, BotCTFGame, BotDoubleDomination only:
 java.lang.Integer getMaxTeamSize()
          BotTeamGame, BotCTFGame, BotDoubleDomination only:
 java.util.List<Mutator> getMutators()
          Returns list of mutators that are active in the current game.
 int getPlayerDeaths(UnrealId id)
          Retreives number of deaths the agent took.
 int getPlayerScore(UnrealId id)
          Retreives agent score.
 java.util.Map<UnrealId,PlayerScore> getPlayerScores()
          Returns unmodifiable map with player scores.
 java.lang.String getPrefixed(java.lang.String objectId)
          It returns 'objectId' prefixed with "getMapName().".
 UnrealId getPrefixedId(java.lang.String objectId)
          It returns 'objectId' prefixed with "getMapName().".
 java.lang.Double getRemainingTime()
          Retreives time remaining for the game.
 java.lang.Integer getStartAdrenaline()
          Retreives starting level of adrenaline.
 java.lang.Integer getStartHealth()
          Retreives starting level of health.
 java.lang.Integer getTargetAdrenaline()
          Retreives target level of adrenaline that need to be gained to start special bonus actions.
 int getTeamScore(int team)
          Retrieves teams team score.
 java.lang.Integer getTeamScoreLimit()
          BotTeamGame, BotCTFGame, BotBombingRun, BotDoubleDomination only:
 java.util.Map<java.lang.Integer,TeamScore> getTeamScores()
          Returns unmodifiable map with team scores.
 double getTime()
          Retreives current game time, since the game started.
 java.lang.Double getTimeLimit()
          Retreives time limit for the game.
 java.lang.Boolean getWeaponsStay()
          Tells, whether the weapons stay on pick-up points, even when they are picked-up by players.
 java.lang.Boolean isBotsPaused()
          Tells, whether the bots are paused or running.
 boolean isMapName(java.lang.String name)
          Tells, whether the UT2004 is currently running map with name 'name'.
 java.lang.Boolean isPaused()
          Tells, whether the game is paused or running.
 boolean isPlayerDeathsKnown(UnrealId player)
          Tells whether the number of deaths for 'player' is known.
 boolean isPlayerScoreKnown(UnrealId player)
          Tells whether the player score for 'player' is known.
 boolean isTeamScoreKnown(int team)
          Tells whether the team score for 'team' is known.
 
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

Game

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

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

Game

public Game(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, the module creates its own logger.
Method Detail

getGameInfo

public GameInfo getGameInfo()
Returns original GameInfo message.

Returns:

getGameType

public Game.GameType getGameType()
Retreives the type of the game.

Returns:
Type of the game.

getMapName

public java.lang.String getMapName()
Retreives the name of current map.

Returns:
Name of the current map.

isMapName

public boolean isMapName(java.lang.String name)
Tells, whether the UT2004 is currently running map with name 'name'.

Parameters:
name -
Returns:

getPrefixed

public java.lang.String getPrefixed(java.lang.String objectId)
It returns 'objectId' prefixed with "getMapName().".

Note that you may pass prefixed objectId into this method, it will detect it that and auto-correct upper/lower case of this existing prefix if needed. Also you may use it as a validation feature because this method will raise an exception if the prefix does not match the current map name.

Parameters:
objectId - will be auto-prefixed (if enabled, which is default)
Returns:

getPrefixedId

public UnrealId getPrefixedId(java.lang.String objectId)
It returns 'objectId' prefixed with "getMapName().".

Note that you may pass prefixed objectId into this method, it will detect it that and auto-correct upper/lower case of this existing prefix if needed. Also you may use it as a validation feature because this method will raise an exception if the prefix does not match the current map name.

Parameters:
objectId - will be auto-prefixed (if enabled, which is default)
Returns:
objectId prefixed and converted to UnrealId

getTime

public double getTime()
Retreives current game time, since the game started.

Returns:
Current game timestamp.

getTimeLimit

public java.lang.Double getTimeLimit()
Retreives time limit for the game.

Note: Then the time limit is reached and the game is tie, special game modes might be turned on, e.g. sudden death overtime. Depends on the game type and game settings.

Returns:
Time limit of the game.
See Also:
getRemainingTime()

getRemainingTime

public java.lang.Double getRemainingTime()
Retreives time remaining for the game.

Note: Then the time limit is reached and the game is tie, special game modes might be turned on, e.g. sudden death overtime. Depends on the game type and game settings.

Returns:
Time limit of the game.
See Also:
getTime(), getTimeLimit()

getFragLimit

public java.lang.Integer getFragLimit()
BotDeathMatch only:

Number of points (e.g. kills) needed to win the game.

Returns:
Frag limit of the game.
See Also:
getTeamScoreLimit()

getTeamScoreLimit

public java.lang.Integer getTeamScoreLimit()
BotTeamGame, BotCTFGame, BotBombingRun, BotDoubleDomination only:

Number of points a team needs to win the game.

Returns:
Team score limit of the game.
See Also:
getFragLimit()

getCTFFlag

public FlagInfo getCTFFlag(int team)
Retrieves FlagInfo object representing the Flag for input team in BotCTFGame. If current game is not BotCTFGame, returns null!

Parameters:
team - to get the flag for.
Returns:
FlagInfo object representing the team flag.

getCTFFlags

public java.util.Collection<FlagInfo> getCTFFlags()
Retrieves all FlagInfo objects in the game (by default two) in BotCTFGame. If current game is not BotCTFGame, returns empty collection!

Returns:
Collection of FlagInfo objects representing the flags in the game.

getDominationPoints

public java.util.Collection<NavPoint> getDominationPoints()
Retrieves all domination points in the game (by default two) in BotDoubleDomination. Domination points are normal NavPoints, but with flag isDomPoint set to true. Moreover, Domination points have attribute DomPointController exported, holding the team that controls the point.

Returns:
Collection of NavPoint objects representing the domination points in the game.

getTeamScores

public java.util.Map<java.lang.Integer,TeamScore> getTeamScores()
Returns unmodifiable map with team scores.

Map is unsynchronized! If you want to iterate it over, use synchronized statement over the map.

Returns:
all known team scores

getTeamScore

public int getTeamScore(int team)
Retrieves teams team score.

Team score is usually rising by achieving team goals, e.g. killing opponents, capturing flags, controlling domination points, etc. Note: Team score might decrease, when opposing teams score points themselves, based on map, game type and game settings.

Note that if Integer.MIN_VALUE is returned, it means that the score is unknown.

Parameters:
team - to get the team score for.
Returns:
teams team score.

isTeamScoreKnown

public boolean isTeamScoreKnown(int team)
Tells whether the team score for 'team' is known.

Parameters:
team -
Returns:

getPlayerScores

public java.util.Map<UnrealId,PlayerScore> getPlayerScores()
Returns unmodifiable map with player scores. (Note that from PlayerScore message you can get also PlayerScore.getDeaths().)

Map is unsynchronized! If you want to iterate it over, use synchronized statement over the map.

Returns:
all known player scores

getPlayerScore

public int getPlayerScore(UnrealId id)
Retreives agent score.

Agent score is usually rising by achieving some goals, e.g. killing opponents, capturing flags, controlling domination points, etc. Note: Agent score might decrease upon suicides, based on map, game type and game settings.

Note that if Integer.MIN_VALUE is returned, than the score is unknown.

Parameters:
id - id of the player
Returns:
Current agent score.

isPlayerScoreKnown

public boolean isPlayerScoreKnown(UnrealId player)
Tells whether the player score for 'player' is known.

Parameters:
player -
Returns:

getPlayerDeaths

public int getPlayerDeaths(UnrealId id)
Retreives number of deaths the agent took.

A death is counted, whenever the agent dies.

Note that if Integer.MIN_VALUE is returned, than the number of deaths is unknown.

Returns:
Number of deaths the agent took.

isPlayerDeathsKnown

public boolean isPlayerDeathsKnown(UnrealId player)
Tells whether the number of deaths for 'player' is known.

Parameters:
player -
Returns:

getMaxTeams

public java.lang.Integer getMaxTeams()
BotTeamGame, BotCTFGame, BotDoubleDomination only:

Retrieves number of teams in the game.

Team numbers start from 0. Usually, there are just two teams: 0 and 1.

Returns:
Number of teams in the game.

getMaxTeamSize

public java.lang.Integer getMaxTeamSize()
BotTeamGame, BotCTFGame, BotDoubleDomination only:

Retreives maximum number of players per team.

Returns:
Maximum number of players per team.

getStartHealth

public java.lang.Integer getStartHealth()
Retreives starting level of health. This is the level of health the players spawn with into the game.

Returns:
Starting level of health.
See Also:
getMaxHealth(), getFullHealth()

getFullHealth

public java.lang.Integer getFullHealth()
Retreives maximum level of non-boosted health. This is the level achievable by foraging standard health kits.

Returns:
Maximum level of non-boosted health.
See Also:
getStartHealth(), getMaxHealth()

getMaxHealth

public java.lang.Integer getMaxHealth()
Retreives maximum level of boosted health. This is the total maximum health achievable by any means of health kits, super health, or health vials.

Returns:
Maximum level of boosted health.
See Also:
getStartHealth(), getFullHealth()

getMaxArmor

public java.lang.Integer getMaxArmor()
Retreives maximum level of combined armor. The armor consist of two parts, which are summed together into combined armor value. However, each part is powered-up by different item (either by small shield or by super-shield).

Returns:
Maximum level of combined armor.
See Also:
getMaxLowArmor(), getMaxHighArmor()

getMaxLowArmor

public int getMaxLowArmor()
Retreives maximum level of low armor. The armor consist of two parts, which are summed together into combined armor value. However, each part is powered-up by different item (either by small shield or by super-shield).

Low armor is powered-up by small shield.

Returns:
Maximum level of low armor.
See Also:
getMaxArmor(), getMaxHighArmor()

getMaxHighArmor

public int getMaxHighArmor()
Retreives maximum level of high armor. The armor consist of two parts, which are summed together into combined armor value. However, each part is powered-up by different item (either by small shield or by super-shield).

High armor is powered-up by super-shield.

Returns:
Maximum level of high armor.
See Also:
getMaxArmor(), getMaxLowArmor()

getStartAdrenaline

public java.lang.Integer getStartAdrenaline()
Retreives starting level of adrenaline. This is the level of adrenaline the players spawn with into the game.

Returns:
Starting level of adrenaline.

getTargetAdrenaline

public java.lang.Integer getTargetAdrenaline()
Retreives target level of adrenaline that need to be gained to start special bonus actions.

Once the agent's adrenaline reaches this designated level, it can be used to start special bonus booster-actions like invisibility, speed, booster, etc. The adrenaline is then spent on the invoked action.

Returns:
Maximum level of adrenaline that can be gained.

getMaxAdrenaline

public java.lang.Integer getMaxAdrenaline()
Retreives maximum level of adrenaline that can be gained.

Returns:
Maximum level of adrenaline that can be gained.

getWeaponsStay

public java.lang.Boolean getWeaponsStay()
Tells, whether the weapons stay on pick-up points, even when they are picked-up by players.

If so, each weapon type can be picked up from pick-up points only once. If the player already has the weapon the pick-up point offers, he can not pick it up. Also, each weapon pick-up point always contains its associated weapon.

If not, weapons can be picked up from pick-up points repeatedly. If the player already has the weapon the pick-up point offers, the pick-up will simply replenish ammo for that weapon. Also, upon each pick-up by a player, the offered weapon disappears (it is "taken" by that player). Weapons respawn on empty pick-up points after a while.

Returns:
True, if weapons stay on pick-up points.

getMaxMultiJump

public java.lang.Integer getMaxMultiJump()
Retreives the maximum number of multi-jumping combos.

Note: Multi-jump combos are currently limited to double-jumps for bots.

Returns:
Maximum number of multi-jumping combos.

getMutators

public java.util.List<Mutator> getMutators()
Returns list of mutators that are active in the current game.

Returns:
Current game's mutators

isPaused

public java.lang.Boolean isPaused()
Tells, whether the game is paused or running. When the game is paused, nobody can move or do anything (usually except posting text messages).

Returns:
True, if the game is paused. False otherwise.
See Also:
areBotsPaused()

isBotsPaused

public java.lang.Boolean isBotsPaused()
Tells, whether the bots are paused or running. When the bots are paused, but the game is not paused as well, human controlled players can move. The bots are standing still and can do nothing (usually except posting text messages).

Returns:
True, if the bots are paused. False otherwise.
See Also:
isPaused()

getAllCTFFlags

public java.util.Map<java.lang.Integer,FlagInfo> getAllCTFFlags()
Returns a map indexed by team numbers, holding all flags in the game. In non-Capture the Flag (CTF) gametypes the result map will be empty.

Returns:
Map containing all the flags in the game indexed by owner team number.

getAllCTFFlagsCollection

public java.util.Collection<FlagInfo> getAllCTFFlagsCollection()
Returns a collection of all the flags in the game. In non-Capture the Flag (CTF) gametypes the result collection will be empty.

Returns:
Collection containing all the flags in the game.

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>