State machines
In Structure, a strategy can expose states to make its behavior easier to understand. Those states describe the mode the strategy is currently in, and the decision tree determines when it stays there or moves somewhere else.
In the editor
Section titled “In the editor”When you open a strategy revision, the states live in their own pane. This is where you define the named modes the revision can move between.
Typical examples are states like:
WaitingLongShortCooldown
Decision tree
Section titled “Decision tree”The decision tree is where the strategy decides whether it should stay in its current state, move to another one, or prepare the values an action needs.
You usually start from a simple branch. The branch condition expects a Bool data type fed into a Label node in the graph.
For the sake of this example we are feeding in a ConstBool but real strategies would use computed values to switch state dynamically.
You can next branches as much as you want, giving you endless possible states.
Once your state machine is set up, you can define actions to take for each state.
Like for state branch conditions, quantity must be fed into a Label node as a Numeric data type
Practical takeaway
Section titled “Practical takeaway”State machines are easiest to understand when each state has a clear purpose and each decision-tree branch has a clear reason. If you can explain why the strategy changes state, the revision is usually much easier to trust.
Next step
Section titled “Next step”Once the states are clear, the next question is what the strategy needs to store between evaluations. That is the focus of Memory slots.