Behavior trees in Python, powered by the bonsai-bt Rust crate.
Project description
bonsai-bt - Python bindings
Python bindings for the bonsai-bt behavior-tree library.
Installation (dev)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\Activate.ps1
pip install maturin
cd bonsai-py
maturin develop
python -c "import bonsai_bt; print(bonsai_bt.__version__)"
Same BT in Rust and Python
A minimal three-node tree (Hello → Wait(1.0) → Goodbye) implemented in both languages. Semantics are identical because the Python package is a thin wrapper around the Rust crate; only the API surface differs (Rust requires an enum + explicit types; Python uses any hashable object as the action payload).
Rust
use bonsai_bt::{Behavior, Event, Status, UpdateArgs, BT};
#[derive(Clone, Debug)]
enum Greet { Hello, Goodbye }
fn main() {
let tree = Behavior::Sequence(vec![
Behavior::Action(Greet::Hello),
Behavior::Wait(1.0),
Behavior::Action(Greet::Goodbye),
]);
let mut bt: BT<Greet, ()> = BT::new(tree, ());
for _ in 0..5 {
let e: Event = UpdateArgs { dt: 0.5 }.into();
bt.tick(&e, &mut |args, _bb| {
match *args.action {
Greet::Hello => println!("hello"),
Greet::Goodbye => println!("goodbye"),
}
(Status::Success, args.dt)
});
}
}
Python
import bonsai_bt as bt
tree = bt.Sequence([
bt.Action("hello"),
bt.Wait(1.0),
bt.Action("goodbye"),
])
tree_bt = bt.BT(tree, None)
def cb(args, _bb):
print(args.action)
return (bt.Status.Success, args.dt)
for _ in range(5):
tree_bt.tick(0.5, cb)
Output (both):
hello
goodbye
For richer examples — multi-job orchestration, visualizer integration, parallel agents — see examples/.
License
MIT - see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bonsai_bt-0.12.0.tar.gz.
File metadata
- Download URL: bonsai_bt-0.12.0.tar.gz
- Upload date:
- Size: 106.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac6f8e2a686f68594e8b8e5b599b4eb32bbb12aa135cc6f494b2789ff5aaec6f
|
|
| MD5 |
20b737c50e4e2aa283d5b4fe2b19370e
|
|
| BLAKE2b-256 |
c95fd54aaf40747a6af158355f7584972770a73d39c456db3746d13b653b29ef
|
Provenance
The following attestation bundles were made for bonsai_bt-0.12.0.tar.gz:
Publisher:
python-wheels.yml on Sollimann/bonsai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bonsai_bt-0.12.0.tar.gz -
Subject digest:
ac6f8e2a686f68594e8b8e5b599b4eb32bbb12aa135cc6f494b2789ff5aaec6f - Sigstore transparency entry: 1724608232
- Sigstore integration time:
-
Permalink:
Sollimann/bonsai@73eb99518da7d6086a60a8bb49fd3e610c396dfb -
Branch / Tag:
refs/tags/py-v0.12.0 - Owner: https://github.com/Sollimann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@73eb99518da7d6086a60a8bb49fd3e610c396dfb -
Trigger Event:
push
-
Statement type:
File details
Details for the file bonsai_bt-0.12.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: bonsai_bt-0.12.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 377.8 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a064586a936240f36a4ff4f08ad5e24842ca97c968ee3f5bf17cd3fcb033d4b9
|
|
| MD5 |
e9f993e73e1e5d30f6af3f5cb96fe025
|
|
| BLAKE2b-256 |
675f32d0f6d5be1efe5cb0ead8bdd87a0875146aad548bdef9326ad8264489b6
|
Provenance
The following attestation bundles were made for bonsai_bt-0.12.0-cp310-abi3-win_amd64.whl:
Publisher:
python-wheels.yml on Sollimann/bonsai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bonsai_bt-0.12.0-cp310-abi3-win_amd64.whl -
Subject digest:
a064586a936240f36a4ff4f08ad5e24842ca97c968ee3f5bf17cd3fcb033d4b9 - Sigstore transparency entry: 1724608512
- Sigstore integration time:
-
Permalink:
Sollimann/bonsai@73eb99518da7d6086a60a8bb49fd3e610c396dfb -
Branch / Tag:
refs/tags/py-v0.12.0 - Owner: https://github.com/Sollimann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@73eb99518da7d6086a60a8bb49fd3e610c396dfb -
Trigger Event:
push
-
Statement type:
File details
Details for the file bonsai_bt-0.12.0-cp310-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: bonsai_bt-0.12.0-cp310-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 493.7 kB
- Tags: CPython 3.10+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ebe80453075355fb7979bc2990d3ed2343654d1141714aa31783b3a12398b1c
|
|
| MD5 |
90cf9a2d03b4f06b8e804b7d7712cc50
|
|
| BLAKE2b-256 |
cd67f0b2a8e5565aff45f35b74f93f587ceea15f227065c9e6165c2f0433567a
|
Provenance
The following attestation bundles were made for bonsai_bt-0.12.0-cp310-abi3-manylinux_2_28_x86_64.whl:
Publisher:
python-wheels.yml on Sollimann/bonsai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bonsai_bt-0.12.0-cp310-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
8ebe80453075355fb7979bc2990d3ed2343654d1141714aa31783b3a12398b1c - Sigstore transparency entry: 1724608607
- Sigstore integration time:
-
Permalink:
Sollimann/bonsai@73eb99518da7d6086a60a8bb49fd3e610c396dfb -
Branch / Tag:
refs/tags/py-v0.12.0 - Owner: https://github.com/Sollimann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@73eb99518da7d6086a60a8bb49fd3e610c396dfb -
Trigger Event:
push
-
Statement type:
File details
Details for the file bonsai_bt-0.12.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: bonsai_bt-0.12.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 856.3 kB
- Tags: CPython 3.10+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b40d1d6f8bbf1007e76cc81cf8817cdd122932707c3171e37fc2ae88bfc28490
|
|
| MD5 |
9f4eacf4d5cd92e4f885479797396876
|
|
| BLAKE2b-256 |
0a3ec4b4afb97e04cd85ab6d5a11dc6f1c531f1556f7589c65dd1fc38ceb626e
|
Provenance
The following attestation bundles were made for bonsai_bt-0.12.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:
Publisher:
python-wheels.yml on Sollimann/bonsai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bonsai_bt-0.12.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
b40d1d6f8bbf1007e76cc81cf8817cdd122932707c3171e37fc2ae88bfc28490 - Sigstore transparency entry: 1724608733
- Sigstore integration time:
-
Permalink:
Sollimann/bonsai@73eb99518da7d6086a60a8bb49fd3e610c396dfb -
Branch / Tag:
refs/tags/py-v0.12.0 - Owner: https://github.com/Sollimann
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-wheels.yml@73eb99518da7d6086a60a8bb49fd3e610c396dfb -
Trigger Event:
push
-
Statement type: