Discussion:
[jade-develop] Question about the "ThanksAgent" example in Jade pack
quangmuop
2014-01-16 04:36:03 UTC
Permalink
From the "ThanksAgent" example (in Jade package, I embeded this file in my
question), I create 1 more agent in the same container with agent 1, call
agent 3. Then, I want to send message from agent 1 to agent 3, i add code
like here:

...../the code of ThanksAgent file/.....
public void action() {
//t1 send message to t3
String t1AgentName = getLocalName()+"t1";
String t3AgentName = getLocalName()+"t3";
ACLMessage tmsg = new
ACLMessage(ACLMessage.INFORM);
tmsg.setContent("Hello friend");
tmsg.addReceiver(new
AID(t3AgentName,AID.ISLOCALNAME));
myAgent.send(tmsg);

//reply from t3
ACLMessage rems = myAgent.receive();
if(rems!=null){
System.out.println(" - " +
myAgent.getLocalName() + " received: " + rems.getContent());
ACLMessage reply = new
ACLMessage(ACLMessage.INFORM);
//
reply.setPerformative(ACLMessage.INFORM);
reply.setContent("T3 reply!");
myAgent.send(reply);
}
block();

...../the code of ThanksAgent file/.....

but isnt doesnt work. I think the compiler doesnt distinct the variable
"myAgent" is belong to what agent, but I cant not use *t1.send(tmsg)* or
*t3.send(reply)*
Anyone can explain me how to solve the problem or edit the code above?
And one more question, how can I send message from agent 1 to agent 2, it
means how to send message between differ container and thank if give me an
example.
Thank you very much! ThanksAgent.java
<http://jade.17737.x6.nabble.com/file/n5002411/ThanksAgent.java>



--
View this message in context: http://jade.17737.x6.nabble.com/Question-about-the-ThanksAgent-example-in-Jade-pack-tp5002411.html
Sent from the JADE - Dev mailing list archive at Nabble.com.
Caire Giovanni
2014-01-17 12:46:14 UTC
Permalink
Hi,

Please specify what the problem is: is it a compilation problem or a runtime problem? In any case please provide a detailed description of what actually happens and include any error message or stack trace.

I also suggest reading the JADE Programming Tutorial for beginners that provides a good explanation of how to make agents execute behaviours and exchange messages.

Bye,

Giovanni

-----Messaggio originale-----
Da: jade-develop-bounces at avalon.tilab.com [mailto:jade-develop-bounces at avalon.tilab.com] Per conto di quangmuop
Inviato: gioved? 16 gennaio 2014 05:36
A: jade-develop at avalon.tilab.com
Oggetto: [jade-develop] Question about the "ThanksAgent" example in Jade pack
...../the code of ThanksAgent file/.....
public void action() {
//t1 send message to t3
String t1AgentName = getLocalName()+"t1";
String t3AgentName = getLocalName()+"t3";
ACLMessage tmsg = new ACLMessage(ACLMessage.INFORM);
tmsg.setContent("Hello friend");
tmsg.addReceiver(new AID(t3AgentName,AID.ISLOCALNAME));
myAgent.send(tmsg);

//reply from t3
ACLMessage rems = myAgent.receive();
if(rems!=null){
System.out.println(" - " +
myAgent.getLocalName() + " received: " + rems.getContent());
ACLMessage reply = new ACLMessage(ACLMessage.INFORM);
//
reply.setPerformative(ACLMessage.INFORM);
reply.setContent("T3 reply!");
myAgent.send(reply);
}
block();

...../the code of ThanksAgent file/.....

but isnt doesnt work. I think the compiler doesnt distinct the variable "myAgent" is belong to what agent, but I cant not use *t1.send(tmsg)* or
*t3.send(reply)*
Anyone can explain me how to solve the problem or edit the code above?
And one more question, how can I send message from agent 1 to agent 2, it means how to send message between differ container and thank if give me an example.
Thank you very much! ThanksAgent.java
<http://jade.17737.x6.nabble.com/file/n5002411/ThanksAgent.java>



--
View this message in context: http://jade.17737.x6.nabble.com/Question-about-the-ThanksAgent-example-in-Jade-pack-tp5002411.html
Sent from the JADE - Dev mailing list archive at Nabble.com.
_______________________________________________
jade-develop mailing list
jade-develop at avalon.tilab.com
https://avalon.cselt.it/mailman/listinfo/jade-develop
UNSUBSCRIBE INSTRUCTIONS AT
http://jade.tilab.com/community-mailinglist.htm

Loading...