The Blackboard acts as shared memory between the State Machine and Behavior Tree. Transitions and BT conditions read from the blackboard; actions write back to it. This decoupled architecture lets you mix high-level state control with detailed behavior logic.
The core library is engine-agnostic, MIT-licensed, and depends only on serde and nalgebra. Use it in any Rust project.
Define states with named transitions. Each transition evaluates conditions against the blackboard to decide when to switch. Supports guard conditions and fallback states.
Sequence, Selector, Parallel, Inverter, Repeater, Succeeder, Failer, Delay, and Action. Compose complex decision-making from simple building blocks.
Shared key-value store with Bool, Int, Float, String, and Vec3. Both state machines and behavior trees read and write the same blackboard instance.
Composable And, Or, and Not operators for transition guards and BT conditions. Build arbitrarily complex conditions from simple comparisons.
Every type implements Serialize and Deserialize. Save AI configurations to JSON, RON, or any serde-compatible format. Hot-reload friendly.
No Fyrox dependency in the core crate. Only serde + nalgebra. Use with Fyrox, Bevy, macroquad, or pure Rust servers and simulations.
Visual editor integration for FyroxEd. Design AI visually, inspect at runtime, debug with full history.
3-panel layout: blackboard panel on the left, graph canvas in the center for drag-and-drop state and transition design, state details on the right for configuring conditions.
Live panel showing all blackboard keys, types, and current values. Edit values at runtime for rapid testing and debugging of AI behavior.
Logs every state transition with timestamps. Review transition history to understand why AI made specific decisions. Filter by entity or state name.
Extended state machine where states have priority levels. Higher-priority states can interrupt lower-priority ones, ideal for alert/combat AI patterns.
All editor operations go through the Fyrox command system. Every graph edit, connection change, and property modification can be undone and redone.
Runs natively inside FyroxEd as a plugin. No external tools needed. AI graphs are saved as part of your Fyrox project and version-controlled normally.
A basic state machine with Idle, Patrol, and Chase states. The blackboard drives transitions.
use fyrox_ai::{StateMachine, State, Transition, Blackboard, Condition}; use fyrox_ai::BlackboardValue::{Bool, Float}; // Create a shared blackboard let mut bb = Blackboard::new(); bb.set("player_visible", Bool(false)); bb.set("patrol_timer", Float(0.0)); // Define states let idle = State::new("Idle"); let patrol = State::new("Patrol"); let chase = State::new("Chase"); // Build the state machine let mut sm = StateMachine::builder() .state(idle) .state(patrol) .state(chase) .transition( Transition::new("Idle", "Patrol") .condition(Condition::gte("patrol_timer", Float(3.0))) ) .transition( Transition::new("Patrol", "Chase") .condition(Condition::eq("player_visible", Bool(true))) ) .transition( Transition::new("Chase", "Idle") .condition(Condition::eq("player_visible", Bool(false))) ) .initial("Idle") .build(); // Tick each frame sm.update(&bb); println!("Current state: {}", sm.current().name());
The free core covers everything you need at runtime. Pro adds visual tooling and advanced features.
| Feature | Free (MIT) | Pro |
|---|---|---|
| State Machine with transitions | ✓ | ✓ |
| Behavior Tree (9 node types) | ✓ | ✓ |
| Blackboard (5 value types) | ✓ | ✓ |
| Condition logic (And/Or/Not) | ✓ | ✓ |
| Full serde serialization | ✓ | ✓ |
| Engine-agnostic (serde + nalgebra only) | ✓ | ✓ |
| Visual State Graph Editor | — | ✓ |
| 3-Panel Layout (blackboard, canvas, details) | — | ✓ |
| Blackboard Inspector Panel | — | ✓ |
| AiDebugLogger (transition history) | — | ✓ |
| PriorityStateMachine | — | ✓ |
| Full undo/redo in editor | — | ✓ |
Fyrox AI is a Rust library for building game AI using state machines and behavior trees. It provides a composable state machine with transitions, 9 behavior tree node types (Sequence, Selector, Parallel, Inverter, Repeater, Succeeder, Failer, Delay, Action), a shared blackboard with 5 value types (Bool, Int, Float, String, Vec3), and composable condition logic (And/Or/Not). The free version is MIT-licensed and engine-agnostic.
No. The free core library depends only on serde and nalgebra, so you can use it in any Rust project — with Fyrox, Bevy, macroquad, or even a headless server. The Pro visual editor requires FyroxEd, but the core AI logic works anywhere.
Fyrox AI Pro adds a 3-panel visual editor inside FyroxEd: a blackboard panel on the left for inspecting variables, a graph canvas in the center for designing state machines with drag-and-drop, and a state details panel on the right for configuring transitions and conditions. All changes support full undo/redo.
Yes. Both systems use a blackboard for condition evaluation, so they can share game state. An NPC's AI state machine can check dialog flags, and dialog condition nodes can read AI state variables. This lets you build NPCs that change behavior based on conversation outcomes.
A state machine defines distinct states (Idle, Patrol, Chase) with explicit transitions based on conditions. A behavior tree organizes behaviors as a tree evaluated top-down, with nodes like Sequence, Selector, and Parallel for complex decision-making. Fyrox AI provides both — use a state machine for high-level modes and behavior trees within each state for detailed logic.
Start free with the MIT-licensed core. Add the Pro visual editor when you need it.