christinne
2014-06-16 21:06:15 UTC
Hi all,
I have a simple agent class AgentA and in the setup method I add a
BehaviourA that extends a OneShotBehaviour. In the behaviour class I have a
private variable int X=0, and a method (changeParam) that makes this
variable from 0 to 1. I would like to know if there is a way in witch I can
pass this parameter from this behaviour class into the setup method (from
where I add this behaviour).
This is a simplified logic of what I tried to do, but without success.
But I have noticed that in the setup method , after adding the behaviour and
getting the 'count' variable with value = 0 , somehow the behavior method is
executed but I didn't understand in which direction, what is the flow
between setup method and behaviour methods. Can someone please clarify also
this for me?
Thank you
public class Nucleus extends Agent {
public int count = 0;
protected void setup() {
// ..
LookForObjectives behavLookForObjective = new
LookForObjectives(this, count);
this.addBehaviour(behavLookForObjective);
this.count = behavLookForObjective.getObj(); // < --- what I
want is that in this point the variable this.count = to be equal to 1 but
is 0
// ...
}
}
public class LookForObjectives extends OneShotBehaviour {
private int obj = 0;
private int received_obj = 0;
public LookForObjectives(Nucleus param0, int param1) {
super(param0);
this.received_obj = param1;
}
public changeParam (int nr){
if (nr ==0) nr = 1;
return nr;
}
public void action() {
obj = changeParam(received_obj);
}
public int getObj(){
return this.obj;
}
}
--
View this message in context: http://jade.17737.x6.nabble.com/Passing-parameters-from-Behavior-to-Agent-tp5002613.html
Sent from the JADE - Dev mailing list archive at Nabble.com.
I have a simple agent class AgentA and in the setup method I add a
BehaviourA that extends a OneShotBehaviour. In the behaviour class I have a
private variable int X=0, and a method (changeParam) that makes this
variable from 0 to 1. I would like to know if there is a way in witch I can
pass this parameter from this behaviour class into the setup method (from
where I add this behaviour).
This is a simplified logic of what I tried to do, but without success.
But I have noticed that in the setup method , after adding the behaviour and
getting the 'count' variable with value = 0 , somehow the behavior method is
executed but I didn't understand in which direction, what is the flow
between setup method and behaviour methods. Can someone please clarify also
this for me?
Thank you
public class Nucleus extends Agent {
public int count = 0;
protected void setup() {
// ..
LookForObjectives behavLookForObjective = new
LookForObjectives(this, count);
this.addBehaviour(behavLookForObjective);
this.count = behavLookForObjective.getObj(); // < --- what I
want is that in this point the variable this.count = to be equal to 1 but
is 0
// ...
}
}
public class LookForObjectives extends OneShotBehaviour {
private int obj = 0;
private int received_obj = 0;
public LookForObjectives(Nucleus param0, int param1) {
super(param0);
this.received_obj = param1;
}
public changeParam (int nr){
if (nr ==0) nr = 1;
return nr;
}
public void action() {
obj = changeParam(received_obj);
}
public int getObj(){
return this.obj;
}
}
--
View this message in context: http://jade.17737.x6.nabble.com/Passing-parameters-from-Behavior-to-Agent-tp5002613.html
Sent from the JADE - Dev mailing list archive at Nabble.com.