Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package examples;
- import jade.core.Agent;
- import jade.core.behaviours.CyclicBehaviour;
- import jade.wrapper.AgentController;
- import jade.wrapper.ContainerController;
- public class CounterAgent extends Agent {
- private int round = 0;
- private boolean finished = true;
- protected void setup() {
- addBehaviour(new MyCyclicBehaviour(this));
- addBehaviour(new AnotherCyclicBehaviour(this));
- ContainerController c = getContainerController();
- try {
- AgentController a = c.createNewAgent("IVAN", "examples.CounterAgent", null);
- a.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- class MyCyclicBehaviour extends CyclicBehaviour {
- public MyCyclicBehaviour(Agent agent) {
- super(agent);
- }
- @Override
- public void action() {
- System.out.println("Inside ACTION:: " + round++);
- }
- }
- class AnotherCyclicBehaviour extends CyclicBehaviour {
- public AnotherCyclicBehaviour(Agent agent) {
- super(agent);
- }
- @Override
- public void action() {
- if (round == 21) {
- this.myAgent.doDelete();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement