View Javadoc

1   package cz.cuni.amis.pogamut.sposh.context;
2   
3   import java.util.Random;
4   import java.util.logging.Level;
5   
6   import cz.cuni.amis.pathfinding.map.IPFMapView;
7   import cz.cuni.amis.pogamut.base.agent.navigation.IPathPlanner;
8   import cz.cuni.amis.pogamut.base.communication.command.IAct;
9   import cz.cuni.amis.pogamut.base.communication.worldview.IWorldView;
10  import cz.cuni.amis.pogamut.base.communication.worldview.listener.annotation.AnnotationListenerRegistrator;
11  import cz.cuni.amis.pogamut.base.communication.worldview.listener.annotation.EventListener;
12  import cz.cuni.amis.pogamut.base.communication.worldview.listener.annotation.ObjectClassEventListener;
13  import cz.cuni.amis.pogamut.base.communication.worldview.listener.annotation.ObjectClassListener;
14  import cz.cuni.amis.pogamut.base.communication.worldview.listener.annotation.ObjectEventListener;
15  import cz.cuni.amis.pogamut.base.communication.worldview.listener.annotation.ObjectListener;
16  import cz.cuni.amis.pogamut.base.utils.logging.LogCategory;
17  import cz.cuni.amis.pogamut.base.utils.math.DistanceUtils;
18  import cz.cuni.amis.pogamut.base3d.worldview.IVisionWorldView;
19  import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated;
20  import cz.cuni.amis.pogamut.ut2004.agent.module.sensomotoric.AdrenalineCombo;
21  import cz.cuni.amis.pogamut.ut2004.agent.module.sensomotoric.AgentConfig;
22  import cz.cuni.amis.pogamut.ut2004.agent.module.sensomotoric.Raycasting;
23  import cz.cuni.amis.pogamut.ut2004.agent.module.sensomotoric.Weaponry;
24  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.AgentInfo;
25  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.AgentStats;
26  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.CTF;
27  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.Game;
28  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.ItemDescriptors;
29  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.Items;
30  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.NavPoints;
31  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.NavigationGraphBuilder;
32  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.Players;
33  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.Senses;
34  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.UT2004AgentInfo;
35  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.UT2004Items;
36  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.WeaponPrefs;
37  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.visibility.Visibility;
38  import cz.cuni.amis.pogamut.ut2004.agent.navigation.UT2004AStarPathPlanner;
39  import cz.cuni.amis.pogamut.ut2004.agent.navigation.UT2004GetBackToNavGraph;
40  import cz.cuni.amis.pogamut.ut2004.agent.navigation.UT2004Navigation;
41  import cz.cuni.amis.pogamut.ut2004.agent.navigation.UT2004PathExecutor;
42  import cz.cuni.amis.pogamut.ut2004.agent.navigation.UT2004RunStraight;
43  import cz.cuni.amis.pogamut.ut2004.agent.navigation.astar.UT2004AStar;
44  import cz.cuni.amis.pogamut.ut2004.agent.navigation.floydwarshall.FloydWarshallMap;
45  import cz.cuni.amis.pogamut.ut2004.agent.navigation.loquenavigator.KefikRunner;
46  import cz.cuni.amis.pogamut.ut2004.agent.navigation.loquenavigator.LoqueNavigator;
47  import cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController;
48  import cz.cuni.amis.pogamut.ut2004.bot.command.AdvancedLocomotion;
49  import cz.cuni.amis.pogamut.ut2004.bot.command.CompleteBotCommandsWrapper;
50  import cz.cuni.amis.pogamut.ut2004.bot.command.ImprovedShooting;
51  import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
52  import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotController;
53  import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotModuleController;
54  import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType;
55  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.GetPath;
56  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.AutoTraceRay;
57  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.BotKilled;
58  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange;
59  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo;
60  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage;
61  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.NavPoint;
62  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.PathList;
63  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Self;
64  import cz.cuni.amis.pogamut.ut2004.communication.translator.itemdescriptor.ItemDescriptor;
65  
66  /**
67   * Primitive State Context for UT2004.
68   * @author Honza
69   */
70  public class UT2004Context<BOT extends UT2004Bot> extends Context<BOT> implements IUT2004Context<BOT> {
71  
72  	/**
73  	 * Random number generator that is usually useful to have during decision making.
74  	 */
75  	protected Random random = new Random(System.currentTimeMillis());
76  	    
77      /**
78       * Alias for user's log.
79       */
80      protected LogCategory log = null;
81  	
82  	/**
83  	 * Memory module specialized on general info about the game - game type, time limit, frag limit, etc.
84  	 * <p><p>
85  	 * May be used since {@link SposhBotLogic#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage)}
86       * is called.
87       * <p><p>
88       * Initialized inside {@link UT2004Behaviour#initializeModules(UT2004Bot)}.
89  	 */
90  	protected Game game;
91  	
92  	/**
93  	 * Memory module specialized on general info about the agent whereabouts - location, rotation, health, current weapon, who is enemy/friend, etc.
94  	 * <p><p>
95  	 * May be used since first {@link Self} message is received, i.e, since the first {@link SposhBotLogic#botFirstSpawn(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, InitedMessage, Self)} 
96       * is called.
97       * <p><p>
98       * Initialized inside {@link UT2004Behaviour#initializeModules(UT2004Bot)}.
99  	 */
100 	protected AgentInfo info;
101 	
102 	/**
103 	 * Memory module specialized on whereabouts of other players - who is visible, enemy / friend, whether bot can see anybody, etc.
104 	 * <p><p>
105 	 * May be used since {@link SposhBotLogic#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage)}
106      * is called.
107      * <p><p>
108      * Initialized inside {@link UT2004Behaviour#initializeModules(UT2004Bot)}.
109 	 */
110 	protected Players players;
111 	
112 	/**
113 	 * Sensory module that provides mapping between {@link ItemType} and {@link ItemDescriptor} providing
114      * an easy way to obtain item descriptors for various items in UT2004.
115      * <p><p>
116      * May be used since {@link SposhBotLogic#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage)}
117      * is called.
118      * <p><p>
119      * Initialized inside {@link UT2004Behaviour#initializeModules(UT2004Bot)}.
120 	 */
121 	protected ItemDescriptors descriptors;
122 	
123 	/**
124 	 * Memory module specialized on items on the map - which are visible and which are probably spawned.
125 	 * <p><p>
126 	 * May be used since {@link SposhBotLogic#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage)}
127      * is called.
128      * <p><p>
129      * Initialized inside {@link UT2004Behaviour#initializeModules(UT2004Bot)}.
130 	 */
131 	protected Items items;
132 	
133 	/**
134 	 * Memory module specialized on agent's senses - whether the bot has been recently killed, collide with level's geometry, etc.
135 	 * <p><p>
136 	 * May be used since {@link SposhBotLogic#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage)}
137      * is called.
138      * <p><p>
139      * Initialized inside {@link UT2004Behaviour#initializeModules(UT2004Bot)}.
140 	 */
141 	protected Senses senses;
142 	
143 	/**
144 	 * Memory module specialized on info about the bot's weapon and ammo inventory - it can tell you which weapons are loaded, melee/ranged, etc.
145 	 * <p><p>
146 	 * May be used since {@link SposhBotLogic#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage)}
147      * is called.
148      * <p><p>
149      * Initialized inside {@link UT2004Behaviour#initializeModules(UT2004Bot)}.
150 	 */
151 	protected Weaponry weaponry;
152 	
153 	/**
154 	 * Memory module specialized on the agent's configuration inside UT2004 - name, vision time, manual spawn, cheats (if enabled at GB2004).
155 	 * <p><p>
156 	 * May be used since {@link SposhBotLogic#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage)}
157      * is called.
158      * <p><p>
159      * Initialized inside {@link UT2004Behaviour#initializeModules(UT2004Bot)}.
160 	 */
161 	protected AgentConfig config;
162 	
163 	/**
164 	 * Support for creating rays used for raycasting (see {@link AutoTraceRay} that is being utilized).
165 	 * <p><p>
166 	 * May be used since {@link SposhBotLogic#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.ConfigChange, cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage)}
167      * is called.
168 	 */
169 	protected Raycasting raycasting;
170 	
171 	/**
172 	 * Module for adrenaline combos.
173 	 */
174 	protected AdrenalineCombo combo;
175 	
176 	/**
177 	 * Creates and wraps all available commands that can be issued to the virtual body of the bot inside UT2004.
178      * <p><p>
179      * May be used since since the first {@link SposhBotLogic#botFirstSpawn(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, InitedMessage, Self)} 
180      * is called.
181      * <p><p>
182      * Initialized inside {@link UT2004Behaviour#initializeModules(UT2004Bot)}.
183 	 */
184 	protected CompleteBotCommandsWrapper body;
185 	
186 	/**
187 	 * Shortcut for <i>body.getImprovedShooting()</i> that allows you to shoot at opponent.
188 	 * <p><p>
189 	 * Note: more weapon-handling methods are available through {@link UT2004Behaviour#weaponry}.
190 	 * <p><p>
191 	 * May be used since since the first {@link SposhBotLogic#botFirstSpawn(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, InitedMessage, Self)} 
192      * is called.
193      * <p><p>
194 	 * Initialized inside {@link UT2004Behaviour#initializeModules(UT2004Bot)}.
195 	 */
196 	protected ImprovedShooting shoot;
197 	
198 	/**
199 	 * Shortcut for <i>body.getAdvancedLocomotion()</i> that allows you to manually steer the movement through the environment.
200 	 * <p><p>
201 	 * Note: navigation is done via {@link UT2004Behaviour#pathExecutor} that needs {@link PathHandle} from the {@link UT2004Behaviour#pathPlanner}.
202 	 * <p><p>
203 	 * May be used since since the first {@link SposhBotLogic#botFirstSpawn(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, InitedMessage, Self)} 
204      * is called.
205      * <p><p>
206 	 * Initialized inside {@link UT2004Behaviour#initializeModules(UT2004Bot)}.
207 	 */
208 	protected AdvancedLocomotion move;
209 	
210 	/**
211      * Executor is used for following a path in the environment.
212      * <p><p>
213      * May be used since since the first {@link IUT2004BotController#botFirstSpawn(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, InitedMessage, Self)}
214      * is called.
215      * <p><p>
216      * Initialized inside {@link UT2004BotModuleControllerNew#initializePathFinding(UT2004Bot)}.
217      */
218 	protected UT2004PathExecutor<ILocated> pathExecutor = null;
219 
220     /**
221      * Planner used to compute the path (consisting of navigation points) inside the map.
222      * <p><p>
223      * May be used since since the first {@link IUT2004BotController#botFirstSpawn(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, InitedMessage, Self)}
224      * is called.
225      * <p><p>
226      * Initialized inside {@link UT2004BotModuleControllerNew#initializePathFinding(UT2004Bot)}.
227      */
228     protected IPathPlanner<ILocated> pathPlanner = null;
229     
230     /**
231      * Weapon preferences for your bot. See {@link WeaponPrefs} class javadoc. It allows you to define preferences for
232      * weapons to be used at given distance (together with their firing mode).
233      */
234     protected WeaponPrefs weaponPrefs;
235     
236     /**
237      * Navigation graph builder that may be used to manually extend the navigation graph of the UT2004.
238      * <p><p>
239      * May be used since {@link IUT2004BotController#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, InitedMessage)} 
240      * is called.
241      * <p><p>
242      * Initialized inside {@link UT2004BotModuleController#initializeModules(UT2004Bot)}.
243      */
244     protected NavigationGraphBuilder navBuilder;
245     
246     /**
247      * Module that is providing various statistics about the bot. You may also used it to output these stats (in CSV format)
248      * into some file using {@link AgentStats#startOutput(String)} or {@link AgentStats#startOutput(String, boolean)}.
249      */
250     protected AgentStats stats;
251 
252     /**
253      * Path-planner ({@link IPathPlanner} using {@link NavPoint}s), you may use it to find paths inside the environment wihtout
254      * waiting for round-trip of {@link GetPath} command and {@link PathList}s response from UT2004. It is much faster than 
255      * {@link UT2004BotModuleController#pathPlanner} but you need to pass {@link NavPoint} instances to planner instead of
256      * {@link ILocated} ... to find the nearest {@link NavPoint} instance, {@link DistanceUtils} is a handy, check especially
257      * {@link DistanceUtils#getNearest(java.util.Collection, ILocated)}.
258      */
259 	protected FloydWarshallMap fwMap;
260 	
261 	/**
262 	 * Command module that is internally using {@link UT2004PathExecutor} for path-following and {@link FloydWarshallMap}
263 	 * for path planning resulting in unified class that can solely handle navigation of the bot within the environment.
264 	 * <p><p> 
265 	 * In contrast to {@link UT2004PathExecutor} methods
266 	 * of this module may be recalled every {@link UT2004BotModuleController#logic()} iteration even with 
267 	 * the same argument (which is not true for {@link UT2004PathExecutor#followPath(cz.cuni.amis.pogamut.base.agent.navigation.IPathFuture)}.
268 	 * <p><p>
269 	 * Note that this class is actually initialized with instances of {@link UT2004BotModuleController#pathExecutor} and {@link UT2004BotModuleController#fwMap}
270 	 * so you must take care if using add/remove stuck detectors or reinitilize this property to your liking (you can do that in {@link UT2004BotModuleController#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, InitedMessage)} 
271 	 * method.
272 	 * <p><p>
273 	 * May be used since first {@link UT2004BotModuleController#logic()} is called.
274      * <p><p>
275      * Initialized inside {@link UT2004BotModuleController#initializePathFinding(UT2004Bot)}.
276 	 */
277 	protected UT2004Navigation navigation;
278     
279     /**
280      * Listener registrator that probes declared methods for the presence of {@link EventListener}, {@link ObjectClassEventListener},
281      * {@link ObjectClassListener}, {@link ObjectEventListener} and {@link ObjectListener} annotations and automatically registers
282      * them as listeners on a specific events.
283      * <p><p>
284      * Note that this registrator is usable for 'this' object only! It will work only for 'this' object.
285      */
286     protected AnnotationListenerRegistrator listenerRegistrator;
287     
288     /**
289      * Shortcut for the {@link UT2004BotModuleController#getWorldView()}.
290      */
291     protected IVisionWorldView world;
292     
293     /**
294      * Shortcut for the {@link UT2004BotModuleController#getAct()}.
295      */
296     protected IAct act;
297 
298     /**
299 	 * Navigation helper that is able to get your bot back to the nearest navigation graph so you can use {@link UT2004BotModuleController#navigation} 
300 	 * without fear of catastrophe.
301 	 * May be used since {@link IUT2004BotController#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, InitedMessage)} 
302      * is called.
303      * <p><p>
304      * Initialized inside {@link UT2004BotModuleController#initializePathFinding(UT2004Bot)}.
305 	 */
306 	protected UT2004GetBackToNavGraph getBackToNavGraph;
307 	
308 	/**
309 	 * Navigation helper that can run-straight to some point with stuck detectors.
310 	 * <p><p>
311 	 * May be used since {@link IUT2004BotController#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, InitedMessage)} 
312      * is called.
313      * <p><p>
314      * Initialized inside {@link UT2004BotModuleController#initializePathFinding(UT2004Bot)}.
315 	 */
316 	protected UT2004RunStraight runStraight;
317 	
318 	/**
319 	 * Module that provides visibility/cover information for the map.
320 	 * <p><p>
321 	 * May be used since {@link IUT2004BotController#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, InitedMessage)} 
322      * is called.
323      * <p><p>
324      * Initialized inside {@link UT2004BotModuleController#initializeModules(UT2004Bot)}.
325 	 */
326 	protected Visibility visibility;
327 	
328 	/**
329 	 * Module specialized on CTF games. Enabled only for CTF games, check {@link CTF#isEnabled()}.
330 	 * <p><p>
331 	 * Initialized inside {@link UT2004BotModuleController#initializeModules(UT2004Bot)}.
332 	 */
333 	protected CTF ctf;
334 	
335 	/**
336 	 * Module that provides shortcut for getting {@link NavPoint}s out of {@link IWorldView}.
337 	 * <p><p>
338 	 * May be used since {@link IUT2004BotController#botInitialized(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, InitedMessage)} 
339      * is called.
340      * <p><p>
341      * Initialized inside {@link UT2004BotModuleController#initializeModules(UT2004Bot)}.
342 	 */
343 	protected NavPoints navPoints;
344 	
345 	/**
346 	 * Class providing A-Star algorithm over the navpoints as they are present within the {@link IWorldView}.
347 	 * <p><p>
348 	 * You may provide custom {@link IPFMapView} over the map in-order to greatly customize the A-Star search.
349 	 */
350 	protected UT2004AStar aStar;
351 
352 	public UT2004Context(String name, BOT bot) {
353 		super(name, bot);
354         log = bot.getLogger().getCategory(UT2004BotController.USER_LOG_CATEGORY_ID);
355         log.setLevel(Level.ALL);
356 	}
357 
358 	/**
359 	 * Called after the construction of the {@link UT2004Behaviour} before the GameBots2004 greets the bot even before
360 	 * {@link UT2004Behaviour#prepareBehaviour(UT2004Bot)} method.
361 	 * <p><p>
362 	 * <b>NOTE:</b> This is Pogamut's developers reserved method - do not override it and if you do, always use 'super' 
363 	 * to call parent's initializeBehaviour.
364      */
365 	protected void initialize() {
366 		initializeModules(bot);
367 		initializePathFinding(bot);
368 		initializeListeners(bot);
369 	}
370 	
371 	/**
372      * Initializes {@link UT2004Behaviour#listenerRegistrator} and calls {@link AnnotationListenerRegistrator#addListeners()} method
373      * to probe all declared methods for event-annotation presence.
374      * @param bot
375      */
376 	protected void initializeListeners(BOT bot) {
377 		listenerRegistrator = new AnnotationListenerRegistrator(this, getWorldView(), bot.getLogger().getCategory("Listeners"));
378 		listenerRegistrator.addListeners();
379 	}
380 
381 	/**
382 	 * Initializes path-finding modules: {@link UT2004BotModuleControllerNew#pathPlanner} and {@link UT2004BotModuleControllerNew#pathExecutor}.
383 	 * If you need different path planner / path executor - override this method and initialize your own modules.
384 	 * @param bot
385 	 */
386 	protected void initializePathFinding(BOT bot) {
387 		pathPlanner  = new UT2004AStarPathPlanner(bot);
388 		fwMap        = new FloydWarshallMap(bot);
389 		aStar       = new UT2004AStar(bot);		
390 		pathExecutor = 
391         	new UT2004PathExecutor<ILocated>(
392         		bot, 
393         		info,
394         		move,
395         		new LoqueNavigator<ILocated>(bot, info, move, bot.getLog())
396         	);   
397 		getBackToNavGraph = new UT2004GetBackToNavGraph(bot, info, move);
398                 runStraight = new UT2004RunStraight(bot, info, move);
399 		navigation = new UT2004Navigation(bot, pathExecutor, fwMap, getBackToNavGraph, runStraight);
400 	}
401 
402 	/**
403 	 * Initializes memory/command modules of the bot.
404 	 * 
405 	 * @param bot
406 	 */
407 	protected void initializeModules(BOT bot) {
408 		world       = getWorldView();
409 		act         = getAct();
410 		
411 		game        = new Game(bot);
412 		navPoints   = new NavPoints(bot);
413 		players     = new Players(bot);
414 		descriptors = new ItemDescriptors(bot);
415 		config      = new AgentConfig(bot);
416 		raycasting  = new Raycasting(bot);
417 		stats       = new AgentStats(bot);
418 		navBuilder  = new NavigationGraphBuilder(bot);
419 		info        = new UT2004AgentInfo(bot, game);
420 		visibility  = new Visibility(bot, info);
421 		ctf         = new CTF(bot, info);
422 		weaponry    = new Weaponry(bot, descriptors);
423 		items       = new UT2004Items(bot, info, game, weaponry, null);
424 		senses      = new Senses(bot, info, players);
425 		body        = new CompleteBotCommandsWrapper(bot, weaponry, null);		
426 		shoot       = body.getImprovedShooting();
427 		move        = body.getLocomotion();
428 		weaponPrefs = new WeaponPrefs(weaponry, bot);
429 		combo       = new AdrenalineCombo(bot, info);
430 	}
431 	
432 	/**
433 	 * Called after the behaviour construction to initialize user's data structures.
434 	 * @param bot
435 	 */
436 	protected void prepareBehaviour(BOT bot) {		
437 	}	
438 	
439 	/**
440      * This method is called whenever {@link InitedMessage} is received. Various agent modules are usable since this
441      * method is called.
442      * 
443      * @param gameInfo
444      * @param config
445      * @param init
446      * @param self
447      */
448     public void botInitialized(GameInfo info, ConfigChange config, InitedMessage init) {
449     }
450 
451     /**
452      * This method is called only once whenever first batch of information what the bot can see is received.
453      * <i><i>
454      * It is sort of "first-logic-method" where you may issue commands for the first time and handle everything
455      * else in bot's logic then. It eliminates the need to have 'boolean firstLogic' field inside your bot.
456      * <p><p>
457      * Note that this method has advantage over the {@link IUT2004BotController#botInitialized(GameInfo, ConfigChange, InitedMessage)}
458      * that you already have {@link Self} object.
459      * 
460      * @param gameInfo
461      * @param config
462      * @param init
463      * @param self
464      */
465     public void botSpawned(GameInfo gameInfo, ConfigChange config, InitedMessage init, Self self) {
466     }
467     
468     /**
469 	 * Called after {@link UT2004Behaviour#botFirstSpawn(GameInfo, ConfigChange, InitedMessage, Self)} as a hook for Pogamut's core developers
470 	 * to finalize initialization of various modules.
471 	 * <p><p>
472 	 * <b>NOTE:</b> This is Pogamut's developers reserved method - do not override it and if you do, always use 'super' 
473 	 * to call parent's finishControllerInitialization.
474      */
475     public void finishInitialization() {
476     	if (navBuilder.isUsed()) {
477 			log.info("Navigation graph has been altered by 'navBuilder', triggering recomputation of Floyd-Warshall path matrix...");
478 			Level oldLevel = fwMap.getLog().getLevel();
479 			fwMap.getLog().setLevel(Level.FINER);
480 			fwMap.refreshPathMatrix();
481 			fwMap.getLog().setLevel(oldLevel);
482 			
483 			aStar.mapChanged();
484 		}
485     }
486     
487     /**
488      * This method is called before the SPOSH iteration is invoked. You may clear previous-state variables here.
489      */
490     public void logicIteration() {    	
491     }
492     
493     /**
494      * Called whenever the bot gets killed inside the game.
495      * 
496      * @param event
497      */
498 	public void botKilled(BotKilled event) {		
499 	}
500 	
501 	public IVisionWorldView getWorldView() {
502 		return bot.getWorldView();
503 	}
504 	
505 	public IAct getAct() {
506 		return bot.getAct();
507 	}
508 
509 	public CompleteBotCommandsWrapper getBody() {
510 		return body;
511 	}
512 
513 	public Random getRandom() {
514 		return random;
515 	}
516 
517 	public LogCategory getLog() {
518 		return log;
519 	}
520 	
521 	public UT2004AStar getAStar() {
522 		return aStar;
523 	}
524 
525 	public Game getGame() {
526 		return game;
527 	}
528 
529 	public AgentInfo getInfo() {
530 		return info;
531 	}
532 
533 	public Players getPlayers() {
534 		return players;
535 	}
536 
537 	public ItemDescriptors getDescriptors() {
538 		return descriptors;
539 	}
540 
541 	public Items getItems() {
542 		return items;
543 	}
544 
545 	public Senses getSenses() {
546 		return senses;
547 	}
548 
549 	public Weaponry getWeaponry() {
550 		return weaponry;
551 	}
552 
553 	public AgentConfig getConfig() {
554 		return config;
555 	}
556 
557 	public Raycasting getRaycasting() {
558 		return raycasting;
559 	}
560 
561 	public ImprovedShooting getShoot() {
562 		return shoot;
563 	}
564 
565 	public AdvancedLocomotion getMove() {
566 		return move;
567 	}
568 
569 	public UT2004PathExecutor<ILocated> getPathExecutor() {
570 		return pathExecutor;
571 	}
572 
573 	public IPathPlanner<ILocated> getPathPlanner() {
574 		return pathPlanner;
575 	}
576 
577 	public WeaponPrefs getWeaponPrefs() {
578 		return weaponPrefs;
579 	}
580 
581 	public NavigationGraphBuilder getNavBuilder() {
582 		return navBuilder;
583 	}
584 
585 	public AgentStats getStats() {
586 		return stats;
587 	}
588 
589 	public FloydWarshallMap getFwMap() {
590 		return fwMap;
591 	}
592 
593 	public UT2004Navigation getNavigation() {
594 		return navigation;
595 	}
596 
597 	public AnnotationListenerRegistrator getListenerRegistrator() {
598 		return listenerRegistrator;
599 	}
600 
601 	public IVisionWorldView getWorld() {
602 		return world;
603 	}
604 	
605 	public UT2004GetBackToNavGraph getBackToNavGraph() {
606 		return getBackToNavGraph;
607 	}
608 
609 	public CTF getCtf() {
610 		return ctf;
611 	}
612 
613 	public Visibility getVisibility() {
614 		return visibility;
615 	}
616 	
617 	public AdrenalineCombo getCombo() {
618 		return combo;
619 	}
620 
621 }