[Pogamut-list] Launching Multiple Bots of Different Types

jakub.gemrot pogamut-forum at diana.ms.mff.cuni.cz
Sun Dec 12 20:24:11 CET 2010


Re: Launching Multiple Bots of Different Types

Author: jakub.gemrot

Thanks for the question!

Actually the parameters are passed to the constructor of the UT2004Bot class itself (as well as is IUT2004BotController implementation).


public UT2004Bot(UT2004AgentParameters parameters, IComponentBus eventBus, IAgentLogger logger, IWorldView worldView, IAct act, IUT2004BotController init) {
        super(parameters.getAgentId(), eventBus, logger, (WORLD_VIEW)worldView, (ACT)act);

        this.params = parameters;
        this.controller = (CONTROLLER) init;
        NullCheck.check(this.controller, "init");
        if (log.isLoggable(Level.FINER)) log.finer("Initializing the controller...");
        this.controller.initializeController(this);
        if (log.isLoggable(Level.FINER)) log.finer("Preparing the controller...");
        this.controller.prepareBot(this);
....


As you can see parameters are saved into internal (private) field of the bot (thisrparams). This is done even before this.controller.prepareBot(this) is called. Which means early on, inside prepareBot() method of your controller (or the Hunter example), you may call bot.getParams() and get a hand on your passed parameters. The only sad thing is that you need to cast these params into the class you are expecting to receive, i.e., to the HunterParameters for instance (and it is expected you provide yourself with some getters to receive whatever params you want).

These params are present inside UT2004Bot during its whole "life", thus you may call bot.getParams() anytime you want.

Cheers!
Jimmy

-- 
Reply Link: <http://diana.ms.mff.cuni.cz/main/tiki-view_forum_thread.php?forumId=4&comments_reply_threadId=4&comments_parentId=221&post_reply=1#form>





More information about the Pogamut-list mailing list