Add a more complex behavior
This PR adds the FSMBehavior which is a Finite State Machine.
When creating a FSMBehavior, you have to:
- define states and associated behaviors
- define transitions between states
- define which state is the initial one and which states are the final ones
Each time the FSM state changes, the associated behavior is instantiated.
Transition are functions that take the previous state's behavior result in parameter and return True
if the transition to the new state is possible.
I also changed how behaviors are managed by the agent:
- when a behavior is added, it is immediately scheduled
- every 5s, the agent perform some cleanup and remove finished behaviors
Now behaviors and agents are using a synchronization primitive to check the agent state and are automatically woke up when the agent's state is whatever they expect. No more explicit sleeping.