cz.cuni.amis.pogamut.ut2004.examples.botwithparams
Class BotWithParams

Package class diagram package BotWithParams
java.lang.Object
  extended by cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotController<BOT>
      extended by cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotLogicController<BOT>
          extended by cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotModuleController
              extended by cz.cuni.amis.pogamut.ut2004.examples.botwithparams.BotWithParams
All Implemented Interfaces:
cz.cuni.amis.pogamut.base.agent.module.IAgentLogic, IUT2004BotController, IUT2004BotLogicController

public class BotWithParams
extends UT2004BotModuleController

This bot does not do anything - it is a show-case that will (hopefully) explain, how to create your own parameters for the bot, and you will see how to obtain them during runtime. The advantage of parameterization is that you may have 1 class with MULTIPLE parameters thus obtaining different behaviors with every instance of params.

There are two things you have to do:

  1. you have to create new class that will extend UT2004BotParameters, in the example implementation that is done by implementation CustomBotParameters
  2. you have to instantiate that class and give it to UT2004BotRunner.startAgents(UT2004BotParameters...), that is carried out inside main(String[])
After that, the runner will feed these params into the UT2004Bot class and they will become available through UT2004Bot.getParams(). Notice, that you will need to cast these params to your class in order to use them. For that we're recommend to create custom method inside your bot controller class that will do that for you.

Note that the implementation of this class is minimalistic, in order to show only methods that are needed. For the sake of simplicity, the bot's behavior is stupid one ... it will either jump, or rotate or both (depending on the parameters obtained from

Author:
Jakub Gemrot aka Jimmy

Field Summary
 
Fields inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotModuleController
act, body, combo, config, ctf, descriptors, fwMap, game, getBackToNavGraph, info, items, listenerRegistrator, move, navBuilder, navigation, pathExecutor, pathPlanner, players, random, raycasting, runStraight, senses, shoot, stats, visibility, weaponPrefs, weaponry, world
 
Fields inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotLogicController
logicModule
 
Fields inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotController
bot, log, USER_LOG_CATEGORY_ID
 
Constructor Summary
BotWithParams()
           
 
Method Summary
 Initialize getInitializeCommand()
          Here we can modify initializing command for our bot, e.g., sets its name, skin, skill level according to getParams(), i.e., CustomBotParameters.getName(), CustomBotParameters.getBotSkin() and CustomBotParameters.getSkillLevel().
 CustomBotParameters getParams()
          This method returns the parameters of the bot, to be used.
 void logic()
          Inside logic we're implementing jumping / turning behavior as instructed by getParams(), i.e., CustomBotParameters.isJumping() and CustomBotParameters.isRotating().
static void main(String[] args)
          This method is called when the bot is started either from IDE or from command line.
 
Methods inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotModuleController
finishControllerInitialization, getBody, getCombo, getConfig, getDescriptors, getFwMap, getGame, getInfo, getItems, getMove, getNavBuilder, getNavigation, getPathExecutor, getPathPlanner, getPlayers, getRandom, getRaycasting, getSenses, getShoot, getStats, getVisibility, getWeaponPrefs, getWeaponry, getWorld, initializeController, initializeListeners, initializeModules, initializePathFinding
 
Methods inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotLogicController
beforeFirstLogic, getLogicInitializeTime, getLogicShutdownTime, initializeLogic, logicInitialize, logicShutdown
 
Methods inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotController
botFirstSpawn, botInitialized, botKilled, botShutdown, getAct, getBot, getLog, getPassword, getWorldView, prepareBot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController
botFirstSpawn, botInitialized, botKilled, botShutdown, getAct, getBot, getLog, getPassword, getWorldView, prepareBot
 

Constructor Detail

BotWithParams

public BotWithParams()
Method Detail

getParams

public CustomBotParameters getParams()
This method returns the parameters of the bot, to be used. It is using UT2004Bot.getParams() and casts them to CustomBotParameters that is, this bot can't be used with different parameters (it will screw up).

Returns:

getInitializeCommand

public Initialize getInitializeCommand()
Here we can modify initializing command for our bot, e.g., sets its name, skin, skill level according to getParams(), i.e., CustomBotParameters.getName(), CustomBotParameters.getBotSkin() and CustomBotParameters.getSkillLevel().

Specified by:
getInitializeCommand in interface IUT2004BotController
Overrides:
getInitializeCommand in class UT2004BotController
Returns:
instance of Initialize

logic

public void logic()
           throws cz.cuni.amis.utils.exception.PogamutException
Inside logic we're implementing jumping / turning behavior as instructed by getParams(), i.e., CustomBotParameters.isJumping() and CustomBotParameters.isRotating().

Specified by:
logic in interface cz.cuni.amis.pogamut.base.agent.module.IAgentLogic
Overrides:
logic in class UT2004BotLogicController
Throws:
cz.cuni.amis.utils.exception.PogamutException

main

public static void main(String[] args)
                 throws cz.cuni.amis.utils.exception.PogamutException
This method is called when the bot is started either from IDE or from command line.

Notice the usage of UT2004BotRunner.startAgents(UT2004BotParameters...) that is using CustomBotParameters. Such method will start 4 bots with all combination of jumping/rotating behavior.

Parameters:
args -
Throws:
cz.cuni.amis.utils.exception.PogamutException


Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.