Tutorial 3 ACL: Agent Communication Language Dr. Fuhua Lin School of Computing and Information Systems Athabasca University, Alberta, Canada Oct. 27, 2009
Initiate a conversation using SimpleAchieveREInitiator public class SimpleRequestInitiator extends Agent { static class MarriageProposer extends SimpleAchieveREInitiator { protected MarriageProposer(Agent agent, ACLMessage msg) { super(agent, msg); } … … 2. Message Sending In the parent class 1. Message construction } Reference: http://jade.tilab.com/doc/programmersguide.pdf
Using Standard Handlers as methods of MarriageProposer protected void handleAgree(ACLMessage msg) { System.out.println(myAgent.getLocalName() + ": Ha Ha! " + msg.getSender().getLocalName() +” has already agreed to marry me. I'm so excited!"); } protected void handleRefuse(ACLMessage msg) { System.out.println(myAgent.getLocalName() + ": Oh no! " + msg.getSender().getLocalName() +rejected me. I feel sad."); } protected void handleInform(ACLMessage msg) { System.out.println(myAgent.getLocalName() + ":" + msg.getSender().getLocalName() +" has informed me of the status of my request." + " They said : " + msg.getContent()); } protected void handleNotUnderstood(ACLMessage msg){ System.out.println(myAgent.getLocalName() + ":" + msg.getSender().getLocalName() + " has indicated that they didn't understand."); } protected void handleOutOfSequence(ACLMessage msg) { System.out.println(myAgent.getLocalName() + ":" + msg.getSender().getLocalName() + "has sent me a message which I wasn't" + " expecting in this conversation"); }
SimpleRequestResponder