Skip to main content

Module ai

Module ai 

Source
Expand description

Entity AI — Finite State Machine, Behavior Tree, and Utility AI.

Three complementary AI models:

  • StateMachine<S>: enum-driven FSM with transition guards
  • BehaviorTree: composable node tree (Sequence, Selector, Decorator)
  • UtilityAI: scores candidate actions and picks the highest

Modules§

keys
Standard blackboard keys used by built-in behaviors.

Structs§

AlwaysFailure
Always-failure leaf.
AlwaysSuccess
Always-success leaf.
BehaviorTree
A complete behavior tree with its own blackboard.
Blackboard
Shared working memory for AI nodes.
CheckFlag
Condition: reads a bool from the blackboard.
CheckFloat
Condition: checks if a float exceeds a threshold.
Consideration
Consideration: maps a blackboard value through a curve to a partial score.
Cooldown
Cooldown: child can only run once every cooldown seconds.
Inverter
Inverter: flips Success/Failure.
Parallel
Parallel: runs all children every tick. Succeeds when n succeed.
RandomSelector
RandomSelector: like Selector but shuffles children on each activation.
Repeater
Repeater: runs child n times (0 = infinite).
Selector
Selector: runs children left-to-right; succeeds on first child success.
Sequence
Sequence: runs children left-to-right; fails on first child failure.
SetFlag
Action: set a blackboard flag.
StateMachine
A generic Finite State Machine.
Succeeder
Succeeder: always returns Success.
UtilityAI
Selects the highest-scoring available action and runs it.
UtilityActionDef
An action defined by its considerations and execution function.
Wait
Action: wait for duration seconds.

Enums§

BtStatus
Status returned by a BT node each tick.
ConsiderationCombine
StateResult
Outcome of a state’s update tick.
UtilityCurve
Scoring curve applied to a raw utility value.

Traits§

BtNode
A node in a behavior tree.
FsmState
A single FSM state.
UtilityAction
An action that utility AI can evaluate and execute.