26 releases (breaking)

0.18.0 Jul 16, 2023
0.17.0 Mar 6, 2023
0.16.0 Jan 30, 2023
0.15.0 Nov 13, 2022
0.1.1 Jul 11, 2020

#68 in Game dev

Download history 108/week @ 2023-08-06 144/week @ 2023-08-13 78/week @ 2023-08-20 128/week @ 2023-08-27 126/week @ 2023-09-03 147/week @ 2023-09-10 118/week @ 2023-09-17 60/week @ 2023-09-24 80/week @ 2023-10-01 92/week @ 2023-10-08 117/week @ 2023-10-15 138/week @ 2023-10-22 162/week @ 2023-10-29 131/week @ 2023-11-05 102/week @ 2023-11-12 127/week @ 2023-11-19

544 downloads per month




crates.io docs.rs Apache 2.0

big-brain is a Utility AI library for games, built for the Bevy Game Engine

It lets you define complex, intricate AI behaviors for your entities based on their perception of the world. Definitions are heavily data-driven, using plain Rust, and you only need to program Scorers (entities that look at your game world and come up with a Score), and Actions (entities that perform actual behaviors upon the world). No other code is needed for actual AI behavior.

See the documentation for more details.


  • Highly concurrent/parallelizable evaluation.
  • Integrates smoothly with Bevy.
  • Proven game AI model.
  • Highly composable and reusable.
  • State machine-style continuous actions/behaviors.
  • Action cancellation.


As a developer, you write application-dependent code to define Scorers and Actions, and then put it all together like building blocks, using Thinkers that will define the actual behavior.


Scorers are entities that look at the world and evaluate into Score values. You can think of them as the "eyes" of the AI system. They're a highly-parallel way of being able to look at the World and use it to make some decisions later.

use bevy::prelude::*;
use big_brain::prelude::*;

#[derive(Debug, Clone, Component, ScorerBuilder)]
pub struct Thirsty;

pub fn thirsty_scorer_system(
    thirsts: Query<&Thirst>,
    mut query: Query<(&Actor, &mut Score), With<Thirsty>>,
) {
    for (Actor(actor), mut score) in query.iter_mut() {
        if let Ok(thirst) = thirsts.get(*actor) {

Actions are the actual things your entities will do. They are connected to ActionStates that represent the current execution state of the state machine.

use bevy::prelude::*;
use big_brain::prelude::*;

#[derive(Debug, Clone, Component, ActionBuilder)]
pub struct Drink;

fn drink_action_system(
    mut thirsts: Query<&mut Thirst>,
    mut query: Query<(&Actor, &mut ActionState), With<Drink>>,
) {
    for (Actor(actor), mut state) in query.iter_mut() {
        if let Ok(mut thirst) = thirsts.get_mut(*actor) {
            match *state {
                ActionState::Requested => {
                    thirst.thirst = 10.0;
                    *state = ActionState::Success;
                ActionState::Cancelled => {
                    *state = ActionState::Failure;
                _ => {}

Finally, you can use it when define the Thinker, which you can attach as a regular Component:

fn spawn_entity(cmd: &mut Commands) {
        Thirst(70.0, 2.0),
            .picker(FirstToScore { threshold: 0.8 })
            .when(Thirsty, Drink),

Once all that's done, we just add our systems and off we go!

fn main() {
        .add_systems(Startup, init_entities)
        .add_systems(Update, thirst_system)
        .add_systems(PreUpdate, (

bevy version

The current version of big-brain is compatible with bevy 0.11.0.


  1. Install the latest Rust toolchain (stable supported).
  2. cargo run --example thirst
  3. Happy hacking!


This project is licensed under the Apache-2.0 License.


~384K SLoC