3

I want to design two agents Agent1 send two message values in different times to Agent2. Agent2 then implement an action depending on the received values.

Using Jade, I tried to write the following :

-Agent1 with two addBehaviour(new TickerBehaviour(this, time) methods

-Agent2 has addBehaviour(new CyclicBehaviour()

When I run the program I get nothing.. The same program works if I only send one value..

Any suggestion ?

Thanks

Nada Ghanem
  • 451
  • 6
  • 16

2 Answers2

6

there is no need to create both the cyclic and the ticker behaviours you only have to run the receiver agent first, then send your message, the following example is tested :

import jade.core.Agent;
import jade.lang.acl.ACLMessage;


public class AgentReceiver extends Agent {
    public void setup(){
      ACLMessage msg = null;
      msg = blockingReceive();
      System.out.println(msg.getContent());
    } 
}

then run the sender one :

import jade.core.AID;
import jade.core.Agent;
import jade.lang.acl.ACLMessage;


public class AgentSender extends Agent {
  public void setup(){
      ACLMessage message = new ACLMessage(ACLMessage.INFORM);
      message.addReceiver(new AID("AgentReceiver", AID.ISLOCALNAME));
      message.setContent("Hello The World");
      send(message);
  }
}
steevn
  • 242
  • 2
  • 8
0
  1. Without your source-code it will be difficult to find your error.
  2. The solution proposed by steevn works only if you want to send and receive a msg once because everything is done in the setup. So it does not correspond to what you are looking for.
  3. It is not necessary to have a cyclic in reception, a simpleBehaviour with done() at false is sufficient.

see this example

Hc.
  • 86
  • 4