aea.skills.behaviours
This module contains the classes for specific behaviours.
SimpleBehaviour Objects
This class implements a simple behaviour.
__
init__
Initialize a simple behaviour.
Arguments:
act
: the act callable.kwargs
: the keyword arguments to be passed to the parent class.
setup
Set the behaviour up.
act
Do the action.
teardown
Tear the behaviour down.
CompositeBehaviour Objects
This class implements a composite behaviour.
CyclicBehaviour Objects
This behaviour is executed until the agent is stopped.
__
init__
Initialize the cyclic behaviour.
number_
of_
executions
Get the number of executions.
act_
wrapper
Wrap the call of the action. This method must be called only by the framework.
is_
done
Return True if the behaviour is terminated, False otherwise.
The user should implement it properly to determine the stopping condition.
Returns:
bool indicating status
OneShotBehaviour Objects
This behaviour is executed only once.
__
init__
Initialize the cyclic behaviour.
is_
done
Return True if the behaviour is terminated, False otherwise.
act_
wrapper
Wrap the call of the action. This method must be called only by the framework.
TickerBehaviour Objects
This behaviour is executed periodically with an interval.
__
init__
| __init__(tick_interval: float = 1.0, start_at: Optional[datetime.datetime] = None, **kwargs: Any) -> None
Initialize the ticker behaviour.
Arguments:
tick_interval
: interval of the behaviour in seconds.start_at
: whether to start the behaviour with an offset.kwargs
: the keyword arguments.
tick_
interval
Get the tick_interval in seconds.
start_
at
Get the start time.
last_
act_
time
Get the last time the act method has been called.
act_
wrapper
Wrap the call of the action. This method must be called only by the framework.
is_
time_
to_
act
Check whether it is time to act, according to the tick_interval constraint and the 'start at' constraint.
Returns:
True if it is time to act, false otherwise.
SequenceBehaviour Objects
This behaviour executes sub-behaviour serially.
__
init__
Initialize the sequence behaviour.
Arguments:
behaviour_sequence
: the sequence of behaviour.kwargs
: the keyword arguments
current_
behaviour
Get the current behaviour.
If None, the sequence behaviour can be considered done.
Returns:
current behaviour or None
act
Implement the behaviour.
is_
done
Return True if the behaviour is terminated, False otherwise.
State Objects
A state of a FSMBehaviour.
A State behaviour is a simple behaviour with a special property 'event' that is opportunely set by the implementer. The event is read by the framework when the behaviour is done in order to pick the transition to trigger.
__
init__
Initialize a state of the state machine.
event
Get the event to be triggered at the end of the behaviour.
is_
done
Return True if the behaviour is terminated, False otherwise.
reset
Reset initial conditions.
FSMBehaviour Objects
This class implements a finite-state machine behaviour.
__
init__
Initialize the finite-state machine behaviour.
is_
started
Check if the behaviour is started.
register_
state
Register a state.
Arguments:
name
: the name of the state.state
: the behaviour in that state.initial
: whether the state is an initial state.
Raises:
ValueError
: if a state with the provided name already exists.
register_
final_
state
Register a final state.
Arguments:
name
: the name of the state.state
: the state.
Raises:
ValueError
: if a state with the provided name already exists.
unregister_
state
Unregister a state.
Arguments:
name
: the state name to unregister.
Raises:
ValueError
: if the state is not registered.
states
Get all the state names.
initial_
state
Get the initial state name.
initial_
state
Set the initial state.
final_
states
Get the final state names.
get_
state
Get a state from its name.
act
Implement the behaviour.
is_
done
Return True if the behaviour is terminated, False otherwise.
register_
transition
Register a transition.
No sanity check is done.
Arguments:
source
: the source state name.destination
: the destination state name.event
: the event.
Raises:
ValueError
: if a transition from source with event is already present.
unregister_
transition
Unregister a transition.
Arguments:
source
: the source state name.destination
: the destination state name.event
: the event.
Raises:
ValueError
: if a transition from source with event is not present.