Sollimann/bonsai
关于
使用 Rust 实现的确定性 AI 行为树(现已提供 Python 绑定)
游戏与模拟器实测星标增长
- 24小时
- +2
- 7天
- +5
- 15天
- +3
- 1个月
- +15
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Bonsai 盆栽
Rust implementation of Behavior Trees
Contents
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:
[dependencies]
bonsai-bt = "*"
Python
Bonsai is available on PyPI as bonsai-bt:
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
Ato stateBifAsucceeds:Sequence([A, B]) - Try
Afirst and then tryBifAfails:Select([A, B]) - If
conditionsucceedes doA, else doB:If(condition, A, B) - If
Asucceeds, return failure (and vice-versa):Invert(A) - Force a child to succeed regardless of its result:
AlwaysSucceed(A) - Run a child, but fail it if it stays
Runninglonger than a limit:Timeout(seconds, A) - Do
A,Brepeatedly whileLoopConditionruns:While(LoopCondition, [A, B]). Checks condition node between nodesA,B. - Do
A,Bforever:While(WaitForever, [A, B]) - Do
A,Brepeatedly whileLoopConditionruns:WhileAll(LoopCondition, [A, B]). After All nodesA,Bare completed successfully, check the condition node. - Run
AandBin parallell and wait for both to succeed:WhenAll([A, B]) - Run
AandBin parallell and wait for any to succeed:WhenAny([A, B]) - Run
AandBin parallell and wait for any to complete regardless of success or failure:Race([A, B]) - Run
AandBin parallell, butAhas to succeed beforeB: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.
探索相关项目
加载中…