simple_bt 1.0.0

minimal(-ish) behavior tree implementation
Documentation
  • Coverage
  • 44%
    11 out of 25 items documented0 out of 10 items with examples
  • Size
  • Source code size: 57.48 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.53 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Jengamon

Simple BT

A verrrry simple behavior tree implementation.

Included are implementations of the composite nodes in this style:

  • Succeeder: a node that always succeeds (or makes their child always succeed)
  • Inverter: inverts the success or failure of their child
  • Sequence: tick each child in order, fail if any child fails, succeed once finished
  • ParallelSequence: tick every child each tick, fail if any child fails, succeed once finished
  • Selector: tick each child in order, succeed if any child succeeds, fail once finished
  • ParallelSelector: tick every child each tick, suceed if any child succeeds, fail once finished
  • Repeated: repeat child forever
  • LimitedRepeated: repeat child a number of times
  • RepeatedUntilFailure: repeat until child fails (result is success)

Central types are BehaviorNode and NodeResult.

BehaviorNode required Debug, Send and Sync, and is only expected to implement 1 function: tick, which takes the Arc the node is stored in, and a unique borrow of the blackboard type, and must return a NodeResult.

NodeResult has 3 variants: the control-flow Success and Failure, and Running, which is required to contain the node that should be run on the next tick.

For leaf nodes, this design should be relatively transparent, but for composite nodes, this requires a little more effort to maintain the tree structure on the next tick. In general, users of this library would only be writing leaf nodes (actions and conditions).

To use this library, you must create some blackboard type which doubles as a context type that controls how any leaf node interacts with its environment. See examples/beehave_example.rs for a worked example.