cz.cuni.pogamut.server
Class UTServer

java.lang.Object
  extended by cz.cuni.pogamut.server.UTServer
All Implemented Interfaces:
UTServerConnectionInterface, UTWorld, FlagListener, java.io.Serializable, java.util.EventListener

public class UTServer
extends java.lang.Object
implements UTWorld, java.io.Serializable, FlagListener, UTServerConnectionInterface

Representation of the UTServer, runs it own thread and manages CONNECTION / RECONNECTION / KEEP ALIVE / COMMUNICATION Work of the thread is based on requests that are stored in the queue and executed accordinaly. This way whole communication with the server is synchronized.

See Also:
Serialized Form

Field Summary
private  java.util.Set<BotEnteredWorldListener> botEnteredWorldListeners
           
private  java.util.Set<BotLeftWorldListener> botLeftWorldListeners
           
private  UTServerConnection connection
          ServerConnection object that manage the connection to GB and process the requests.
protected  GameBotConnection gbConn
           
protected  java.net.Socket gbSocket
           
protected  UTServerInfoSnapshot info
          This contains all the informations about the server.
private  java.util.logging.Logger log
          Logger for the class, used also by UTServerConnection.
private  java.util.logging.Logger rawGBLog
          Logger for the GB raw data.
protected  java.util.concurrent.CountDownLatch waitInventory
           
protected  java.util.concurrent.CountDownLatch waitItems
           
protected  java.util.concurrent.CountDownLatch waitMaps
           
protected  java.util.concurrent.CountDownLatch waitNavPoints
           
protected  java.util.concurrent.CountDownLatch waitRefreshInfo
           
protected  java.io.PrintWriter writer
           
 
Constructor Summary
UTServer()
          Used for loading the agent classes from projects directories.
 
Method Summary
 void addBotEnteredWorldListener(BotEnteredWorldListener listener)
          Add listener to the bot-enetered-the-world event.
 void addBotLeftWorldListener(BotLeftWorldListener listener)
          Add listener to the bot-left-the-world event.
 void addInventory(java.lang.String botUnrealId, java.lang.String inventoryClass)
          Adds the item to the bot's inventory.
 void addRcvMsgListener(RcvMsgListener listener)
          Add listener that will be notified when a new message from Server Control will arrive.
 void botAutoTrace(java.lang.String botUnrealId, boolean autoTrace)
          TODO: comment
 void botDrawTraceLines(java.lang.String botUnrealId, boolean drawTraceLines)
           
 void botInvulnerable(java.lang.String botUnrealId, boolean invulnerable)
          According to param 'invulnerable' sets (or retract) the invulnerability of the specified bot.
 void botManualSpawn(java.lang.String botUnrealId, boolean manualSpawn)
          TODO: comment
 void botShowDebug(java.lang.String botUnrealId, boolean showDebug)
           
 void botShowFocalPoint(java.lang.String botUnrealId, boolean showFocalPoint)
           
 void botSynchronousOff(java.lang.String botUnrealId, boolean synchronousOff)
           
 void connect()
          Connects the server if communication is down with URI specified through setServerURI().
 java.lang.String connectBot(Agent newBot)
          Connects bot to the server.
 java.lang.String connectBot(Agent newBot, ParserType parserType)
           
 java.lang.String connectBot(Agent bot, java.lang.String botName)
          Connects bot to the server.
 void connectBot(Agent bot, java.lang.String botName, ParserType parserType)
          Connects bot to the server with given type of parser.
 void connectOriginalBot(java.lang.String name, Triple location, int difficultyLevel, int team)
          Connects a native UT bot.
static UTServer createLocalhostServer()
           
 void disconnect()
          Disconnect the server connection + stops the communication thread.
 void disconnectAllBots()
          Disconnect all bots from server.
 void disconnectBot(Agent bot)
          Disconnect bot from UT server
 void disconnectBot(java.lang.String botUnrealId)
          Disconnects bot from this server.
 void finalize()
           
 void flagChanged(java.lang.Object changedValue, int listenerParam)
          When registering the flag you may additionally specify listener parameter, if you do so - your listener will be called with that parameter.
 java.util.Collection<Player> getAllBots()
          Returns list of players inside the world.
 boolean getAutomaticallyReconnect()
           
 int getAutoReconnectMillis()
           
 java.util.Collection<UTMap> getAvailableMaps()
          Can return NULL -> means communication with GB is DOWN ...
 java.util.Collection<Agent> getConnectedBots()
          List of bots connected to server through this UTServer instance.
 UTServerConnection getConnection()
           
 java.util.Collection<Agent> getDisconnectedBots()
          Returns collection of all TERMINATED or FAILed bots.
 MessageType getExpectedWelcomeMessage()
          Which message we should expect as the greeting from GameBots?
 java.net.URI getGamebotsBotsURI()
           
 java.net.URI getGamebotsControlConnectionURI()
           
 GameInfo getGameInfo()
           
protected  GameBotConnection getGBConnection()
           
 UTServerInfoSnapshot getInfo()
          Must NOT return null !!!
 java.util.Map<java.lang.String,Item> getInventory()
           
 java.util.Collection<Item> getItems()
          May return NULL -> means communication with GB is DOWN ...
 java.util.logging.Logger getLog()
           
 java.lang.String getMap()
          Returns name of the map which is loaded into UT2004.
 java.lang.String getName()
          Returns human readable name of the server.
 java.util.Collection<NavPoint> getNavPoints()
          May return NULL -> means communication with GB is DOWN ...
 boolean getPingPong()
           
 java.util.Set<Player> getPlayers()
           
 int getPongTimeoutMillis()
           
private  ParserType getPreferredParserType()
          Returns preferred parser type for bots connecting <-> server communication.
 java.util.logging.Logger getRawGBLog()
          Which log should be used to dump raw GB data.
 java.net.URI getServerRemoteParserURI()
           
 UTServerState getServerState()
          Tells the server state ... e.g. running / initializing, etc.
 Flag<UTServerState> getServerStateFlag()
          Flag of the server state, you may hook up the listener on it...
 UTServerInfoSnapshot getSnapshot()
           
 java.util.concurrent.CountDownLatch getWaitInventoryLatch()
           
 java.util.concurrent.CountDownLatch getWaitItemsLatch()
           
 java.util.concurrent.CountDownLatch getWaitMapsLatch()
           
 java.util.concurrent.CountDownLatch getWaitNavPointsLatch()
           
 java.util.concurrent.CountDownLatch getWaitRefreshInfoLatch()
           
 void changeAttribute(java.lang.String botUnrealId, java.lang.String attribute, java.lang.String value)
          Changes the bot's attribute value to a specified value.
protected  void init()
          Called from constructor or from readObject().
 boolean isAutomaticallyReconnect()
          Whether we should automaticly try to reconnect.
 boolean isConnectionAlive()
          HERE BEGINS IMPLEMENTATION OF UTWORLD INTERFACE ******
 boolean isPingPong()
          Whether we should check whether the connection is active.
 boolean isServerOpened()
          Does this server allow connection of new bots?
 void kickBot(java.lang.String botUnrealId)
          Kick bot from the game.
 Agent loadAgent(java.lang.String fullyClassifiedClassName)
          TODO redundant?
 java.lang.Class loadAgentClass(java.lang.String fullyClassifiedClassName)
          TODO redundant?
static void main(java.lang.String[] args)
           
 void pause(boolean completely)
          Pause the world.
private  void readObject(java.io.ObjectInputStream in)
          Deserialization...
 void reconnect()
          Issue reconnect request.
 boolean refreshInformations()
          Requests and waits for refreshing the informations about the server.
 void removeAllBots()
          Remove all bots from list of bots.
 void removeBot(Agent bot)
          Remove bot from list of bots.
 void removeBotEnteredWorldListener(BotEnteredWorldListener listener)
          Remove listener to the bot-enetered-the-world event.
protected  void removeBotInner(Agent bot)
           
 void removeBotLeftWorldListener(BotLeftWorldListener listener)
          Remove listener to the bot-left-the-world event.
 java.util.Collection<Agent> removeDisconnectedBots()
          Remove all disconnected bots from list of bots.
 void removeRcvMsgListener(RcvMsgListener listener)
          Remove listener that listens for messages from server control.
 boolean request(UTServerRequest request)
          This method is synchronized (later on in the body)!
 void respawnBot(java.lang.String botUnrealId)
          Respawns specified bot at random place.
 void respawnBot(java.lang.String botUnrealId, Triple location)
          Respawns specified bot at specified location.
 void resume()
          Resume the world;
 void sendToGB(java.lang.String msg)
           
 void setAutomaticallyReconnect(boolean automaticallyReconnect)
           
 void setAutoReconnectMillis(int autoReconnectMillis)
           
 void setBotName(java.lang.String botUnrealId, java.lang.String name)
          TODO: comment
 void setConnection(UTServerConnection connection)
           
 void setGamebotsBotURI(java.net.URI serverURI)
           
 void setGamebotsControlConnectionURI(java.net.URI serverURI)
           
 void setGameInfo(GameInfo info)
          DO NOT USED OUTSIDE THE UTServerConnection !!!
 void setGameSpeed(double speed)
          Speed is from 0.1 to 40. 1 is normal game speed.
 boolean setMap(java.lang.String name)
          Sets the map of the UT2004, NO BLOCK
 boolean setMapAndWait(java.lang.String name)
          Will send command to change the map IFF it's not the one that is currently running.
 void setName(java.lang.String name)
          Sets the name of the server.
 void setPingPong(boolean pingPong)
           
 void setPongTimeoutMillis(int pongTimeoutMillis)
           
 void setServerOpened(boolean opened)
          Open or close server for new bots.
 void setServerRemoteParserURI(java.net.URI serverURI)
           
 void setVisionTime(double visionTime)
          Set vision time... whatever it is.
 void startRecording(java.lang.String fileName)
          Starts recording of the "replay" to a specified file at server.
 void stopRecording()
          Stops recording of the "replay".
 void terminate()
          Requests termination of the server.
 java.lang.String toString()
          Returns name of the server in format "name (uri)".
 boolean waitForCommunication()
          Checks whether communication is OK, if not, issue reconnect() and waits for communication
 boolean waitForNFOMessageInHandshake()
          Whether we should wait for NFO message after READY is sent.
private  void writeObject(java.io.ObjectOutputStream out)
          Serialization...
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private transient java.util.logging.Logger log
Logger for the class, used also by UTServerConnection.


rawGBLog

private transient java.util.logging.Logger rawGBLog
Logger for the GB raw data.


connection

private transient UTServerConnection connection
ServerConnection object that manage the connection to GB and process the requests. Everything goes through there, it also alters informations in this object.


botEnteredWorldListeners

private transient java.util.Set<BotEnteredWorldListener> botEnteredWorldListeners

botLeftWorldListeners

private transient java.util.Set<BotLeftWorldListener> botLeftWorldListeners

info

protected UTServerInfoSnapshot info
This contains all the informations about the server. We have it in one class because you make call snapshot() that will return it's clone.


waitNavPoints

protected transient java.util.concurrent.CountDownLatch waitNavPoints

waitItems

protected transient java.util.concurrent.CountDownLatch waitItems

waitMaps

protected transient java.util.concurrent.CountDownLatch waitMaps

waitRefreshInfo

protected transient java.util.concurrent.CountDownLatch waitRefreshInfo

waitInventory

protected transient java.util.concurrent.CountDownLatch waitInventory

gbConn

protected GameBotConnection gbConn

gbSocket

protected java.net.Socket gbSocket

writer

protected java.io.PrintWriter writer
Constructor Detail

UTServer

public UTServer()
Used for loading the agent classes from projects directories.

Method Detail

createLocalhostServer

public static UTServer createLocalhostServer()

init

protected void init()
Called from constructor or from readObject(). Initialize the object + starting the UTServerConnection


connect

public void connect()
Connects the server if communication is down with URI specified through setServerURI().


disconnect

public void disconnect()
Disconnect the server connection + stops the communication thread.


toString

public java.lang.String toString()
Returns name of the server in format "name (uri)".

Overrides:
toString in class java.lang.Object
Returns:
name of the server

readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Deserialization...

Parameters:
in -
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeObject

private void writeObject(java.io.ObjectOutputStream out)
                  throws java.io.IOException
Serialization...

Parameters:
out -
Throws:
java.io.IOException

request

public boolean request(UTServerRequest request)
This method is synchronized (later on in the body)! This is only way how to add request to the queue of requests (for UTServerConnection object), USE ONLY THIS EVEN INSIDE THIS CLASS FOR ADDING REQUESTS!

Parameters:
request -
Returns:
success

getServerStateFlag

public Flag<UTServerState> getServerStateFlag()
Flag of the server state, you may hook up the listener on it...

Specified by:
getServerStateFlag in interface UTServerConnectionInterface
Specified by:
getServerStateFlag in interface UTWorld
Returns:

getServerState

public UTServerState getServerState()
Tells the server state ... e.g. running / initializing, etc.

Specified by:
getServerState in interface UTServerConnectionInterface
Returns:

isAutomaticallyReconnect

public boolean isAutomaticallyReconnect()
Description copied from interface: UTServerConnectionInterface
Whether we should automaticly try to reconnect.

Specified by:
isAutomaticallyReconnect in interface UTServerConnectionInterface

setAutomaticallyReconnect

public void setAutomaticallyReconnect(boolean automaticallyReconnect)

getAutomaticallyReconnect

public boolean getAutomaticallyReconnect()

getConnection

public UTServerConnection getConnection()

setConnection

public void setConnection(UTServerConnection connection)

isPingPong

public boolean isPingPong()
Description copied from interface: UTServerConnectionInterface
Whether we should check whether the connection is active.

Specified by:
isPingPong in interface UTServerConnectionInterface

setPingPong

public void setPingPong(boolean pingPong)

getPingPong

public boolean getPingPong()

getPongTimeoutMillis

public int getPongTimeoutMillis()
Specified by:
getPongTimeoutMillis in interface UTServerConnectionInterface

setPongTimeoutMillis

public void setPongTimeoutMillis(int pongTimeoutMillis)

getLog

public java.util.logging.Logger getLog()
Specified by:
getLog in interface UTServerConnectionInterface

getGamebotsControlConnectionURI

public java.net.URI getGamebotsControlConnectionURI()
Specified by:
getGamebotsControlConnectionURI in interface UTServerConnectionInterface

getGamebotsBotsURI

public java.net.URI getGamebotsBotsURI()

setGamebotsControlConnectionURI

public void setGamebotsControlConnectionURI(java.net.URI serverURI)

setGamebotsBotURI

public void setGamebotsBotURI(java.net.URI serverURI)

setServerRemoteParserURI

public void setServerRemoteParserURI(java.net.URI serverURI)

getServerRemoteParserURI

public java.net.URI getServerRemoteParserURI()

getAutoReconnectMillis

public int getAutoReconnectMillis()
Specified by:
getAutoReconnectMillis in interface UTServerConnectionInterface

setAutoReconnectMillis

public void setAutoReconnectMillis(int autoReconnectMillis)

getRawGBLog

public java.util.logging.Logger getRawGBLog()
Description copied from interface: UTServerConnectionInterface
Which log should be used to dump raw GB data.

Specified by:
getRawGBLog in interface UTServerConnectionInterface

getGameInfo

public GameInfo getGameInfo()
Specified by:
getGameInfo in interface UTServerConnectionInterface

setGameInfo

public void setGameInfo(GameInfo info)
DO NOT USED OUTSIDE THE UTServerConnection !!! Part of the UTServerConnectionInterface This can't change the server URI or any info inside the GameInfo object won't have effect on anything. (Actualy it may does but always in the wrong way!)

Specified by:
setGameInfo in interface UTServerConnectionInterface

flagChanged

public void flagChanged(java.lang.Object changedValue,
                        int listenerParam)
Description copied from interface: FlagListener
When registering the flag you may additionally specify listener parameter, if you do so - your listener will be called with that parameter. Note that we purposefully denying OOP paradigm here. 'listenerParam' will allow you to implement this interface only once for more flags at the cost of switch(listenerParam){} ... but imagine that you have 4 objects which all register 4 different flag listeners (it would be a bit messy, wouldn't it).

Specified by:
flagChanged in interface FlagListener

terminate

public void terminate()
Requests termination of the server. The server will be unusable after that.


finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

refreshInformations

public boolean refreshInformations()
Requests and waits for refreshing the informations about the server.

Returns:

reconnect

public void reconnect()
Issue reconnect request. WON'T WAIT FOR ANYTHING, if you need to reconnect AND wait for communication to set up, use waitForCommunication().


waitForCommunication

public boolean waitForCommunication()
Checks whether communication is OK, if not, issue reconnect() and waits for communication


getPlayers

public java.util.Set<Player> getPlayers()

addRcvMsgListener

public void addRcvMsgListener(RcvMsgListener listener)
Add listener that will be notified when a new message from Server Control will arrive. Beware, that the thread that calls the listeners is the very same thread that recieves the messages from Parser, so you cant recieve more messages, unless you return control.


removeRcvMsgListener

public void removeRcvMsgListener(RcvMsgListener listener)
Remove listener that listens for messages from server control.


getSnapshot

public UTServerInfoSnapshot getSnapshot()

isServerOpened

public boolean isServerOpened()
Does this server allow connection of new bots? It isn't necesarry to check this flag. It is just polite to do so.


setServerOpened

public void setServerOpened(boolean opened)
Open or close server for new bots.


setName

public void setName(java.lang.String name)
Sets the name of the server.

Parameters:
name - New name.

isConnectionAlive

public boolean isConnectionAlive()
HERE BEGINS IMPLEMENTATION OF UTWORLD INTERFACE ******

Specified by:
isConnectionAlive in interface UTWorld
Returns:
connection is alive

getName

public java.lang.String getName()
Returns human readable name of the server.

Specified by:
getName in interface UTWorld
Returns:
Name of the server.

getMap

public java.lang.String getMap()
Returns name of the map which is loaded into UT2004.

Specified by:
getMap in interface UTWorld
Returns:
String name of the map

setMap

public boolean setMap(java.lang.String name)
               throws PogamutException
Description copied from interface: UTWorld
Sets the map of the UT2004, NO BLOCK

Specified by:
setMap in interface UTWorld
Returns:
true if succeeded
Throws:
PogamutException

setMapAndWait

public boolean setMapAndWait(java.lang.String name)
                      throws PogamutException
Description copied from interface: UTWorld
Will send command to change the map IFF it's not the one that is currently running. After that it will take care not to connect to the server with the same map again. Block until connection to server with specified map name is made or until it fails to change the map.

Specified by:
setMapAndWait in interface UTWorld
Throws:
PogamutException

getAvailableMaps

public java.util.Collection<UTMap> getAvailableMaps()
Can return NULL -> means communication with GB is DOWN ... First call of this method may block as we need to obtain maps from the server, next calls are non-blocking.

Specified by:
getAvailableMaps in interface UTWorld
Returns:
available maps names

getNavPoints

public java.util.Collection<NavPoint> getNavPoints()
                                            throws PogamutException
May return NULL -> means communication with GB is DOWN ... First call of this method may block as we need to obtain navpoints from the server, next calls are non-blocking.

Specified by:
getNavPoints in interface UTWorld
Returns:
list of all navpoints in the world
Throws:
PogamutException

getItems

public java.util.Collection<Item> getItems()
May return NULL -> means communication with GB is DOWN ... First call of this method may block as we need to obtain items from the server, next calls are non-blocking.

Specified by:
getItems in interface UTWorld
Returns:
list of items, which are present in the world

getInventory

public java.util.Map<java.lang.String,Item> getInventory()
Specified by:
getInventory in interface UTWorld
Returns:
list of items that can be added to the bot's inventory

getAllBots

public java.util.Collection<Player> getAllBots()
                                        throws PogamutException
Description copied from interface: UTWorld
Returns list of players inside the world. Probably will take some time to resolve as it needs to do the round trip between the class and GameBots (UT2004).

Specified by:
getAllBots in interface UTWorld
Returns:
list of players in the game
Throws:
PogamutException

getConnectedBots

public java.util.Collection<Agent> getConnectedBots()
List of bots connected to server through this UTServer instance.

Specified by:
getConnectedBots in interface UTWorld
Returns:
List of connected bots.

connectBot

public java.lang.String connectBot(Agent newBot)
                            throws PogamutException
Connects bot to the server. The type of used parser depends on the value of key "PreferredParserType" in cz.cuni.pogamut.Client.Agent.class properties node. TODO: may be it should return Thread (bot's thread) for additional manipulation

Specified by:
connectBot in interface UTWorld
Parameters:
bot - Bot to be connected.
Returns:
name of the bot inside UT2004
Throws:
PogamutException

connectBot

public java.lang.String connectBot(Agent newBot,
                                   ParserType parserType)
                            throws PogamutException
Parameters:
newBot -
parserType -
Returns:
name of the bot inside UT2004
Throws:
PogamutException

connectBot

public java.lang.String connectBot(Agent bot,
                                   java.lang.String botName)
                            throws PogamutException
Connects bot to the server. The type of used parser depends on the value of key "PreferredParserType" in cz.cuni.pogamut.Client.Agent.class properties node.

Specified by:
connectBot in interface UTWorld
Parameters:
bot - Bot to be connected.
Returns:
name of the bot inside UT2004
Throws:
PogamutException

getPreferredParserType

private ParserType getPreferredParserType()
Returns preferred parser type for bots connecting <-> server communication.


connectBot

public void connectBot(Agent bot,
                       java.lang.String botName,
                       ParserType parserType)
                throws PogamutException
Connects bot to the server with given type of parser. If remote parser connection fails then try to connect using local parser. TODO: may be it should return Thread (bot's thread) for additional manipulation

Parameters:
bot - Bot to be connected.
Throws:
PogamutException

connectOriginalBot

public void connectOriginalBot(java.lang.String name,
                               Triple location,
                               int difficultyLevel,
                               int team)
                        throws PogamutException
Connects a native UT bot.

Specified by:
connectOriginalBot in interface UTWorld
Parameters:
name - identificator of the bot class inside UT
Throws:
PogamutException

respawnBot

public void respawnBot(java.lang.String botUnrealId)
                throws PogamutException
Description copied from interface: UTWorld
Respawns specified bot at random place.

Specified by:
respawnBot in interface UTWorld
Throws:
PogamutException

respawnBot

public void respawnBot(java.lang.String botUnrealId,
                       Triple location)
                throws PogamutException
Description copied from interface: UTWorld
Respawns specified bot at specified location.

Specified by:
respawnBot in interface UTWorld
Throws:
PogamutException

kickBot

public void kickBot(java.lang.String botUnrealId)
             throws PogamutException
Kick bot from the game.

Specified by:
kickBot in interface UTWorld
Parameters:
botUnrealId - Id of bot we want to kick from the game
Throws:
PogamutException

disconnectBot

public void disconnectBot(java.lang.String botUnrealId)
Disconnects bot from this server.

Specified by:
disconnectBot in interface UTWorld
Parameters:
botUnrealId - A bot to be disconnected.

disconnectAllBots

public void disconnectAllBots()
Disconnect all bots from server.

Specified by:
disconnectAllBots in interface UTWorld

pause

public void pause(boolean completely)
           throws PogamutException
Description copied from interface: UTWorld
Pause the world. Completely == true ... pause the spectator as well.

Specified by:
pause in interface UTWorld
Throws:
PogamutException

resume

public void resume()
            throws PogamutException
Description copied from interface: UTWorld
Resume the world;

Specified by:
resume in interface UTWorld
Throws:
PogamutException

addInventory

public void addInventory(java.lang.String botUnrealId,
                         java.lang.String inventoryClass)
                  throws PogamutException
Description copied from interface: UTWorld
Adds the item to the bot's inventory.

Specified by:
addInventory in interface UTWorld
Throws:
PogamutException

changeAttribute

public void changeAttribute(java.lang.String botUnrealId,
                            java.lang.String attribute,
                            java.lang.String value)
                     throws PogamutException
Description copied from interface: UTWorld
Changes the bot's attribute value to a specified value.

Specified by:
changeAttribute in interface UTWorld
Throws:
PogamutException

botInvulnerable

public void botInvulnerable(java.lang.String botUnrealId,
                            boolean invulnerable)
                     throws PogamutException
Description copied from interface: UTWorld
According to param 'invulnerable' sets (or retract) the invulnerability of the specified bot.

Specified by:
botInvulnerable in interface UTWorld
Throws:
PogamutException

botAutoTrace

public void botAutoTrace(java.lang.String botUnrealId,
                         boolean autoTrace)
                  throws PogamutException
Description copied from interface: UTWorld
TODO: comment

Specified by:
botAutoTrace in interface UTWorld
Throws:
PogamutException

botManualSpawn

public void botManualSpawn(java.lang.String botUnrealId,
                           boolean manualSpawn)
                    throws PogamutException
Description copied from interface: UTWorld
TODO: comment

Specified by:
botManualSpawn in interface UTWorld
Throws:
PogamutException

botShowDebug

public void botShowDebug(java.lang.String botUnrealId,
                         boolean showDebug)
                  throws PogamutException
Throws:
PogamutException

botShowFocalPoint

public void botShowFocalPoint(java.lang.String botUnrealId,
                              boolean showFocalPoint)
                       throws PogamutException
Throws:
PogamutException

botDrawTraceLines

public void botDrawTraceLines(java.lang.String botUnrealId,
                              boolean drawTraceLines)
                       throws PogamutException
Throws:
PogamutException

botSynchronousOff

public void botSynchronousOff(java.lang.String botUnrealId,
                              boolean synchronousOff)
                       throws PogamutException
Throws:
PogamutException

setBotName

public void setBotName(java.lang.String botUnrealId,
                       java.lang.String name)
                throws PogamutException
Description copied from interface: UTWorld
TODO: comment

Specified by:
setBotName in interface UTWorld
Throws:
PogamutException

setVisionTime

public void setVisionTime(double visionTime)
                   throws PogamutException
Description copied from interface: UTWorld
Set vision time... whatever it is.

Specified by:
setVisionTime in interface UTWorld
Throws:
PogamutException

setGameSpeed

public void setGameSpeed(double speed)
                  throws PogamutException
Speed is from 0.1 to 40. 1 is normal game speed.

Specified by:
setGameSpeed in interface UTWorld
Throws:
PogamutException

startRecording

public void startRecording(java.lang.String fileName)
                    throws PogamutException
Description copied from interface: UTWorld
Starts recording of the "replay" to a specified file at server.

Specified by:
startRecording in interface UTWorld
Throws:
PogamutException

stopRecording

public void stopRecording()
                   throws PogamutException
Description copied from interface: UTWorld
Stops recording of the "replay".

Specified by:
stopRecording in interface UTWorld
Throws:
PogamutException

addBotEnteredWorldListener

public void addBotEnteredWorldListener(BotEnteredWorldListener listener)
Description copied from interface: UTWorld
Add listener to the bot-enetered-the-world event.

Specified by:
addBotEnteredWorldListener in interface UTWorld

removeBotEnteredWorldListener

public void removeBotEnteredWorldListener(BotEnteredWorldListener listener)
Description copied from interface: UTWorld
Remove listener to the bot-enetered-the-world event.

Specified by:
removeBotEnteredWorldListener in interface UTWorld

addBotLeftWorldListener

public void addBotLeftWorldListener(BotLeftWorldListener listener)
Description copied from interface: UTWorld
Add listener to the bot-left-the-world event.

Specified by:
addBotLeftWorldListener in interface UTWorld

removeBotLeftWorldListener

public void removeBotLeftWorldListener(BotLeftWorldListener listener)
Description copied from interface: UTWorld
Remove listener to the bot-left-the-world event.

Specified by:
removeBotLeftWorldListener in interface UTWorld

disconnectBot

public void disconnectBot(Agent bot)
Disconnect bot from UT server

Specified by:
disconnectBot in interface UTWorld

removeBot

public void removeBot(Agent bot)
Remove bot from list of bots. Commonly used after disconnectBot. If the bot was still connected then dicsonnect him.

Do not overload this class, better overload removeBotInner()


removeBotInner

protected void removeBotInner(Agent bot)

removeAllBots

public void removeAllBots()
Remove all bots from list of bots. Commonly used after disconnectBot


removeDisconnectedBots

public java.util.Collection<Agent> removeDisconnectedBots()
Remove all disconnected bots from list of bots.

Returns:
List of disconnected bots

getDisconnectedBots

public java.util.Collection<Agent> getDisconnectedBots()
Returns collection of all TERMINATED or FAILed bots.


getInfo

public UTServerInfoSnapshot getInfo()
Description copied from interface: UTServerConnectionInterface
Must NOT return null !!! We're synchronizing access to info through this object.

Specified by:
getInfo in interface UTServerConnectionInterface
Returns:

getWaitNavPointsLatch

public java.util.concurrent.CountDownLatch getWaitNavPointsLatch()
Specified by:
getWaitNavPointsLatch in interface UTServerConnectionInterface

getWaitItemsLatch

public java.util.concurrent.CountDownLatch getWaitItemsLatch()
Specified by:
getWaitItemsLatch in interface UTServerConnectionInterface

getWaitMapsLatch

public java.util.concurrent.CountDownLatch getWaitMapsLatch()
Specified by:
getWaitMapsLatch in interface UTServerConnectionInterface

getWaitInventoryLatch

public java.util.concurrent.CountDownLatch getWaitInventoryLatch()
Specified by:
getWaitInventoryLatch in interface UTServerConnectionInterface

getWaitRefreshInfoLatch

public java.util.concurrent.CountDownLatch getWaitRefreshInfoLatch()
Specified by:
getWaitRefreshInfoLatch in interface UTServerConnectionInterface

getExpectedWelcomeMessage

public MessageType getExpectedWelcomeMessage()
Description copied from interface: UTServerConnectionInterface
Which message we should expect as the greeting from GameBots?

Specified by:
getExpectedWelcomeMessage in interface UTServerConnectionInterface

waitForNFOMessageInHandshake

public boolean waitForNFOMessageInHandshake()
Description copied from interface: UTServerConnectionInterface
Whether we should wait for NFO message after READY is sent.

Specified by:
waitForNFOMessageInHandshake in interface UTServerConnectionInterface
Returns:

loadAgentClass

public java.lang.Class loadAgentClass(java.lang.String fullyClassifiedClassName)
                               throws PogamutException
TODO redundant? Returns class of the required agent - special class loader is used.

Specified by:
loadAgentClass in interface UTWorld
Parameters:
fullyClassifiedName - e.g. hunter.Main
Returns:
Class of the agent
Throws:
PogamutException - usualy class not found exception

loadAgent

public Agent loadAgent(java.lang.String fullyClassifiedClassName)
                throws PogamutException
TODO redundant? see loadBotFrom* Loads and instantiate a new agent object. You would probably want to call utWorld.connectBot(newAgentInstance) afterwards.

Specified by:
loadAgent in interface UTWorld
Parameters:
fullyClassifiedName - e.g. hunter.Main
Returns:
Agent instantiated agent
Throws:
PogamutException - usualy class not found exception

getGBConnection

protected GameBotConnection getGBConnection()
                                     throws java.net.UnknownHostException,
                                            ConnectException
Throws:
java.net.UnknownHostException
ConnectException

sendToGB

public void sendToGB(java.lang.String msg)
              throws java.io.IOException,
                     CantWriteException,
                     ConnectException
Throws:
java.io.IOException
CantWriteException
ConnectException

main

public static void main(java.lang.String[] args)