# Examples The examples below are minimal, made-up scenarios to help you get going. For real-world usage of `bonsai-bt` in the wild, see: * [utahrobotics/utah-lunabotics-2026](https://github.com/utahrobotics/utah-lunabotics-2026) — orchestrates core autonomy on a lunar rover. The team placed 3rd out of 50 in the autonomy challenge at [NASA Lunabotics 2026](https://www.nasa.gov/learning-resources/lunabotics-challenge/). * [catornot/bp-ort](https://github.com/catornot/bp-ort) — NPC plugins for Titanfall 2 mod servers (Northstar). [Live demo](https://www.youtube.com/watch?v=uT3aAuB4ej4&t=60s). * [AnotherlandServer/anotherland](https://github.com/AnotherlandServer/anotherland) — NPC behaviors for the Anotherland MMORPG. `cargo build --package examples` ## Game NPC AI console application Demonstrates use of a behavior tree in minimal and easy to follow console application setting where a fictional non-playing game character updates its AI state. Run and inspect this example if you want to get a quick introduction on how behavior tree can be used in an application. `cargo run --bin simple_npc_ai` ## Memoryless composites (`Sequence`/`Select` with `memory = false`) Two short console demos in one binary, showing the difference between memoryless composites and their stateful (memory) siblings: - **memoryless `Sequence`** (`Sequence(...).memory(false)`) — chase while visible. When visibility flips off mid-chase, the running `Chase` aborts on the next tick because the leading `EnemyVisible` check is re-run from scratch. A regular `Sequence` would resume the running child and keep chasing. - **memoryless `Select`** (`Select(...).memory(false)`) — priority preemption. `Attack` is preferred over `Chase`. While the enemy is out of range, attack fails and chase runs. Once the enemy enters range, the next tick preempts the chase and runs attack. `cargo run --bin memoryless_chase` ## Boids flocking Constructing boids flocking behavior by copying the same behavior tree across many agents. Each agent follows the following rules: 1. Fly towards the center of the swarm 2. Avoid other agents and predators (predator being the mouse cursor) 3. Match the velocity of other agents `cargo run --bin boids` *PS!* if for some how you're unable to build and run the example, it is most likely because you're lacking some dependencies. Try installing the following dependencies: `sudo apt-get update && sudo apt-get install libudev-dev pkg-config librust-alsa-sys-dev`