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