A behavior tree is a mathematical model that details the plan of execution of a predefined set of tasks. If you have a finite set of tasks, then a behavior tree is where you specify how the program switches from one task to another.

Behavior trees were initially used to develop video games but are now widely used in robotics, computer science, and artificial intelligence (AI). With behavior trees, complex tasks, such as catching Pacman, are made possible through a series of simple tasks. In “Pacman,” these tasks include determining the locations of pills and fruits.

Other interesting terms…

Read More about a “Behavior Tree

A behavior tree looks precisely like a flowchart that we usually see in offices, which explains the flow of a specific process. For instance, in hospitals, you would usually see the triage flowchart, which helps healthcare professionals prioritize patients according to medical need. An example of such a flowchart taken from Research Gate is provided below.

Applications of Behavior Trees

Behavior Trees in Robotics

Behavior trees make robotics applications more efficient and productive. Imagine a robot assigned to pick up cans from the floor to put them on a specific shelf. Without employing a behavior tree, the robot would go on its route, regardless of events. For example, the robot would not stop even when it drops a can or when a person is directly in its path. As a result, it would end up not doing its task efficiently.

When the same robot is created using a behavior tree, it can be programmed to stop when something blocks its path. It can further be taught to go back to its original position or alert a human being when this happens.

Behavior Trees in Computer Games

As previously mentioned, behavior trees were first used in computer games to control the behaviors of nonplayer characters or game characters the player does not control. In essence, behavior trees provide AI to these characters. Some examples of computer games that use behavior trees are:

  • Pacman
  • Halo
  • Spore
  • Bioshock

How Do Behavior Trees Work?

Simply put, the goal of behavior trees is to give nonplayer characters AI so they can execute specific actions. If you notice in this video of a “Pacman” game, the ghosts seem to be drawn to the pills, which is most likely where Pacman would be:

The ghosts were taught through the behavior tree to defeat Pacman by going where the pills are located.

Over the years, behavior trees have evolved to keep up with industry developments. At present, behavior trees are mostly event-driven, which means that nonplayer characters and programs can already be programmed to react to events. A simplified example of an event-driven behavior tree used in “Halo 2” is shown in the video below.

Behavior Tree Limitations

Creating robots, applications, and games using behavior trees makes them a lot better in terms of efficiency and performance. Still, behavior trees have limitations. One of them is the need for tools when navigating through large behavior trees.

The most significant restriction is that it does not teach a program to make better decisions. Since the decision-making process is hard-coded into the tree, it does not teach the characters or robots how the decisions are made.


Behavior trees have greatly improved the way robots, video games, and computer programs are developed. Its evolution toward becoming event-driven also helped improve efficiency and made technology products more intelligent.

But, like any technology, it has challenges and limitations. The demand for more features and functionality could propel the further evolution of behavior trees.