Esempio n. 1
0
  /**
   * create the monitoring agents (rma+sniffer) on the main-container given in parameter and launch
   * them. - RMA agent's is used to debug and monitor the platform; - Sniffer agent is used to
   * monitor communications
   *
   * @param mc the main-container's reference
   * @return a ref to the sniffeur agent
   */
  private static void createMonitoringAgents(ContainerController mc) {

    System.out.println("Launching the rma agent on the main container ...");
    AgentController rma;

    try {
      rma = mc.createNewAgent("rma", "jade.tools.rma.rma", new Object[0]);
      rma.start();
    } catch (StaleProxyException e) {
      e.printStackTrace();
      System.out.println("Launching of rma agent failed");
    }

    System.out.println("Launching  Sniffer agent on the main container...");
    AgentController snif = null;

    try {
      snif = mc.createNewAgent("sniffeur", "jade.tools.sniffer.Sniffer", new Object[0]);
      snif.start();

    } catch (StaleProxyException e) {
      e.printStackTrace();
      System.out.println("launching of sniffer agent failed");
    }
  }
Esempio n. 2
0
 private void createQueenAgents(int nQueens) {
   log.info("Create number of " + nQueens + " Queen Agents");
   ContainerController containerController = getContainerController();
   try {
     for (int i = 1; i <= nQueens; i++) {
       containerController
           .createNewAgent("Queen" + i, XQueen.class.getName(), new Object[] {i, nQueens})
           .start();
     }
   } catch (StaleProxyException e) {
     log.severe(e.getMessage());
   }
 }
Esempio n. 3
0
  public void startContainer() throws SlickException {
    // ----------JADE start
    // Get a hold of JADE runtime
    Runtime runtime = Runtime.instance();
    // Create a default profile
    ProfileImpl profile = new ProfileImpl();
    // Create a new non-main container, connecting to the default
    // main container (i.e. on this host, port 1099)
    ContainerController cc = runtime.createMainContainer(profile);
    AgentController rma = null;
    AgentController player1 = null;
    AgentController player2 = null;
    AgentController player3 = null;
    AgentController player4 = null;
    ArrayList<AgentController> landmarks = new ArrayList<AgentController>();
    Object[] arguments = new Object[3];
    arguments[0] = this.map;
    arguments[1] = "team1-luffy";
    arguments[2] = map.getAvatars().get(1);
    Object[] argumentsChief = new Object[3];
    argumentsChief[0] = this.map;
    argumentsChief[1] = "team1-luffy";
    argumentsChief[2] = map.getAvatars().get(0);
    Object[] arguments2 = new Object[3];
    arguments2[0] = this.map;
    arguments2[1] = "team2-roronoa";
    arguments2[2] = map.getAvatars().get(2);
    Object[] argumentsChief2 = new Object[3];
    argumentsChief2[0] = this.map;
    argumentsChief2[1] = "team2-roronoa";
    argumentsChief2[2] = map.getAvatars().get(3);
    try {
      rma = cc.createNewAgent("rma", "jade.tools.rma.rma", null);
      player1 =
          cc.createNewAgent(
              ((Avatar) arguments[2]).getName(), "agents.TickerExplorerRandomPlayer", arguments);
      player2 =
          cc.createNewAgent(
              ((Avatar) arguments2[2]).getName(), "agents.TickerExplorerRandomPlayer", arguments2);
      player3 =
          cc.createNewAgent(
              "Chiefteam1-luffy", "agents.TickerExplorerRandomPlayer", argumentsChief);
      player4 =
          cc.createNewAgent(
              "Chiefteam2-roronoa", "agents.TickerExplorerRandomPlayer", argumentsChief2);
      for (int i = 0; i < map.getLandmarks().size(); i++) {
        Object[] landmarkArgs = new Object[4];
        landmarkArgs[0] = "Landmark" + i;
        landmarkArgs[1] = this.map;
        landmarkArgs[2] = map.getLandmarks().get(i);
        landmarkArgs[3] = map.getLandmarks().get(i).getMessage();
        landmarks.add(
            cc.createNewAgent(
                map.getLandmarks().get(i).getName(), "agents.LandmarkAgent", landmarkArgs));
      }
      System.out.println("Agent created \n");

    } catch (StaleProxyException ex) {
      System.out.println("here is problem");
    }
    try {
      // rma.start();
      player1.start();
      player2.start();
      player3.start();
      player4.start();
      for (int i = 0; i < map.getLandmarks().size(); i++) {
        landmarks.get(i).start();
      }
      System.out.println("Agent started \n");
    } catch (StaleProxyException ex) {
      System.out.println("Stale Proxy pointer ex");
    } catch (NullPointerException ex) {
      System.out.println("Null pointer ex");
      ex.printStackTrace();
    }
    //	            //----------JADE end
  }
Esempio n. 4
0
  /**
   * Creates the agents and add them to the agentList. agents are NOT started.
   *
   * @param containerList :Name and container's ref
   * @param sniff : a ref to the sniffeur agent
   * @return the agentList
   */
  private static List<AgentController> createAgents(
      HashMap<String, ContainerController> containerList) {
    System.out.println("Launching agents...");
    ContainerController c;
    String agentName;
    List<AgentController> agentList = new ArrayList<AgentController>();

    // wumpus on container0
    c = containerList.get("container0");
    agentName = "Golem";
    try {
      Object[] objtab = new Object[] {env}; // used to give informations to the agent
      AgentController ag =
          c.createNewAgent(agentName, mas.agents.GolemAgent.class.getName(), objtab);
      agentList.add(ag);
      System.out.println(agentName + " launched");
    } catch (StaleProxyException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // wumpus on container0
    //		c = containerList.get("container0");
    //		agentName="Wumpus1";
    //		try {
    //
    //
    //			Object[] objtab=new Object[]{env,agentName};//used to give informations to the agent
    //			AgentController	ag=c.createNewAgent(agentName,DummyWumpusAgent.class.getName(),objtab);
    //			agentList.add(ag);
    //			System.out.println(agentName+" launched");
    //		} catch (StaleProxyException e) {
    //			// TODO Auto-generated catch block
    //			e.printStackTrace();
    //		}

    //		agentName="Wumpus2";
    //		try {
    //
    //
    //			Object[] objtab=new Object[]{env,agentName};//used to give informations to the agent
    //			AgentController	ag=c.createNewAgent(agentName,DummyAgentWumpus.class.getName(),objtab);
    //			agentList.add(ag);
    //			System.out.println(agentName+" launched");
    //		} catch (StaleProxyException e) {
    //			// TODO Auto-generated catch block
    //			e.printStackTrace();
    //		}
    //
    //		//wumpus on container0
    //		c = containerList.get("container0");
    //		agentName="Wumpus3";
    //		try {
    //
    //
    //			Object[] objtab=new Object[]{env,agentName};//used to give informations to the agent
    //			AgentController	ag=c.createNewAgent(agentName,DummyAgentWumpus.class.getName(),objtab);
    //			agentList.add(ag);
    //			System.out.println(agentName+" launched");
    //		} catch (StaleProxyException e) {
    //			// TODO Auto-generated catch block
    //			e.printStackTrace();
    //		}
    //
    //
    // Agent0 on container0
    c = containerList.get("container0");
    agentName = "Explo1";
    try {

      Object[] objtab = new Object[] {env}; // used to give informations to the agent
      AgentController ag = c.createNewAgent(agentName, DummyExploAgent.class.getName(), objtab);
      agentList.add(ag);
      System.out.println(agentName + " launched");
    } catch (StaleProxyException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    //
    ////

    c = containerList.get("container0");
    agentName = "Explo2";
    try {

      Object[] objtab = new Object[] {env}; // used to give informations to the agent
      AgentController ag = c.createNewAgent(agentName, DummyExploAgent.class.getName(), objtab);
      agentList.add(ag);
      System.out.println(agentName + " launched");
    } catch (StaleProxyException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    c = containerList.get("container0");
    agentName = "Explo3";
    try {

      Object[] objtab = new Object[] {env}; // used to give informations to the agent
      AgentController ag = c.createNewAgent(agentName, DummyExploAgent.class.getName(), objtab);
      agentList.add(ag);
      System.out.println(agentName + " launched");
    } catch (StaleProxyException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    /*
    		c = containerList.get("container0");
    		agentName="Explo4";
    		try {


    			Object[] objtab=new Object[]{env};//used to give informations to the agent
    			AgentController	ag=c.createNewAgent(agentName,DummyExploAgent.class.getName(),objtab);
    			agentList.add(ag);
    			System.out.println(agentName+" launched");
    		} catch (StaleProxyException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}

    		c = containerList.get("container0");
    		agentName="Explo5";
    		try {


    			Object[] objtab=new Object[]{env};//used to give informations to the agent
    			AgentController	ag=c.createNewAgent(agentName,DummyExploAgent.class.getName(),objtab);
    			agentList.add(ag);
    			System.out.println(agentName+" launched");
    		} catch (StaleProxyException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}

    		c = containerList.get("container0");
    		agentName="Explo6";
    		try {


    			Object[] objtab=new Object[]{env};//used to give informations to the agent
    			AgentController	ag=c.createNewAgent(agentName,DummyExploAgent.class.getName(),objtab);
    			agentList.add(ag);
    			System.out.println(agentName+" launched");
    		} catch (StaleProxyException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}


    		c = containerList.get("container0");
    		agentName="Explo7";
    		try {

    			Object[] objtab=new Object[]{env};//used to give informations to the agent
    			AgentController	ag=c.createNewAgent(agentName,DummyExploAgent.class.getName(),objtab);
    			agentList.add(ag);
    			System.out.println(agentName+" launched");
    		} catch (StaleProxyException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    //
    ////

    		c = containerList.get("container0");
    		agentName="Explo8";
    		try {


    			Object[] objtab=new Object[]{env};//used to give informations to the agent
    			AgentController	ag=c.createNewAgent(agentName,DummyExploAgent.class.getName(),objtab);
    			agentList.add(ag);
    			System.out.println(agentName+" launched");
    		} catch (StaleProxyException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}


    		c = containerList.get("container0");
    		agentName="Explo9";
    		try {


    			Object[] objtab=new Object[]{env};//used to give informations to the agent
    			AgentController	ag=c.createNewAgent(agentName,DummyExploAgent.class.getName(),objtab);
    			agentList.add(ag);
    			System.out.println(agentName+" launched");
    		} catch (StaleProxyException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}

    		c = containerList.get("container0");
    		agentName="Explo10";
    		try {


    			Object[] objtab=new Object[]{env};//used to give informations to the agent
    			AgentController	ag=c.createNewAgent(agentName,DummyExploAgent.class.getName(),objtab);
    			agentList.add(ag);
    			System.out.println(agentName+" launched");
    		} catch (StaleProxyException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}

    		c = containerList.get("container0");
    		agentName="Explo11";
    		try {


    			Object[] objtab=new Object[]{env};//used to give informations to the agent
    			AgentController	ag=c.createNewAgent(agentName,DummyExploAgent.class.getName(),objtab);
    			agentList.add(ag);
    			System.out.println(agentName+" launched");
    		} catch (StaleProxyException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}

    		c = containerList.get("container0");
    		agentName="Explo12";
    		try {


    			Object[] objtab=new Object[]{env};//used to give informations to the agent
    			AgentController	ag=c.createNewAgent(agentName,DummyExploAgent.class.getName(),objtab);
    			agentList.add(ag);
    			System.out.println(agentName+" launched");
    		} catch (StaleProxyException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		*/
    /*
     */

    System.out.println("Agents launched...");
    return agentList;
  }