|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.pogamut.Client.Agent
cz.cuni.pogamut.Client.BaseBot
public class BaseBot
This class is meant as an example for the user of Pogamut2 - it overrides the crucial methods and explains them (see the respective methods).
You may inherit this class (but that's no need to) or class cz.cuni.pogamut.Client.Agent (which is recommanded).
We recommand you to read the documentation of methods overriden by this class and then check out the Agent class.
This is commented template class - do not add any code here! If you wish to test stuff - change class TestBot or create your own.
========================================================================
Q: How it all works?
--------------------
The bot consists of two threads - Logic thread and Communication thread.
Communication thread is meant to communicate with Parser (which can be LOCAL - part of the agent or REMOTE - run as an independent application usualy at computer where UT2004 server is running).
Parser is parsing text messages from GameBots and translates them into java objects which are sent to communication thread. The communication thread is responsible for maintaining information about the world around the bot. For that - see cz.cuni.Client.GameMap / History / HistoryBatch / Agent, etc.
Before logic thread is started you must be sure, that you've bind a parser to the bot (well NetBeans plugin does that for you :-). Check out methods cz.cuni.Client.Agent-connectToLocalParser() / connectToRemoteParser().
When logic thread is started it does a few things:
Now you should have good picture about which method you need to override and what to place into them - checkout documentation inside those methods for more informations.
Check out the method main() code for tips on how to run the bot from your code.
Q: That's fine but I don't know how to work with the class at all!
------------------------------------------------------------------
You're right - we haven't explain where sensors and efetors of the agent are. And we won't do this here. Just check out Agent.memory (AgentMemory) and Agent.body (AgentBody). Those are class where you find sensors (AgentMemory, stuff like seeAnyEnemy(), etc.) and effectors (AgentBody, stuff like jump(), runTo(), etc.)
Field Summary | |
---|---|
protected java.lang.String |
botName
Name of the bot. |
Fields inherited from class cz.cuni.pogamut.Client.Agent |
---|
bindedParserType, body, flagLogicTemporalyStopped, gameBotConnection, gameMap, GARBAGE_COLLECTOR_FREQUENCY, instancesAlive, iterationEndListeners, log, logicFrequency, logicFrequencyChanged, memory, oldLogicFrequency, parserLogger, pauseHolders, platformLog, random, rawGBLog |
Constructor Summary | |
---|---|
BaseBot()
Constructor of the bot - here is place where you should initialize any variables you need to. |
Method Summary | |
---|---|
protected void |
doLogic()
doLogic() is repeatedly called by Agent while running() returns true. |
java.lang.String |
getBotName()
Returns bot name. |
static void |
main(java.lang.String[] Args)
This main() method is for 'learn by example' - it contains everything what is needed to run the agent - check to code. |
protected void |
postPrepareAgent()
Prepares logic according to information gathered from cz.cuni.pogamut.Client.Agent.startCommunication(). |
protected void |
prePrepareAgent()
Prepares agent logic to run - whings like initializing neural networks etc. |
void |
setBotName(java.lang.String newBotName)
Sets new name of the bot. |
protected void |
shutdownAgent()
This method is last to be called before disposing of the agent. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String botName
Constructor Detail |
---|
public BaseBot()
Method Detail |
---|
protected void doLogic()
doLogic
in class Agent
protected void prePrepareAgent()
prePrepareAgent
in class Agent
protected void postPrepareAgent()
postPrepareAgent
in class Agent
protected void shutdownAgent()
shutdownAgent
in class Agent
public static void main(java.lang.String[] Args)
public java.lang.String getBotName()
public void setBotName(java.lang.String newBotName)
newBotName
- new name of the bot
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |