Flow Graph, BDS and Ability
Separate how a behavior executes from which behavior should execute now.
Four core concepts
| Concept | Responsibility | Examples |
|---|---|---|
| Flow Graph | Organize execution across frames | Entry → Action → child graph / BDS → Return |
| BDS | Evaluate candidates every frame | Gates, base scores, bonuses and Evaluation |
| Ability | A candidate participating in a decision | Conditions, scoring Context and Execution |
| Action | Perform a concrete operation | Move, wait, invoke a method or set a variable |
How one BDS works
Sequence: visit candidates in order
Evaluate Ability 1…N in configuration order. This is evaluation order, not execution of all behaviors, and not an extra execution Sequence node to add to the graph.
Ability: gate, then score
A failed gate excludes the candidate. Eligible candidates calculate their base score plus contextual bonuses using the logical frame’s data.
Decision: select an eligible candidate
Choose the highest score among available candidates. The current implementation keeps the first encountered candidate on an equal maximum, so ordering must be stable. Disabled/cooldown eligibility still applies.
Selected Ability: apply switching policy
A leader is not automatically the executor. After completion, another candidate may start; while the current behavior is unfinished, normal candidates wait and eligible forced-interrupt leaders can exit the old branch.
Execution: perform concrete behavior
The behavior may be a complex flow graph or a child BDS. Leaf Actions operate through Enter / Update / Exit. Active parent BDS layers continue evaluating on subsequent frames.
Evaluate before executing
An Ability first checks its gate. Eligible candidates calculate a base score and conditional bonuses. Evaluation compares those scores to identify the current leader. The leader and the executing Ability can differ: a normal candidate waits for the current behavior to finish; an eligible leader with forced interruption may replace it.
How nested decisions cooperate
In Acquire → Combat → Defense → Evade, all active BDS layers continue evaluating conditions and scores. Concrete Actions execute along the current leaf branch. When Acquire chooses an eligible interrupting alternative, the old branch and its descendants exit together. Combat and Defense can similarly replace their own descendants.
An Action is not just one function call
Enter initializes an Action, Update continues it on later frames, and Exit cleans it up when the graph leaves or interrupts the node. Several Actions can share a node; every unfinished updating Action runs until all have finished. Use one node for concurrent movement and firing, or several connected nodes for an ordered approach → reload → fire → return sequence.