Skip to content

Commit 02e8c37

Browse files
committed
docs: Add conceptual overview of behavior trees and related resources
- Introduced a new page detailing the conceptual overview of behavior trees, including their principles, mechanisms, and applications in AI and robotics. - Added a journal entry for December 27, 2025, featuring the Diataxis Conceptual overview and linking to the Bonsai project by Kristoffer Rakstad for a Rust implementation of behavior trees. - Created a new page for Kristoffer Rakstad's GitHub project, enhancing the documentation on behavior trees and their implementations.
1 parent c10bb99 commit 02e8c37

File tree

3 files changed

+88
-3
lines changed

3 files changed

+88
-3
lines changed

journals/2025_12_27.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- [d-bucur/awesome-bevy: A curated list of Bevy resources](https://github.com/d-bucur/awesome-bevy?tab=readme-ov-file)
44
- [[Dimforge]]
55
- [[Rapier]]
6-
- [[Person/Kristoffer Rakstad]]
7-
- [Sollimann/bonsai: Rust implementation of behavior trees for deterministic AI](https://github.com/Sollimann/bonsai)
8-
-
6+
- Added Diataxis Conceptual overview in [[AI/Behavior/Tree]]s
7+
- {{embed [[Person/Kristoffer Rakstad/GitHub/bonsai]]}}
8+
-
9+
-

pages/AI___Behavior___Tree.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
tags:: [[Diataxis/Explanation]]
2+
3+
- # Behavior Trees Conceptual Overview
4+
- ## Overview
5+
- **Behavior trees (BTs)** are a well-established concept in **computer science and AI**, completely independent of any specific implementation
6+
- They are hierarchical, composable control structures used to define agent behavior through a tree of decision nodes
7+
- Designed to be **reactive**, **deterministic**, and **readable by humans**
8+
- Provide a structured way to encode both control flow and policy together
9+
- ![Image](https://towardsdatascience.com/wp-content/uploads/2020/12/1QKcHS8xnKX0mDeJp1jEiAA.png)
10+
- ![Image](https://edirlei.com/aulas/game-ai/GAME_AI_Lecture_08_Behavior_Trees_2018_files/img_07.png)
11+
- ![Image](https://robohub.org/wp-content/uploads/2021/08/bt_vs_fsm.png)
12+
- ![Image](https://www.researchgate.net/publication/312869797/figure/fig4/AS%3A1039702882795522%401624895892920/A-behavior-tree-including-selector-sequence-condition-and-action-nodes.png)
13+
- ## Context
14+
- **Historical Development**: Behavior trees emerged in the early 2000s, primarily from **game AI**, as a response to limitations in:
15+
- Finite State Machines (FSMs)
16+
- Hierarchical FSMs
17+
- Hard-coded decision logic
18+
- **Problem Addressed**: Traditional FSMs became unwieldy for complex NPC behaviors, leading to "spaghetti state machines" that were difficult to maintain and debug
19+
- **Adoption**: Popularized by studios like **LucasArts**, **Bungie**, and **EA**, with a canonical reference being Isla, D. "Handling Complexity in the Halo 2 AI." GDC 2005
20+
- **Current Relevance**: Now widely used in:
21+
- Game engines (Unreal Engine, Unity)
22+
- Robotics and autonomous systems (ROS/ROS2 ecosystems)
23+
- Safety-critical applications requiring deterministic, explainable behavior
24+
- Modern AI systems as high-level controllers for reinforcement learning and planning systems
25+
- ## Key Principles
26+
- **Hierarchical Structure**: Behavior trees organize decisions in a tree structure, allowing complex behaviors to be decomposed into simpler components
27+
- **Composability**: Simple behaviors can be combined into more complex behaviors through composition
28+
- **Reactivity**: BTs can respond to changing conditions and environment states
29+
- **Determinism**: Given the same inputs and state, a behavior tree produces the same outputs
30+
- **Human Readability**: The tree structure is more intuitive and maintainable than large state machines
31+
- **Tick-Based Execution**: BTs use a tick-based execution semantics where the tree is evaluated periodically
32+
- **Small Node Set**: Uses a closed set of node types (Sequence, Selector, Parallel, Decorators, Actions/Conditions) that can express complex behaviors
33+
- ## Mechanism
34+
- Behavior trees execute through a **tick-based evaluation** process:
35+
- Starting from the root, nodes are evaluated in order
36+
- Each node returns a status: Success, Failure, or Running
37+
- Control flow is determined by composite nodes (Sequence, Selector, Parallel)
38+
- **Core Node Types**:
39+
- **Sequence**: Executes children in order until one fails (all must succeed)
40+
- **Selector**: Executes children in order until one succeeds (at least one must succeed)
41+
- **Parallel**: Executes multiple children simultaneously
42+
- **Decorators**: Modify the behavior of child nodes (invert, repeat, etc.)
43+
- **Actions/Conditions**: Leaf nodes that perform actual work or check conditions
44+
- **Execution Flow**:
45+
- The tree is ticked from the root
46+
- Status propagates up the tree based on node semantics
47+
- Running nodes maintain state between ticks
48+
- The tree can be interrupted and resumed based on conditions
49+
- **Control Flow + Policy**: Unlike pure control structures, BTs encode both the decision logic (control flow) and the policy (what actions to take) in a single structure
50+
- ## Examples
51+
- ### Game AI
52+
- NPCs in games use BTs to determine behaviors like:
53+
- Patrol routes (Sequence of waypoints)
54+
- Combat decisions (Selector between attack, defend, retreat)
55+
- Complex behaviors combining movement, combat, and interaction
56+
- ### Robotics
57+
- Robot control architectures use BTs for:
58+
- Task decomposition (breaking complex tasks into simpler actions)
59+
- Safety-critical behaviors (ensuring deterministic responses)
60+
- Explainable autonomy (humans can understand and verify robot decisions)
61+
- ### Modern AI Systems
62+
- **BT + RL Hybrids**: Behavior trees provide high-level structure while reinforcement learning optimizes low-level actions
63+
- **BT Compilation from Planners**: Automated planners generate behavior trees for execution
64+
- **Formal Verification**: BTs can be formally verified for safety properties
65+
- **Runtime BT Synthesis**: Systems that generate or modify BTs at runtime based on conditions
66+
- ### Implementation Example: [[Person/Kristoffer Rakstad/GitHub/bonsai]]
67+
- The **Bonsai** project provides a **Rust-native**, strongly typed implementation
68+
- Demonstrates BTs' suitability for:
69+
- Embedded systems
70+
- Robotics applications
71+
- Game engines
72+
- Deterministic execution with concurrency-aware semantics
73+
- ## Misconceptions
74+
- Behavior trees are only for games → **False**. BTs are widely used in robotics, autonomous systems, and modern AI architectures
75+
- BTs are just fancy state machines → **False**. While related, BTs offer hierarchical composition, better readability, and different execution semantics
76+
- BTs are outdated compared to neural networks → **False**. BTs are actively used alongside and in combination with modern AI techniques like RL
77+
- BTs can only express simple behaviors → **False**. Through composition, BTs can express very complex behaviors while remaining maintainable
78+
- BTs are always deterministic → **True, but context matters**. BTs themselves are deterministic, but they can interact with non-deterministic systems (like RL policies)
79+
- BTs replace all other AI techniques → **False**. BTs are often used as high-level controllers that coordinate with other AI systems
80+
- ## Related
81+
- [[AI/Behavior/Tree]] - Quick reference for behavior trees
82+
- [Sollimann/bonsai: Rust implementation of behavior trees for deterministic AI](https://github.com/Sollimann/bonsai)
83+
- [[Person/Kristoffer Rakstad]] - Creator of the Bonsai implementation
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- [Sollimann/bonsai: Rust implementation of behavior trees for deterministic AI](https://github.com/Sollimann/bonsai)

0 commit comments

Comments
 (0)