public abstract class UT2004Match<CONFIG extends UT2004MatchConfig,RESULT extends UT2004MatchResult> extends Object implements Callable<RESULT>, Runnable
The class is sought to be inherited and its abstract method be additionally defined.
It also defines may handful methods that can be used to create required GameBots2004.ini file, start UCC, start all bots with observers / change their team / restart match.
| Modifier and Type | Class and Description |
|---|---|
static class |
UT2004Match.Bots |
| Modifier and Type | Field and Description |
|---|---|
protected CONFIG |
config
Configuration of the match, it contains all information that is needed to start the match.
|
protected Throwable |
exception |
protected cz.cuni.amis.pogamut.base.utils.logging.LogHandler |
fileHandler |
protected File |
gb2004FileBackup
Where we have backed up the GB2004.ini file...
|
protected cz.cuni.amis.pogamut.base.utils.logging.LogCategory |
log |
protected RESULT |
result |
protected boolean |
teamMatch |
protected File |
ut2004FileBackup
Where we have backed up the UT2004.ini file...
|
| Constructor and Description |
|---|
UT2004Match(boolean teamMatch,
CONFIG config,
cz.cuni.amis.pogamut.base.utils.logging.LogCategory log)
Construct the match with provided configuration.
|
| Modifier and Type | Method and Description |
|---|---|
RESULT |
call() |
void |
cleanUp()
WARNING: this method will delete the whole directory where results are stored!
|
protected void |
closeLogger()
Usually STEP 14 that close logging to file.
|
protected void |
copyReplay(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc,
String fileName,
File outputDirectory)
Optional (usually) STEP 11 ... moves replay file to desired directory.
|
protected void |
createGB2004Ini()
Usually STEP 2.2 ... it overwrites the GameBots2004.ini file that is present in UT2004 home.
|
protected void |
createUT2004Ini()
Usually STEP 2.2 ... it overwrites the GameBots2004.ini file that is present in UT2004 home.
|
protected abstract RESULT |
execute()
Performs the match and return the result (or throw an exception in case of error).
|
CONFIG |
getConfig()
Returns configuration of the match.
|
static String |
getCurrentDate()
May be used for file names.
|
Throwable |
getException()
If exception occures during the match execution, it is stored and made available through this method.
|
protected File |
getGB2004IniFile()
Returns file that is pointing to GameBots2004.ini that will be used by ucc.exe.
|
cz.cuni.amis.pogamut.base.utils.logging.LogCategory |
getLog()
Returns logger used for outputting stuff.
|
cz.cuni.amis.utils.token.IToken |
getMatchId()
Returns ID of the match.
|
File |
getOutputPath()
Parent path of all files that should be output by the class as results.
|
File |
getOutputPath(String relativePath)
Returns path relative to
getOutputPath(). |
RESULT |
getResult()
|
protected File |
getUccHome()
Returns file that is pointing to a directory that contains ucc.exe.
|
protected File |
getUT2004IniFile()
Returns file that is pointing to GameBots2004.ini that will be used by ucc.exe.
|
protected void |
changeBotTeam(cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId botId,
int desiredTeam) |
static boolean |
isHumanPlayer(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player player) |
boolean |
isTeamMatch()
Whether team / individuals are fighting in this match.
|
protected void |
matchIsAboutToBegin(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc,
cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
cz.cuni.amis.pogamut.ut2004.analyzer.UT2004Analyzer analyzer,
UT2004Match.Bots bots)
Optional (usually) STEP 7 ... set up any listeners needed.
|
protected abstract void |
outputResults(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc,
cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
cz.cuni.amis.pogamut.ut2004.analyzer.UT2004Analyzer analyzer,
UT2004Match.Bots bots,
UT2004MatchResult result,
File outputDirectory)
Usually STEP 12 ... concludes the match by producing/presenting whatever statistics needed about the match.
|
protected void |
recordReplay(cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
String fileName)
Optional (usually) STEP 9 ... begin recording UT2004 replay
|
protected void |
restartMatch(cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
UT2004Match.Bots bots)
Usually STEP 8 ... restarts the match (in order to reinitialize the environment and restart all bots).
|
void |
restoreGB2004IniBackup()
Usually STEP 10.2
Overwrites current GameBots2004.ini with GameBots2004.ini.backup that was created during
createGB2004Ini(). |
void |
restoreUT2004IniBackup()
Usually STEP 10.1
Overwrites current UT2004.ini with UT2004.ini.backup that was created during
createUT2004Ini(). |
void |
run()
Runs the match, its result is than available through
getResult(). |
protected void |
setupLogger()
Usually STEP 0 that set up logger to output to file.
|
protected void |
shutdownAll(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc,
cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
cz.cuni.amis.pogamut.ut2004.analyzer.UT2004Analyzer analyzer,
UT2004Match.Bots bots)
Usually STEP 13 ... shutdowns everything
|
protected cz.cuni.amis.pogamut.ut2004.analyzer.UT2004Analyzer |
startAnalyzer(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc,
UT2004Match.Bots bots,
File outputDirectory,
boolean humanLikeObserving)
Optional (usually) STEP 6 ... it is nice to collect some data about bots, that is done by the analyzer that automatically
observe any custom-bot.
|
protected UT2004Match.Bots |
startBots(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc,
cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server)
Usually STEP 5.1 ... starts all custom & native bots + changes their teams if needed.
|
protected cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server |
startControlServer(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc)
Usually STEP 4 ... after the UCC has started up, you usually want to connect to it to confirm it is up and running
and be able to observe any changes in the environment / alter the environment, etc.
|
protected cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper |
startUCC()
Usually STEP 3 ... it starts up the UCC, it is a blocking method that waits until UCC is up and running.
|
String |
toString() |
void |
validate()
Usually STEP 1 in match execution ... it validates the contents of
config. |
protected void |
waitHumanPlayers(cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
UT2004Match.Bots bots)
Usually STEP 5.2 ... wait till all human players gets connected to the game.
|
protected abstract UT2004MatchResult |
waitMatchFinish(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc,
cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
cz.cuni.amis.pogamut.ut2004.analyzer.UT2004Analyzer analyzer,
UT2004Match.Bots bots,
long timeoutInMillis)
Usually STEP 10 ... you wait for a predefined time (blocking method) for the match to finish.
|
protected CONFIG extends UT2004MatchConfig config
protected cz.cuni.amis.pogamut.base.utils.logging.LogCategory log
protected RESULT extends UT2004MatchResult result
protected Throwable exception
protected boolean teamMatch
protected cz.cuni.amis.pogamut.base.utils.logging.LogHandler fileHandler
protected File ut2004FileBackup
protected File gb2004FileBackup
public UT2004Match(boolean teamMatch,
CONFIG config,
cz.cuni.amis.pogamut.base.utils.logging.LogCategory log)
config - MUST NOT BE NULLpublic boolean isTeamMatch()
True == team match, False = match of individual bots.
public static boolean isHumanPlayer(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player player)
public RESULT getResult()
public Throwable getException()
public void run()
getResult().public RESULT call()
call in interface Callable<RESULT extends UT2004MatchResult>protected abstract RESULT execute()
public static String getCurrentDate()
public CONFIG getConfig()
public cz.cuni.amis.utils.token.IToken getMatchId()
public cz.cuni.amis.pogamut.base.utils.logging.LogCategory getLog()
public File getOutputPath()
public File getOutputPath(String relativePath)
getOutputPath().relativePath - protected void setupLogger()
public void validate()
config.
Raises exception in case of error.
As it is public, you may also use it prior the match execution by yourself to ensure that the match is correctly configured.
public void cleanUp()
protected File getUccHome()
protected File getUT2004IniFile()
protected File getGB2004IniFile()
protected void createUT2004Ini()
Raises exception in case of any error.
protected void createGB2004Ini()
Raises exception in case of any error.
protected cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper startUCC()
Raises exception in case of any error.
protected cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server startControlServer(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc)
This method may need to be override to provide custom implementation of UT2004Server interface, i.e.,
provide your custom control server. Current implementation is using UT2004Server.
Raises exception in case of any error.
If UT2004MatchConfig.isStartTCServer() it will start UT2004TCServer instead of plain UT2004Server.
ucc - MUST NOT BE NULLprotected void changeBotTeam(cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId botId,
int desiredTeam)
protected UT2004Match.Bots startBots(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc, cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server)
Raises exception in case of any error.
Note that the inner implementation is pretty complex... if you need to alter the method, copy-paste it and dig in.
ucc - MUST NOT BE NULLserver - MUST NOT BE NULLanalyzer - may be NULLprotected void waitHumanPlayers(cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
UT2004Match.Bots bots)
Raises exception in case of any error.
Note that the inner implementation is pretty complex... if you need to alter the method, copy-paste it and dig in.
server - MUST NOT BE NULLprotected cz.cuni.amis.pogamut.ut2004.analyzer.UT2004Analyzer startAnalyzer(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc,
UT2004Match.Bots bots,
File outputDirectory,
boolean humanLikeObserving)
This method may need to be override to provide custom implementation of UT2004Analyzer interface, i.e.,
provide your custom control server. Current implementation is using UT2004Analyzer.
Fills data UT2004Match.Bots.botObservers.
Raises exception in case of any error.
ucc - MUST NOT BE NULLbots - outputDirectory - where to output data about bots, MUST NOT BE NULLhumanLikeObserving - whether to produce output for "HumanLikeBot project" analysisprotected void matchIsAboutToBegin(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc,
cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
cz.cuni.amis.pogamut.ut2004.analyzer.UT2004Analyzer analyzer,
UT2004Match.Bots bots)
Current implementation is empty.
ucc - MUST NOT BE NULLserver - MUST NOT BE NULLanalyzer - may be nullbots - MUST NOT BE NULLprotected void restartMatch(cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
UT2004Match.Bots bots)
Blocks until the match is restarted.
Raises exception in case of any error.
server - MUST NOT BE NULLprotected void recordReplay(cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
String fileName)
server - fileName - protected abstract UT2004MatchResult waitMatchFinish(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc, cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server, cz.cuni.amis.pogamut.ut2004.analyzer.UT2004Analyzer analyzer, UT2004Match.Bots bots, long timeoutInMillis)
This method may need to be override to provide correct MATCH-FINISHED detecting routine.
Always abide the timeout!
Don't forget to observe whether all 'custom bots' are running! Use UT2004BotExecution.getRunning() flag and FlagListener.
Raises exception in case of any error / timeout
ucc - MUST NOT BE NULLserver - MUST NOT BE NULLanalyzer - may be nullbots - MUST NOT BE NULLtimeoutInMillis - must be specified correctlypublic void restoreUT2004IniBackup()
Overwrites current UT2004.ini with UT2004.ini.backup that was created during createUT2004Ini().
public void restoreGB2004IniBackup()
Overwrites current GameBots2004.ini with GameBots2004.ini.backup that was created during createGB2004Ini().
protected void copyReplay(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc,
String fileName,
File outputDirectory)
ucc - fileName - protected abstract void outputResults(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc,
cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
cz.cuni.amis.pogamut.ut2004.analyzer.UT2004Analyzer analyzer,
UT2004Match.Bots bots,
UT2004MatchResult result,
File outputDirectory)
Raises exception in case of any error / timeout
ucc - MUST NOT BE NULLserver - MUST NOT BE NULLanalyzer - may be nullbots - MUST NOT BE NULLresult - MUST NOT BE NULLoutputDirectory - MUST NOT BE NULLprotected void shutdownAll(cz.cuni.amis.pogamut.ut2004.utils.UCCWrapper ucc,
cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server server,
cz.cuni.amis.pogamut.ut2004.analyzer.UT2004Analyzer analyzer,
UT2004Match.Bots bots)
ucc - protected void closeLogger()
Copyright © 2019 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All rights reserved.