Re: [jade-develop] Creating agents


Subject: Re: [jade-develop] Creating agents
From: Stephen C. Upton (upton@mitre.org)
Date: Wed Sep 18 2002 - 15:23:15 MET DST


James,

I've attached some code I use for having an agent create another agent.
This is my StarterAgent that creates a set of other agents. You can
obviously ignore the stuff about the XML usage in the setup() method.
The creation of agents is in the CreateAgentsBehavior inner class. The
code works for JADE 2.5, so I don't know about 2.6. Also, it doesn't use
the ContentManager, which I believe is the recommended way of putting
together messages - just haven't refactored yet!

HTH
steve

James Cole wrote:

> Hi again, I'm having trouble making one of my agents create another
> agent. In the RMA source code, there is the following
> section: CreateAgent ca = new CreateAgent();
> if(containerName.equals(""))
> containerName = AgentManager.MAIN_CONTAINER_NAME;
> ca.setAgentName(agentName);
> ca.setClassName(className);
> ca.setContainer(new ContainerID(containerName, null));
> for(int i = 0; i<arg.length ; i++)
> ca.addArguments((Object)arg[i]);
>
> try {
> Action a = new Action();
> a.set_0(getAMS());
> a.set_1(ca);
> List l = new ArrayList(1);
> l.add(a); ACLMessage requestMsg = getRequest();
> requestMsg.setOntology(JADEAgentManagementOntology.NAME);
> fillMsgContent(requestMsg, l);
> addBehaviour(new AMSClientBehaviour("CreateAgent", requestMsg));
>
> }
> catch(FIPAException fe) {
> fe.printStackTrace();
> } I've tried to follow this lead but Action has no set_0 (AID) or
> set_1(CreateAgent) method. Looking through the JADE 2.6 API docs, I
> have not found a set_1(CreateAgent) method. The following
> code: String containerName = AgentManager.MAIN_CONTAINER_NAME;
>
> CreateAgent ca = new CreateAgent();
> ca.setAgentName(agentName);
> ca.setClassName(SAClassName);
> ca.setContainer(new ContainerID(containerName, null));
> ca.addArguments(""); does not create an agent that appears in
> the RMA GUI. Do I need to register the agent object that I have
> created? Can anybody help me out? Much appreciated, James




This archive was generated by hypermail 2a22 : Wed Sep 18 2002 - 15:21:20 MET DST