[Pogamut-list] Launching Multiple Bots of Different Types

jakub.gemrot pogamut-forum at diana.ms.mff.cuni.cz
Tue Jun 8 08:21:13 CEST 2010


Re: Launching Multiple Bots of Different Types

Author: jakub.gemrot

Hi! That would be more tricky.

There is no consensus among Pogamut team members how this should be done, but here is one way that is achievable already:

I'm going to describe the code, you're probably aware of (as you write):

SingleUT2004BotRunner as well as MultipleUT2004BotRunner has method


    /**
     * Custom hook called after the agent is instantiated by the {@link RemoteAgentRunner#factory} and before
     * the {@link IAgent#start()} is called.
     * @param agent
     */
    protected void preStartHook(T agent) throws PogamutException {
    }

    /**
     * Custom hook called after the agent is instantiated by the {@link RemoteAgentRunner#factory} and
     * started with {@link IAgent#start()}.
     * @param agent
     * @throws PogamutException
     */
    protected void postStartHook(T agent) throws PogamutException {    	
    }


This method (postStartHook) is going to be called everytime a new agent is created (preStartHook) and started (postStartHook). This way, you may inject whatever you want into the agent's instance. Note that you will do something like:


                new MultipleUT2004BotRunner(3, NavigationBot.class, "NavigationBot") {	
			protected void preStartHook(UT2004Bot agent) throws PogamutException {
				((NavigationBot)agent.getController()).setSomething(myconfig[++index]);
			};			
		}.startAgent();


This way you may pass configs into newly created agents.


Another way would be through Guice which I'm going to implement as well. Basicly, I will create an
IAgentParameters interface that you may put into the constructor of the IUT2004BotController implementor and specify the bindings for this via Guice letting Guice to inject these parameters into the constructor for you. 

Best,
Jakub

-- 
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