Concept
The ActionDrivenAgentis is an agent implementation with a fully flexible and dynamic behavior.
It relies on an external strategy, IActionPreparator, to provide an action which is to be executed. This action can be simple or complex, its semantics are left to the IActionPreparator.
The IActionPreparator constructs an action based on:
- The agent's state, viewed as a set of properties;
- The agent's environment, viewed as a queryable interface.
With such a solution, the behavior of an agent may dynamically change during the computation, accordingly to a change of its state or environment. This behavior can even be fully switched by changing the strategy object. The agent now only provides infrastructure for the computation, the essence of which is delegated to a simpler and freely configurable object.
Available implementations
JAgE provides several useful implementations of the IActionPreparator interface.
ActionPreparatorChain
This class allows you to build a tree of IActionPreparators, according to the Composite pattern. It delegates action creation to its children and return a complex one, containing those created by them. Instances of this class are configurable from xml.
SingleActionPreparator
This class returns a constant action, regardless of the context. Instances of this class are configurable from xml.
MultipleActionPreparator
This class returns a complex action, containing several constant ones, regardless of the context. Instances of this class are configurable from xml.
Summary
The following diagram illustrates the solution described here.