Behavior Trees in Robotics and AI

Welcome to the webpage of the book Behavior Trees in Robotics and AI

Home

Tutorials

  Pac-Man Example

  Youbot Example

About the Authors

Tutorial for Pac-Man Example

Here you will find the instructions to run the Pac-Man example of Chapter 2. You will be able to design the AI of the Pac-Man game designing your own Behavior Tree (BT) via a Graphical User Interface (GUI).

scenario_pacman

Below you can find the instructions according to your operating system.

Installation in Windows


1) Install Dependencies:

git clone https://github.com/btirai/pacman.git

3) Build the Software:

Run Cmake, set the project (pacman) root folder and the desired build folder (your choice). Configure and generate project solution for your favorite IDE (e.g. Visual Studio 13). Then open the solution from your IDE and build the project.

Run in Windows


In a terminal, go to the build directory of the project and then run the following commands:

./behavior_tree_editor.exe

Alternatively, run the executable pacman_behavior_tree_editor.exe from File Explorer

Installation in Unix


1) Install Dependencies:

sudo apt-get install build-essential libgl1-mesa-dev python3-tk qtdeclarative5-dev

2) Download the repository:

git clone https://github.com/btirai/pacman.git

3) Build the Software:

Run in a terminal the following commands:

cd pacman
mkdir build
cd build
cmake ..
make

Run in Unix


Run in a terminal the following commands:

cd bt_editor

./behavior_tree_editor

Verify your installation


screenwindows

Create your own Behavior Tree


Right Click in the editor to add a node. The nodes have the following meanings:

Name Type Description
IsGhostClose Condition Returns Success if the a ghost is close. Failure otherwise.
IsClosestGhostScared Condition Returns Success if the the closes ghost is scared. Failure otherwise.
Greedy Action Moves to the next position that has a pill.
ClosestDotSearch Action Moves in the direction of the closest pill.
Chase Action Moves in the direction of the closest ghost.
KeepDistance Action Moves to a position that maximize the distance with the ghosts.
Escape Action Moves to a position that maximize the distance with the closest ghost.

NOTE: A BT must have the root node. It cannot have loose nodes (non-connected nodes).