I have a Behavior Tree set up for my AI, which I’m rewriting as a StateTree so I can learn it and see what I like better. In a Behavior Tree, you have the Observer Abort option to abort other parts of the tree when a condition is met. This allows you to create loosely coupled branches of the tree (i.e. states) that don’t care about each other. I was surprised to find that StateTrees seemingly don’t offer similar functionality and require the states to be tightly coupled to each other, unless I’m missing something?
This tight coupling comes from the Events and Transitions you have to use. Every other state that needs to abort has to have a transition based on the event that then points to the new state. This grows increasingly complex as you get more states with more events and transitions. I’m trying to create an AI that can be in different “states” without these states needing to be tightly coupled to each other. A problem that is elegantly solved with a Behavior Tree.
For example, you might have an AI that can perform a task (Task State) when it is given a task to do by the player. In the meantime, it can do other things, Idle State, Rest State, etc. In a Behavior Tree, when the AI is assigned a task, the branch (state) to handle this can simply abort all lower priority branches. It doesn’t care what it is aborting and the other branches do care who aborted them. How do I do this in a StateTree? If I use events, then I need to set up a transition on every other state to transition to the Task State on this event. If I later add another state, I have to remember to transition it as well. If I later add another type of event (and state), I have to remember to update every state with every combination of transitions based on what can abort what. I don’t understand how this can scale and am surprised I can’t find anyone discussing this, so I wonder if I’m missing something?