1. What a Behavior Tree Is

A Behavior Tree, or BT, is a common way to structure AI decision logic. It represents behavior as a tree, and on each update tick, the tree is evaluated from the root downward. Each node typically returns one of three states: SuccessFailure, or Running. Parent nodes then decide what to do next based on those child results.

In Flow Core, BT is not treated as an isolated subsystem. It is deeply embedded into the unified Flow graph model. BtRoot is itself a node inside the Flow graph, which means BT results can directly continue into later Flow logic without requiring a separate bridging layer between systems.

Compared with workflows where behavior trees, state machines, and flow graphs are split into separate domains, this integrated model can be a better fit for projects that need multiple paradigms to work together, while also reducing context-switching between tools and systems.


2. Node States

Flow Core BT nodes support the following runtime states:

State Meaning
Success The node completed successfully
Failure The node failed
Running The node is still executing and will continue on later ticks
Abort The branch was cancelled or forcefully terminated, and the tree stops immediately

Abort is intentionally different from ordinary failure. It represents a stronger control-level stop, which is useful for cancellation, interruption, or protective shutdown scenarios.


3. Node Hierarchy

The BT node structure in Flow Core looks like this:

BtRoot (driver)
  └─ Composite
       ├─ Sequence
       ├─ Selector
       └─ Parallel
            └─ Decorator
                 └─ Leaf
                      ├─ BtCondition
                      ├─ BtAction
                      ├─ BtLoop
                      └─ BtSubGraph

This overall structure is familiar to anyone who has used behavior trees before. Where Flow Core pushes further is in runtime control, async scheduling, interruption rules, and direct integration with Flow execution.


4. Tick Runtime Model

4.1 BtRoot as the Driver

The entire tree is driven by BtRoot. It runs inside Flow Core’s asynchronous execution chain and checks whether the configured update interval has been reached. When it has, a full tree traversal is triggered, which counts as one root tick.

while (tree is Running):
    wait 1 frame
    check Cancel / ForceSuccess / ForceFailure
    if update interval reached:
        RootTickIndex++
        evaluate Observer Aborts
        execute TickBtRootChildren()
    if result != Running:
        clean up all tasks and return result

Supported update interval modes include: