|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.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 File |
fileToOutput
Concrete file we're currently using. |
protected Map<ItemType.Category,Integer> |
itemsByCategoryCollected
How many items according to its ItemType.Category the bot has collected. |
protected Map<ItemType,Integer> |
itemsCollected
How many items the bot has collected according to their item type. |
protected Map<UnrealId,Integer> |
killed
Contains statistics about bot that was KILLED BY OBSERVED BOT. |
protected Map<UnrealId,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 Formatter |
outputFile
Formatter that is used to output strings into the UT2004AnalyzerObserver#observerFile . |
protected String |
pathToOutput
Path to output as passed by the user. |
protected int |
playerKilledInRow
|
protected Map<UnrealId,PlayerScore> |
playerScores
Most rescent message containing info about the player's score. |
protected boolean |
shooting
Whether the bot is shooting. |
protected Object |
statsMutex
|
protected int |
suicides
How many times this bot has comitted suicide. |
protected Map<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 Map<ItemType,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,
Logger log)
Constructor. |
Method Summary | |
---|---|
protected void |
botKilled(BotKilled event)
|
protected String |
fixSemicolon(String text)
|
protected void |
flagInfo(FlagInfo event)
|
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. |
Map<ItemType.Category,Integer> |
getItemsByCategoryCollected()
How many items (per respective ItemType.Category ) your bot has collected so far. |
Map<ItemType,Integer> |
getItemsCollected()
How many items (per ItemType ) your bot has collected so far (in total). |
Map<UnrealId,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". |
Map<UnrealId,Integer> |
getKilledBy()
Who has killed your bot the most? |
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). |
File |
getOutputFile()
Actually used file for outputting of stats. |
protected File |
getOutputFile(String pathToFile,
boolean seekAlternatives)
Returns File for a given 'pathToFile'. |
String |
getOutputPath()
Returns the output path as supplied in startOutput(String) or startOutput(String, boolean) . |
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. |
Map<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. |
Map<ItemType,Double> |
getWeaponsUsedTime()
For how long your bot was using a certain weapon (in total). |
boolean |
isLogBeforeMatchRestart()
Should we log something before GameRestarted ? |
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()
|
void |
outputHeader(Formatter output)
Outputs stats headers into the 'output'. |
protected void |
outputStatLine(double time,
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(Formatter output,
double time,
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)
|
void |
startOutput(String pathToFile)
Starts or redirect logging to 'pathToFile'. |
void |
startOutput(String pathToFile,
boolean seekAlternatives)
Starts or redirect logging to 'pathToFile'. |
protected void |
stop()
|
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 Map<UnrealId,Integer> killed
protected Map<UnrealId,Integer> killedBy
protected Map<UnrealId,PlayerScore> playerScores
protected Map<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 Map<ItemType,Double> weaponsUsedTime
Shoot
command
has been effective for the bot.
protected Map<ItemType,Integer> itemsCollected
protected Map<ItemType.Category,Integer> itemsByCategoryCollected
ItemType.Category
the bot has collected.
protected int totalItemsCollected
protected int numberOfPlayersKilledWithoutDeath
protected int doubleDamageCount
protected double doubleDamageTime
protected Object statsMutex
protected String pathToOutput
protected File fileToOutput
protected 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, 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(Formatter output)
output
- public void outputStatLine(Formatter output, double time, String... eventOutput)
output
- eventOutput
- protected void outputStatLine(double time, String... eventOutput)
outputFile
is not null, was initialized by startOutput(String)
or startOutput(String, boolean)
).
eventOutput
- protected String fixSemicolon(String text)
public void resetStats()
getCurrentMatchTime()
(use resetMatchTime()
for that purpose separately).
public void resetMatchTime()
getCurrentMatchTime()
> 0).
public boolean isOutputting()
public String getOutputPath()
startOutput(String)
or startOutput(String, boolean)
.
For concretely used file for the output, use getOutputFile()
.
public File getOutputFile()
public void startOutput(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 File getOutputFile(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(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 Map<UnrealId,Integer> getKilled()
public Map<UnrealId,PlayerScore> getPlayerScores()
public Map<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 Map<ItemType,Double> getWeaponsUsedTime()
public Map<ItemType,Integer> getItemsCollected()
ItemType
) your bot has collected so far (in total).
public Map<ItemType.Category,Integer> getItemsByCategoryCollected()
ItemType.Category
) your bot has collected so far.
public int getTotalItemsCollected()
public int getNumberOfPlayersKilledWithoutDeath()
public int getDoubleDamageCount()
public double getDoubleDamageTime()
public Map<UnrealId,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 flagInfo(FlagInfo 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)
start
in class AgentModule<IObservingAgent>
protected void stop()
stop
in class AgentModule<IObservingAgent>
protected void kill()
kill
in class AgentModule<IObservingAgent>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |