behavior_tree 0.1.3 copy "behavior_tree: ^0.1.3" to clipboard
behavior_tree: ^0.1.3 copied to clipboard

A behavior tree implementation written in Dart. This package is designed to be used for implementing AI in games.

flame

This package provides a simple and easy to use behavior tree API in pure dart.


Behavior tree is a very common way of implementing AI behavior in game and robotics. Using this, you can break-down a complex behavior of an in game AI, into multiple smaller nodes.

Features #

  • Nodes
    • Composite
      • Sequence: Continues execution until one of the children fails.
      • Selector: Continues execution until one of the children succeeds.
    • Decorator
      • Inverter: Flips the status of the child node.
      • Limiter: Limits the number of ticks for child node.
    • Task
      • Task: Executes a given callback when ticked.
      • AsyncTask: Executes an async callback when ticked.
      • Condition: Checks a condition when ticked.

Getting started #

Add this package to your dart project using,

dart pub add behavior_tree

Usage #

  • Create a behavior tree.
final treeRoot = Sequence(
  children: [
    Condition(() => isHungry),
    Task(() => goToShop()),
    Task(() => buyFood()),
    Task(() => goToHome()),
    Task(() => eatFood()),
  ]
);
  • Tick the root node to update the tree.
final treeRoot = ...;
treeRoot.tick();
3
likes
160
points
87
downloads

Publisher

unverified uploader

Weekly Downloads

A behavior tree implementation written in Dart. This package is designed to be used for implementing AI in games.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

Funding

Consider supporting this project:

opencollective.com
github.com
patreon.com

License

MIT (license)

Dependencies

meta

More

Packages that depend on behavior_tree