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

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

example/behavior_tree_example.dart

import 'package:behavior_tree/behavior_tree.dart';

bool isHungry = true;

void main() {
  // Create a sequence of tasks
  final treeRoot = Sequence(
    children: [
      Condition(() => isHungry),
      Task(goToShop),
      Task(buyFood),
      Task(goToHome),
      Task(eatFood),
    ],
  );

  // Tick the tree
  treeRoot.tick();
}

NodeStatus goToShop() {
  // Go to the shop
  return NodeStatus.success;
}

NodeStatus buyFood() {
  // Buy food
  return NodeStatus.success;
}

NodeStatus goToHome() {
  // Go home
  return NodeStatus.success;
}

NodeStatus eatFood() {
  // Eat food
  return NodeStatus.success;
}
2
likes
0
pub points
71%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

opencollective.com
github.com
patreon.com

License

unknown (license)

Dependencies

meta

More

Packages that depend on behavior_tree