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