JADE Behaviors

JADE provides a concept called a Behavior. A Behavior is a means by which agents can execute actions, such as sending messages. Two very common types of behaviors are the Ticker Behavior (TickerBehaviour.java) and the CyclicBehavior (CyclicBehaviour.java).

TickerBehavior

This abstract class implements a behavior that periodically executes a user-defined piece of code. The user is expected to extend this class re-defining the method onTick() and including the piece of code that must be periodically executed into it. In essence, this is very similar to a scheduled task or a Unit cron task. This behavior is very useful for monitoring states periodically.

CyclicBehavior

This class implements an atomic behaviour that must be executed forever. This abstract class can be extended by application programmers to create behaviours that keep executing continuously (e.g. simple reactive behaviours).

In both cases, the expectation is that the application programmer overrides the action() method in order to provide application specific implementation. Agents can have any number of behaviors and sub-behaviors executing at different internals. The only thing to remember is that behaviors, once executed, will execute until completion. This makes the model very simple and makes sharing of state very straightforward.

Thanks,

Luis Atencio

Leave a Comment