View Javadoc

1   package cz.cuni.amis.pogamut.ut2004.bot;
2   
3   import java.util.logging.Logger;
4   
5   import cz.cuni.amis.pogamut.base.communication.command.IAct;
6   import cz.cuni.amis.pogamut.base3d.worldview.IVisionWorldView;
7   import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
8   import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Initialize;
9   import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.PasswordReply;
10  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.BotKilled;
11  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange;
12  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo;
13  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage;
14  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Self;
15  
16  public interface IUT2004BotController<BOT extends UT2004Bot> {
17  	
18  	/**
19  	 * Returns user log of the controller.
20  	 * @return
21  	 */
22  	public Logger getLog();
23  	
24  	/**
25  	 * Returns underlying controlled {@link UT2004Bot} class that is managing life-cycle of the bot.
26  	 * @return
27  	 */
28  	public BOT getBot();
29  	
30  	/**
31  	 * Returns mean for sending commands through bot's GB2004 communication channel. 
32  	 * @return
33  	 */
34  	public IAct getAct();
35  	
36  	/**
37  	 * Returns world view of the controlled that providing access to all objects/events the bot has.
38  	 * @return
39  	 */
40  	public IVisionWorldView getWorldView();
41  	
42  	/**
43  	 * Called during the construction of the {@link UT2004Bot} before the GameBots2004 greets the bot even before
44  	 * {@link IUT2004BotController#prepareBot(UT2004Bot)} method.
45  	 * <p><p>
46  	 * <b>NOTE:</b> This is Pogamut's developers reserved method - do not override it and if you do, always use 'super' 
47  	 * to call parent's initializeController.
48       */
49  	public void initializeController(BOT bot);
50  	
51  	/**
52  	 * Called during the construction of the {@link UT2004Bot} before the GameBots2004 greets the bot.
53       */
54      public void prepareBot(BOT bot);
55  	
56  	
57  	/**
58  	 * Returns password that should be used to access the GameBots2004 server.
59  	 * <p><p>
60  	 * Called only if the bot is challenged by the password request.
61  	 * 
62  	 * @return
63  	 */
64  	public PasswordReply getPassword();
65  	
66      /**
67       * This method is called after handshake with GameBots2004 is over and the GameBots2004
68       * is awaiting the INIT command (Initialize class). Here you have to construct the
69       * Initialize message where you may specify many starting parameters of the bot including:
70       * <ul>
71       * <li>bot's name</li>
72       * <li>bot skill level (aim precision)</li>
73       * <li>bot skin</li>
74       * <li>raycasting</li>
75       * <li>etc. - for complete list see Initialize command</li>
76       * </ul>
77       * This message is then saved to private field initalizeCommand and is accessible
78       * via getInitializeCommand() method if required to probe the starting parameters (even though
79       * they can be changed during the bot's lifetime!).
80       */
81      public Initialize getInitializeCommand();
82  
83      /**
84       * This method is called whenever {@link InitedMessage} is received. Various agent modules are usable since this
85       * method is called.
86       * 
87       * @param gameInfo
88       * @param config
89       * @param init
90       * @param self
91       */
92      public void botInitialized(GameInfo gameInfo, ConfigChange currentConfig, InitedMessage init);
93      
94      /**
95       * This method is called only once whenever first batch of information what the bot can see is received.
96       * <i><i>
97       * It is sort of "first-logic-method" where you may issue commands for the first time and handle everything
98       * else in bot's logic then. It eliminates the need to have 'boolean firstLogic' field inside your bot.
99       * <p><p>
100      * Note that this method has advantage over the {@link IUT2004BotController#botInitialized(GameInfo, ConfigChange, InitedMessage)}
101      * that you already have {@link Self} object.
102      * 
103      * @param gameInfo
104      * @param config
105      * @param init
106      * @param self
107      */
108     public void botFirstSpawn(GameInfo gameInfo, ConfigChange currentConfig, InitedMessage init, Self self);
109     
110     /**
111 	 * Called after {@link IUT2004BotController#botFirstSpawn(GameInfo, ConfigChange, InitedMessage, Self)} as a hook for Pogamut's core developers
112 	 * to finalize initialization of various modules.
113 	 * <p><p>
114 	 * <b>NOTE:</b> This is Pogamut's developers reserved method - do not override it and if you do, always use 'super' 
115 	 * to call parent's finishControllerInitialization.
116      */
117 	public void finishControllerInitialization();
118     
119     /**
120      * Called whenever the bot gets killed inside the game.
121      * 
122      * @param event
123      */
124     public void botKilled(BotKilled event);
125     
126     /**
127      * Called whenever the bot is shutdown (has finished) or killed (not in the game but as the instance).
128      * <p><p>
129      * Use the method to save your work / data collected during the run of the agent.
130      * <p><p>
131      * Pogamut's guarantee that this method is called even if exception happens inside your previous code.
132      */
133     public void botShutdown();
134 
135 }