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