|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.pogamut.base.agent.module.AgentModule<AGENT> cz.cuni.amis.pogamut.base.agent.module.SensorModule<IObservingAgent> cz.cuni.amis.pogamut.ut2004.agent.module.sensor.AgentStats
public class AgentStats
Memory module specialized on collecting various statistics about the bot such as number of deaths, suicides, etc.
The module abides GameRestarted
(clear stats upon the restart) and can be set to export collected
data into certain file.
Field Summary | |
---|---|
protected int |
deaths
How many times the observed bot has died. |
protected int |
doubleDamageCount
How many times the bot had double damage. |
protected double |
doubleDamageTime
Total number of seconds the bot had double damage. |
protected java.io.File |
fileToOutput
Concrete file we're currently using. |
protected java.util.Map<ItemType.Category,java.lang.Integer> |
itemsByCategoryCollected
How many items according to its ItemType.Category the bot has collected. |
protected java.util.Map<ItemType,java.lang.Integer> |
itemsCollected
How many items the bot has collected according to their item type. |
protected java.util.Map<UnrealId,java.lang.Integer> |
killed
Contains statistics about bot that was KILLED BY OBSERVED BOT. |
protected java.util.Map<UnrealId,java.lang.Integer> |
killedBy
Contains statistics about bots that KILLED OBSERVED BOT. |
protected int |
killedByOthers
How many times was this bot killed by other players. |
protected int |
killedOthers
How many times this bot has killed other players. |
protected Location |
lastLocation
|
protected int |
numberOfPlayersKilledWithoutDeath
How many other players this bot has killed during its single life. |
protected boolean |
observer
|
protected java.util.Formatter |
outputFile
Formatter that is used to output strings into the UT2004AnalyzerObserver#observerFile . |
protected java.lang.String |
pathToOutput
Path to output as passed by the user. |
protected int |
playerKilledInRow
|
protected java.util.Map<UnrealId,PlayerScore> |
playerScores
Most rescent message containing info about the player's score. |
protected boolean |
shooting
Whether the bot is shooting. |
protected java.lang.Object |
statsMutex
|
protected int |
suicides
How many times this bot has comitted suicide. |
protected java.util.Map<java.lang.Integer,TeamScore> |
teamScores
Most rescent message containing info about the player team's score. |
protected double |
timeMoving
For how long in total the bot was moving (had non-zero (> 1) velocity) |
protected double |
timeShooting
For how long in total the bot was shooting. |
protected int |
totalItemsCollected
Total number of items the bot has collected. |
protected double |
travelledDistance
Sum of the bot's travelled distance. |
protected java.util.Map<ItemType,java.lang.Double> |
weaponsUsedTime
For how long the bot was shooting with a certain weapon, truly counting the number of seconds the Shoot command
has been effective for the bot. |
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 | |
---|---|
AgentStats(IObservingAgent bot)
Constructor. |
|
AgentStats(IObservingAgent bot,
java.util.logging.Logger log)
Constructor. |
Method Summary | |
---|---|
protected void |
botKilled(BotKilled event)
|
protected java.lang.String |
fixSemicolon(java.lang.String text)
|
protected void |
gameRestarted(GameRestarted event)
|
UnrealId |
getBotId()
Returns Id of the bot, sensitive to isObserver() . |
double |
getCurrentMatchTime()
Current match time - note that this might different from the current GB2004 time because the match time is reset upon GameRestarted . |
double |
getCurrentUT2004Time()
Returns current UT2004 time (without any deltas, i.e., this is completely driven by the time from BeginMessage s). |
int |
getDeaths()
How many times in total your bot has died (regardless the type of death). |
int |
getDoubleDamageCount()
How many times your bot had double damage so far. |
double |
getDoubleDamageTime()
For how long (in total) your bot had double damage. |
java.util.Map<ItemType.Category,java.lang.Integer> |
getItemsByCategoryCollected()
How many items (per respective ItemType.Category ) your bot has collected so far. |
java.util.Map<ItemType,java.lang.Integer> |
getItemsCollected()
How many items (per ItemType ) your bot has collected so far (in total). |
java.util.Map<UnrealId,java.lang.Integer> |
getKilled()
Returns map that counts how many time your bot kills other bot (according to opponent bot ID), i.e., under the key (other bot ID) is "how many time your bot has billed the other bot". |
java.util.Map<UnrealId,java.lang.Integer> |
getKilledBy()
Who has killed your bot the most? This map holds number according to killers' ides. |
int |
getKilledByOthers()
How many times your bot has been killed by other bots. |
int |
getKilledOthers()
How many other bots your bot has killed so far. |
double |
getMatchStartTime()
Returns the global UT2004 time that we're considering as a start-of-match. |
int |
getNumberOfPlayersKilledWithoutDeath()
The biggest number of other bots killed in a row (without being killed). |
java.io.File |
getOutputFile()
Actually used file for outputting of stats. |
protected java.io.File |
getOutputFile(java.lang.String pathToFile,
boolean seekAlternatives)
Returns File for a given 'pathToFile'. |
java.lang.String |
getOutputPath()
Returns the output path as supplied in startOutput(String) or startOutput(String, boolean) . |
java.util.Map<UnrealId,PlayerScore> |
getPlayerScores()
Returns map with scores of respective players in the game. |
int |
getScore()
Current score of your bot. |
int |
getSuicides()
How many times your bot has committed suicide. |
int |
getTeamScore()
Current score of the bot's team. |
java.util.Map<java.lang.Integer,TeamScore> |
getTeamScores()
Returns map with scores of respective teams in the game. |
double |
getTimeMoving()
For how long your bot was moving (in total). |
double |
getTimeShooting()
For how long your bot was shooting (in total). |
int |
getTotalItemsCollected()
Total number of items the bot collected (including items received when the bot respawns). |
double |
getTravelledDistance()
How big distance your bot has travelled so far. |
java.util.Map<ItemType,java.lang.Double> |
getWeaponsUsedTime()
For how long your bot was using a certain weapon (in total). |
boolean |
isLogBeforeMatchRestart()
Should we log something before GameRestarted ? Default: TRUE. |
boolean |
isLogging()
Whether the object is currently collecting stats. |
boolean |
isObserver()
Whether the module is being used inside observer. |
boolean |
isOutputting()
Whether the object is currently logging (it may be false while the match is being restarted). |
boolean |
isShooting()
Whether the bot is currently shooting |
boolean |
isTimeInitialized()
Whether we have already received at least two BeginMessage in order to have all time-vars initialized
so we may collect all stats. |
protected void |
itemPickedUp(ItemPickedUp event)
|
protected void |
kill()
Kills the agent module. |
void |
outputHeader(java.util.Formatter output)
Outputs stats headers into the 'output'. |
protected void |
outputStatLine(double time,
java.lang.String... eventOutput)
Outputs stats line with event IFF logging (i.e., outputFile is not null, was initialized by startOutput(String) or startOutput(String, boolean) ). |
void |
outputStatLine(java.util.Formatter output,
double time,
java.lang.String... eventOutput)
Outputs stats line into 'output' appending 'eventOutput' at the end (also separated by semicolons) |
protected void |
playerKilled(PlayerKilled event)
|
void |
resetMatchTime()
Resets match time to ZERO again (if is initialized, i.e., getCurrentMatchTime() > 0). |
void |
resetStats()
Reset all stats, DOES NOT RESET getCurrentMatchTime() (use resetMatchTime() for that purpose separately). |
void |
setLogBeforeMatchRestart(boolean logBeforeMatchRestart)
Sets whether we should collect stats before GameRestarted event. |
void |
setObserver(boolean observer)
Sets whether the module is being used inside observer. |
protected void |
start(boolean startToPaused)
Starts the agent module. |
void |
startOutput(java.lang.String pathToFile)
Starts or redirect logging to 'pathToFile'. |
void |
startOutput(java.lang.String pathToFile,
boolean seekAlternatives)
Starts or redirect logging to 'pathToFile'. |
protected void |
stop()
Stops the agent module. |
void |
stopOutput()
Stops outputting of stats into file, nullify outputFile and fileToOutput . |
protected void |
updateStats(EndMessage event)
Called when EndMessage is received, writes another line into the UT2004AnalyzerObsStats#outputFile . |
Methods inherited from class cz.cuni.amis.pogamut.base.agent.module.AgentModule |
---|
cleanUp, getComponentId, getLog, getState, initComponentId, isRunning, pause, reset, resume, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected boolean observer
protected java.util.Map<UnrealId,java.lang.Integer> killed
protected java.util.Map<UnrealId,java.lang.Integer> killedBy
protected java.util.Map<UnrealId,PlayerScore> playerScores
protected java.util.Map<java.lang.Integer,TeamScore> teamScores
protected int deaths
protected int suicides
protected int killedByOthers
protected int killedOthers
protected double travelledDistance
protected boolean shooting
protected double timeShooting
protected double timeMoving
protected java.util.Map<ItemType,java.lang.Double> weaponsUsedTime
Shoot
command
has been effective for the bot.
protected java.util.Map<ItemType,java.lang.Integer> itemsCollected
protected java.util.Map<ItemType.Category,java.lang.Integer> itemsByCategoryCollected
ItemType.Category
the bot has collected.
protected int totalItemsCollected
protected int numberOfPlayersKilledWithoutDeath
protected int doubleDamageCount
protected double doubleDamageTime
protected java.lang.Object statsMutex
protected java.lang.String pathToOutput
protected java.io.File fileToOutput
protected java.util.Formatter outputFile
UT2004AnalyzerObserver#observerFile
.
protected int playerKilledInRow
protected Location lastLocation
Constructor Detail |
---|
public AgentStats(IObservingAgent bot)
bot
- owner of the module that is using itpublic AgentStats(IObservingAgent bot, java.util.logging.Logger log)
bot
- owner of the module that is using itlog
- Logger to be used for logging runtime/debug info. If null, the module creates its own logger.Method Detail |
---|
public boolean isObserver()
public void setObserver(boolean observer)
observer
- public UnrealId getBotId()
isObserver()
.
public void outputHeader(java.util.Formatter output)
output
- public void outputStatLine(java.util.Formatter output, double time, java.lang.String... eventOutput)
output
- eventOutput
- protected void outputStatLine(double time, java.lang.String... eventOutput)
outputFile
is not null, was initialized by startOutput(String)
or startOutput(String, boolean)
).
eventOutput
- protected java.lang.String fixSemicolon(java.lang.String text)
public void resetStats()
getCurrentMatchTime()
(use resetMatchTime()
for that purpose separately).
public void resetMatchTime()
getCurrentMatchTime()
> 0).
public boolean isOutputting()
public java.lang.String getOutputPath()
startOutput(String)
or startOutput(String, boolean)
.
For concretely used file for the output, use getOutputFile()
.
public java.io.File getOutputFile()
public void startOutput(java.lang.String pathToFile)
pathToFile
- (target file format is .csv, should not need to end with any extension, will be supplied)setOutputPath(String, boolean)
public void stopOutput()
outputFile
and fileToOutput
.
After the call:
isOutputting()
will report falsegetOutputFile()
will report nullgetOutputPath()
will still be reported the last path passed into startOutput(String)
or startOutput(String, boolean)
protected java.io.File getOutputFile(java.lang.String pathToFile, boolean seekAlternatives)
File
for a given 'pathToFile'. Target file is either non-existent or is file (otherwise throws an exception).
If 'seekAlternatives' is true, the method will try to find another file if 'pathToFile' already exists by appending "_000", "_001", ... If alternative filename is found, it is returned. Otherwise throws an exception.
pathToFile
- seekAlternatives
-
public void startOutput(java.lang.String pathToFile, boolean seekAlternatives)
If 'seekAlternatives' is true, the method will try to find another file if 'pathToFile' already exists by appending "_000", "_001", ... If alternative filename is found, the log is redirected there. Otherwise throws an exception.
pathToFile
- (target file format is .csv, should not need to end with any extension, will be supplied)seekAlternatives
- whether to try other file (using suffixes to file name '_000', '_001', ..., '_999'public java.util.Map<UnrealId,java.lang.Integer> getKilled()
public java.util.Map<UnrealId,PlayerScore> getPlayerScores()
public java.util.Map<java.lang.Integer,TeamScore> getTeamScores()
public double getCurrentMatchTime()
GameRestarted
.
Returns negative number if it can't be evaluated, i.e., the match has not been started (and we're waiting for it,
that happens only if you have used setLogBeforeMatchRestart(boolean)
), or we do not have enough data.
public double getCurrentUT2004Time()
BeginMessage
s).
Returns negative number if it can't be evaluated.
public int getKilledOthers()
public boolean isShooting()
public double getTimeShooting()
public double getTimeMoving()
public java.util.Map<ItemType,java.lang.Double> getWeaponsUsedTime()
public java.util.Map<ItemType,java.lang.Integer> getItemsCollected()
ItemType
) your bot has collected so far (in total).
public java.util.Map<ItemType.Category,java.lang.Integer> getItemsByCategoryCollected()
ItemType.Category
) your bot has collected so far.
public int getTotalItemsCollected()
public int getNumberOfPlayersKilledWithoutDeath()
public int getDoubleDamageCount()
public double getDoubleDamageTime()
public java.util.Map<UnrealId,java.lang.Integer> getKilledBy()
public int getDeaths()
public double getTravelledDistance()
public int getSuicides()
public int getScore()
public int getTeamScore()
public int getKilledByOthers()
public boolean isTimeInitialized()
BeginMessage
in order to have all time-vars initialized
so we may collect all stats.
public double getMatchStartTime()
public boolean isLogging()
This depends on three things:
isTimeInitialized()
GameRestarted
, i.e., you have used setLogBeforeMatchRestart(boolean)
Self
public boolean isLogBeforeMatchRestart()
GameRestarted
? Default: TRUE.
public void setLogBeforeMatchRestart(boolean logBeforeMatchRestart)
GameRestarted
event. Default: FALSE.
Best to be utilized in IUT2004BotController.prepareBot(UT2004Bot)
.
logBeforeMatchRestart
- protected void gameRestarted(GameRestarted event)
protected void botKilled(BotKilled event)
protected void playerKilled(PlayerKilled event)
protected void itemPickedUp(ItemPickedUp event)
protected void updateStats(EndMessage event)
EndMessage
is received, writes another line into the UT2004AnalyzerObsStats#outputFile
.
protected void start(boolean startToPaused)
AgentModule
start
in class AgentModule<IObservingAgent>
protected void stop()
AgentModule
Calls AgentModule.cleanUp()
.
stop
in class AgentModule<IObservingAgent>
protected void kill()
AgentModule
Calls AgentModule.cleanUp()
.
kill
in class AgentModule<IObservingAgent>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |