Module behavior

Source
Expand description

Everything related to AI behavior and behavior trees.

Behavior trees are simple but very powerful mechanism to implement artificial intelligence for games. The main concept is in its name. Tree is a set of connected nodes, where each node could have single parent and zero or more children nodes. Execution path of the tree is defined by the actions of the nodes. Behavior tree has a set of hard coded nodes as well as leaf nodes with user-defined logic. Hard coded nodes are: Sequence, Selector, Leaf. Leaf is special - it has custom method tick that can contain any logic you want.

For more info see:

Modules§

composite
Composite node is a container for children nodes. Composite node could be either Sequence or Selector. Sequence node will execute children nodes consecutively until Status::Failure is returned from any descendant node. In other words Sequence implement AND logical function. Selector node will execute children until Status::Success is returned from any descendant node. In other worlds Selector implement OR logical function.
inverter
A node, that inverts its child state (super::Status::Failure becomes super::Status::Success and vice versa, super::Status::Running remains unchanged)
leaf
Leaf is a “final” node of a behavior tree. It contains user-defined action which is able to mutate given context.

Structs§

BehaviorTree
See module docs.
RootNode
Root node of the tree.

Enums§

BehaviorNode
Possible variations of behavior nodes.
Status
Status of execution of behavior tree node.

Traits§

Behavior
A trait for user-defined actions for behavior tree.

Functions§

inverter
Creates a new inverter.
leaf
Creates a new leaf.
selector
Creates a new selector.
sequence
Creates a new sequence.