mirror of
https://github.com/avatao-content/test-tutorial-framework
synced 2024-11-12 19:47:18 +00:00
Update docs with FSM stuff
This commit is contained in:
parent
c9439f547b
commit
7949d94493
23
README.md
23
README.md
@ -201,6 +201,29 @@ Should you want to avoid using a feature, you can just delete the appropriate ev
|
||||
|
||||
It is genarally a good idea to separate these files from the rest of the stuff in `solvable`, so it is a good practice to create an `src` directory.
|
||||
|
||||
### FSM
|
||||
|
||||
A good state machine is the backbone of a good TFW challenge.
|
||||
|
||||
There are two ways to define a state machine:
|
||||
- Using a YAML configuration file
|
||||
- Implementing it in Python by hand
|
||||
|
||||
The first option enables you to handle FSM callbacks and custom logic in any programming language (not just Python) and is generally really easy to work with.
|
||||
You should choose this method unless you have good reason not to.
|
||||
This involves creating your YAML file (see `test_fsm.yml` for an example) and parsing it using our `YamlFSM` class (see `event_handler_main.py` for an example).
|
||||
|
||||
The second option allows you to implement your FSM in Python, using the transitions library.
|
||||
To do this just subclass our `FSMBase` class or use our `LinearFSM` class for simple machines (see `test_fsm.py` for an example).
|
||||
|
||||
In your FSM you can define callbacks for states and transitions.
|
||||
State callbacks:
|
||||
- `on_enter`
|
||||
- `on_exit`
|
||||
Transition callbacks:
|
||||
- `before`
|
||||
- `after`
|
||||
|
||||
## Baby steps
|
||||
|
||||
When creating your own challenge the process should be the following:
|
||||
|
Loading…
Reference in New Issue
Block a user