behave-graph
behave-graph copied to clipboard
Maybe easier to use a stack to manage execution rather than work queue?
I am starting to wonder if the main method of evaluating these behavior graphs is actually a stack rather than a work queue.
The reason why a stack would be easier is:
- The sequence node would just put its children on the stack in reverse order.
- The for-loop would put itself on the stack and then its loopBody. When it gets executed again after the loopBody is done, it will put itself again on the stack and then the next iteration of loopBody.
I think that once the stack is completed, you go back to look for new events?
I think this doesn't handle the case where you want to "break" a for-loop. In those cases you either need a loop in the graph (non-DAG) or as Unity does it, it has an event that is raised in the loopBody and then executes and sets a "break" flow socket on the for-loop (but this violates the stack execution model, as the events wouldn't be fired until the for-loop is done.)
Thus this isn't yet sufficient.