Overview
Choosing a Logic Model
Match Flow, FSM, Behavior Tree, Stack, or GOAP to the responsibility you need to express.
- Audience
- System designers and developers
- Time
- 10 minutes
- Requires
- Flow Core in Five Concepts
- Modules
- Flow, FSM, Behavior Tree, Stack, GOAP
On this page
Choose a model by the question it must answer at runtime. Flow Core modules can cooperate, but each responsibility should have one clear owner.
Decision table
| Model | Runtime question | Strong fit | Poor fit |
|---|---|---|---|
| Flow | What happens next after this event? | Ordered work, waits, side effects, signals, UI, handoffs | Repeated priority reevaluation |
| FSM | Which long-lived mode is active? | Patrol/Combat, locomotion modes, interaction phases | Large priority trees |
| Behavior Tree | Which valid behavior has highest priority now? | AI decisions, ordered checks, reactive fallback | Long cinematic or UI timelines |
| Stack | Which temporary layer is currently on top? | Menus, input contexts, dialogue overlays, inspect mode | Concurrent state families |
| GOAP | Which action sequence can reach the desired facts at acceptable cost? | Dynamic planning from world facts | Fixed short sequences |
Start with normal Flow
If a button click should validate input, play feedback, wait, and open another screen, a normal Flow owns that sequence clearly. Do not add a state or planner when the route is already known.
Add FSM for persistent identity
Use FSM when the active mode changes what behavior is allowed. A character may be in Patrol, Combat, or Stunned. The state owns entry, active behavior, transitions, and exit.
Add a Behavior Tree for priority
Use a Behavior Tree when choices must be checked again as facts change. A combat tree may prefer Attack, then Chase, then Take Cover, then Idle. The tree owns the decision; normal Flow can perform visible consequences after the result.
Add Stack for temporary coverage
Use Stack when a mode is covered and later restored in reverse order. Gameplay can be covered by Pause, then Options; popping Options resumes Pause, and popping Pause resumes Gameplay.
Add GOAP for discovered sequences
Use GOAP when the authored content defines possible actions, but the planner should discover a route from current facts to desired facts. If the action order is always known, authoring the sequence directly is usually clearer.
Compose without overlapping ownership
A common composition is:
- Flow receives an event and activates Combat.
- FSM owns whether Combat remains active.
- A Behavior Tree inside Combat chooses Attack, Chase, or Cover.
- Flow performs animation, camera, audio, and UI consequences.
- Blackboard values carry shared facts such as
TargetVisibleandCanAttack.