[Pogamut-list] Launching Multiple Bots of Different Types

dirkmalta pogamut-forum at diana.ms.mff.cuni.cz
Tue Nov 23 17:44:37 CET 2010


Re: Launching Multiple Bots of Different Types

Author: dirkmalta

Thanks Jimmy.
The Pogamut 3 version I installed is 'Pogamut-3-install-all-v3.0.11'.

The following is a full copy&paste of MultipleUT2004BotRunner:

package cz.cuni.amis.pogamut.ut2004.utils;

import java.util.concurrent.CountDownLatch;

import cz.cuni.amis.pogamut.base.agent.IAgent;
import cz.cuni.amis.pogamut.base.agent.impl.AgentId;
import cz.cuni.amis.pogamut.base.agent.state.level0.IAgentState;
import cz.cuni.amis.pogamut.base.agent.state.level1.IAgentStateDown;
import cz.cuni.amis.pogamut.base.agent.state.level1.IAgentStateGoingDown;
import cz.cuni.amis.pogamut.base.agent.state.level2.IAgentStateFailed;
import cz.cuni.amis.pogamut.base.agent.utils.runner.impl.RemoteAgentRunner;
import cz.cuni.amis.pogamut.base.communication.connection.impl.socket.SocketConnectionAddress;
import cz.cuni.amis.pogamut.base.utils.Pogamut;
import cz.cuni.amis.pogamut.base.utils.PogamutPlatform;
import cz.cuni.amis.pogamut.base.utils.PogamutProperty;
import cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController;
import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
import cz.cuni.amis.pogamut.ut2004.factory.guice.remoteagent.UT2004BotFactory;
import cz.cuni.amis.pogamut.ut2004.factory.guice.remoteagent.UT2004BotModule;
import cz.cuni.amis.utils.exception.PogamutException;
import cz.cuni.amis.utils.exception.PogamutInterruptedException;
import cz.cuni.amis.utils.flag.FlagListener;

/**
* This class has only one purpose - execute ONE OR MORE BOTS inside 'main' method. You can't use it for anything else!
* It is THE SHORTCUT of all SHORTCUTS to execute multiple bots, wait till they finishe and close the whole Pogamut.
* 
* Designed especially for the usage inside NetBeans projects.
* 
* NOTE: It's not even meant to be instantiated twice for two different batch of bots and consequently executed in two different threads!
* Single-purpose class only ;-)
* 
* NOTE: It might be very interesting for you to check out the source of method {@link MultipleUT2004BotRunner#startAgent()} to
* see how the agent should be instantiated via {@link UT2004BotFactory} using {@link UT2004BotModule}.
*
* @author Jimmy
*/
public class MultipleUT2004BotRunner {

    protected String host;
    protected int port;
     protected int number;
     protected UT2004BotFactory factory;
     protected String name;
    
     private Object agentCounterMutex = new Object();
     private int agentCounter;

    /**
     * Constructs the runner so the newly created bots will be controlled by 'controllerClass' has name 'name' and will connect to 'host:port'.
     * @param number how many bot instances with 'controllerClass' should be created
     * @param controllerClass class that controls the bot's behavior
     * @param name name of the bot
     * @param host where it should connect (host of GB2004 bot connection)
     * @param port to which port it should connect (port of the GB2004 bot connection)
     */
    public MultipleUT2004BotRunner(int number, Class

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