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