百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
B

bonsai

> 编程语言
开源

Rust 实现用于确定性 AI 的行为树(现在包含 Python 绑定)

565 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Rust 实现用于确定性 AI 的行为树(现在包含 Python 绑定)

Bonsai 盆栽

Rust implementation of Behavior Trees

Contents

  • Quick intro to Behavior Trees
  • Concepts
  • Examples
  • Development Guide
  • Kanban Board
  • Honorable Mentions

Using Bonsai

Rust

Bonsai is available on crates.io. The recommended way to use it is to add a line into your Cargo.toml such as:

toml
[dependencies]
bonsai-bt = "*"

Python

Bonsai is available on PyPI as bonsai-bt:

bash
pip install bonsai-bt

See bonsai-py/ for examples.

Example of use

See Examples folder.

What is a Behavior Tree?

A Behavior Tree (BT) is a data structure in which we can set the rules of how certain behavior's can occur, and the order in which they would execute. BTs are a very efficient way of creating complex systems that are both modular and reactive. These properties are crucial in many applications, which has led to the spread of BT from computer game programming to many branches of AI and Robotics.

How to use a Behavior tree?

A Behavior Tree forms a tree structure where each node represents a process. When the process terminates, it signals Success or Failure. This can then be used by the parent node to select the next process. A signal Running is used to tell the process is not done yet.

For example, if you have a state A and a state B:

  • Move from state A to state B if A succeeds: Sequence([A, B])
  • Try A first and then try B if A fails: Select([A, B])
  • If condition succeedes do A, else do B : If(condition, A, B)
  • If A succeeds, return failure (and vice-versa): Invert(A)
  • Do A, B repeatedly while LoopCondition runs: While(LoopCondition, [A, B]). Checks condition node between nodes A, B.
  • Do A, B forever: While(WaitForever, [A, B])
  • Do A, B repeatedly while LoopCondition runs: WhileAll(LoopCondition, [A, B]). After All nodes A, B are completed successfully, check the condition node.
  • Run A and B in parallell and wait for both to succeed: WhenAll([A, B])
  • Run A and B in parallell and wait for any to succeed: WhenAny([A, B])
  • Run A and B in parallell and wait for any to complete regardless of success or failure: Race([A, B])
  • Run A and B in parallell, but A has to succeed before B: After([A, B])

See the Behavior enum for more information.

Calling long-running tasks in behavior tree

To make sure that the behavior tree is always responsive, it is important that the actions that are created executes instantly so that they do not block the tree traversal. If you have long-running tasks/functions that can take seconds or minutes to execute - either async or sync - then we can dispatch those jobs into background threads, and get status of the task through a channel.

see async drone example in the /examples folder for more details.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustaiautonomous-robotsbehavior-treebevy

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言