jade.core.behaviours
Class NonDeterministicBehaviour
java.lang.Object
|
+--jade.core.behaviours.Behaviour
|
+--jade.core.behaviours.ComplexBehaviour
|
+--jade.core.behaviours.NonDeterministicBehaviour
- public class NonDeterministicBehaviour
- extends ComplexBehaviour
Composite behaviour with non deterministic children scheduling.
It is a ComplexBehaviour that executes its children
behaviours non deterministically, and it terminates when a
particular condition on its sub-behaviours is met. Static
Factory Methods are provided to get a
NonDeterministicBehaviour that ends when all its
sub-behaviours are done, when any sub-behaviour terminates or when
N sub-behaviours have finished.
- Author:
- Giovanni Rimassa - Universita` di Parma
- See Also:
- Serialized Form
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
NonDeterministicBehaviour
protected NonDeterministicBehaviour(int endCondition)
- Protected constructor: use static Factory Methods
instead.
NonDeterministicBehaviour
protected NonDeterministicBehaviour(Agent a,
int endCondition)
- Protected constructor: use static Factory Methods
instead.
bodyAction
protected boolean bodyAction()
- Nondeterministic policy for children scheduling. This method
executes children behaviours one at a time, in a round robin
fashion.
- Overrides:
- bodyAction in class ComplexBehaviour
- See Also:
ComplexBehaviour.bodyAction()
reset
public void reset()
- Resets this behaviour. This methods puts a
NonDeterministicBehaviour back in initial state,
besides calling reset() on each child behaviour
recursively.
- Overrides:
- reset in class ComplexBehaviour
handle
protected void handle(Behaviour.RunnableChangedEvent rce)
- Handle block/restart notifications. A
NonDeterministicBehaviour object is blocked
only when all its children behaviours are blocked and
becomes ready to run as soon as any of its children is
runnable. This method takes care of the various possibilities.
- Parameters:
rce - The event to handle.- Overrides:
- handle in class ComplexBehaviour
block
public void block()
- Blocks this behaviour.
- Overrides:
- block in class Behaviour
createWhenAll
public static NonDeterministicBehaviour createWhenAll()
- Static Factory Method. This method creates a new
NonDeterministicBehaviour that terminates when
all its children end. It does not set the owner
agent for this behaviour.
- Returns:
- A new
NonDeterministicBehaviour.
createWhenAll
public static NonDeterministicBehaviour createWhenAll(Agent a)
- Static Factory Method. This method creates a new
NonDeterministicBehaviour that terminates when
all its children end. It sets the owner agent for
this behaviour.
- Parameters:
a - The agent this behaviour belongs to.- Returns:
- A new
NonDeterministicBehaviour.
createWhenAny
public static NonDeterministicBehaviour createWhenAny()
- Static Factory Method. This method creates a new
NonDeterministicBehaviour that terminates when
any among its children ends. It does not set the
owner agent for this behaviour.
- Returns:
- A new
NonDeterministicBehaviour.
createWhenAny
public static NonDeterministicBehaviour createWhenAny(Agent a)
- Static Factory Method. This method creates a new
NonDeterministicBehaviour that terminates when
any among its children ends. It sets the owner
agent for this behaviour.
- Parameters:
a - The agent this behaviour belongs to.- Returns:
- A new
NonDeterministicBehaviour.
createWhenN
public static NonDeterministicBehaviour createWhenN(int howMany)
- Static Factory Method. This method creates a new
NonDeterministicBehaviour that terminates when
at least N of its children end. It does not set
the owner agent for this behaviour.
- Parameters:
howMany - The number of children behaviour that must
terminate to make this NonDeterministicBehaviour
finish.- Returns:
- A new
NonDeterministicBehaviour.
createWhenN
public static NonDeterministicBehaviour createWhenN(Agent a,
int howMany)
- Static Factory Method. This method creates a new
NonDeterministicBehaviour that terminates when
at least N of its children end. It sets the owner
agent for this behaviour.
- Parameters:
a - The agent this behaviour belongs to.howMany - The number of children behaviour that must
terminate to make this NonDeterministicBehaviour
finish.- Returns:
- A new
NonDeterministicBehaviour.