Development, Labs

Experimenting with Behavior Trees


Welcome to the first lab post!

These past few weeks I spent time working out a new AI system, as part of our next step in the development for The Very Organized Thief.

The new system is using Behavior Trees, allowing us to create more reactive AI in our games.

Part of this is to solve some limitations we’ve been having with our State Machine. It has been great for simple AI, but it becomes a mess the more detail we add to them.

The State Machine soup that is the Owner AI for The Very Organized Thief

So like with all new things, I started an experimental project in Unity. Bashing out code that allowed me to create Behavior Trees by hand.

I’d add a behavior, run the scene, observe, and then improve it based on issues or oddities that I saw. Then repeat this process until I felt like I had a good understanding of how it all worked together.

This let me quickly explore how it worked, and see any limitations there might have been when creating complex behavior trees.

What I ended up working on turned out to be a lot of fun.

It’s not easy to tell what’s going on, so here’s a breakdown.

  • The blue cylinder is a lazy human guard.
  • The green cylinder is a human gardener.
  • The purple cylinder is a hungry human.
  • The red cylinder is a monster.
  • The monster will roam around scaring humans, growing when he does.
  • When the humans are scared, they’ll shrink.
  • The guard will scare the monster away only while on patrol.
  • The hungry human will eat the plants.
  • The gardener will water the plants to help them grow once they’ve been eaten.
  • The plants need to ripen before they can be eaten by the hungry human again.
  • They all have a home to return to, to recover and rest.

I also gave myself the extra challenge to make it run forever which led to adding more complexity to make it possible.

With that, the experiment was a success.

I’m currently taking everything I’ve learned, and extending our AI system with new features and tools around creating Behavior Trees.

I’ll be posting more about that in a follow-up post.


Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Ko-fi Coffee

One Response


Comments for this post are closed.