SAE-Institute-Geneva / GPR5204_919

MIT License
0 stars 6 forks source link

Behavior Tree - Vincent & Lorna #4

Open eleonoradps opened 3 years ago

eleonoradps commented 3 years ago

Behavior Tree

Introduction

The task given to us is to implement a behavior tree in two weeks for the GPR5204 module at SAE Institute Geneva. Here is how we’re planning to do it with the help of a documentation from the BTSK git repository : https://github.com/aigamedev/btsk

Behavior Tree classes and hierarchy

image

Overview

We have an enum called Status that represents the different statuses of the actions (Success, Running, Failure).

We have a base class called Behavior with three virtual functions that inheriting classes will implement :

OnInitialize() : Initializes status of action. Update() : Updates status of action. OnTerminate() : Is called when previous update is no longer running.

There is also a function to check the Status of the Behavior and react accordingly.

Then we have classes that inherit from the Behavior class :

Composite : class for nodes with multiple Behaviors to manage. Decorator : class for nodes with only one Behavior.

Finally, we have two classes that inherit from the Composite class :

Selector : This class has conditional nodes, they’re only executed based on certain conditions/events. Sequence : This class executes behaviors in order from left to right.

Variables

The Behavior class only has a Status as its main variable. The Composite class has a vector of Behavior as variable. The Decorator class has a Behavior as variable. The Selector and Sequence classes both inherit the vector from the Composite class and have an iterator for said vector.

EliasFarhan commented 3 years ago

Thanks for the enhaucement proposal.

I have some remarks:

We will discuss optimizations and implementation scenario next week.