From 218e4e73610b1a7733dfa0bdcd1c1b21ee11b882 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Tue, 31 Oct 2023 14:23:41 +0100 Subject: [PATCH] Add getting-started.md and introduction to BTs --- README.md | 5 ++++- doc/getting-started.md | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 doc/getting-started.md diff --git a/README.md b/README.md index 6a44f1d..bc4dfed 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,9 @@ LimboAI is a C++ module for Godot Engine 4 that provides an implementation of Be >**🛈 License**: Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at https://opensource.org/licenses/MIT. -A Behavior Tree (BT) is a powerful hierarchical structure used to model and control the behavior of agents in a game. It comprises tasks that represent specific actions or decision-making rules. When executed, the Behavior Tree starts from the root task and traverses down to the leaf tasks, which correspond to the actual actions or behaviors that the agent should perform. For detailed information on how various BT tasks function, please refer to the class documentation. The BTTask class serves as a good starting point. +A Behavior Tree (BT) is a powerful hierarchical structure used to model and control the behavior of agents in a game. It comprises tasks that represent specific actions or decision-making rules. When executed, the Behavior Tree starts from the root task and traverses down to the leaf tasks, which correspond to the actual actions or behaviors that the agent should perform. For detailed information on how various BT tasks function, please refer to the class documentation. The BehaviorTree class serves as a good starting point. + +> 🛈 See also: [Introduction to Behavior Trees](./doc/getting-started.md). ![Textured screenshot](doc/images/behavior-tree-editor.png) @@ -52,6 +54,7 @@ A Behavior Tree (BT) is a powerful hierarchical structure used to model and cont - Download the Godot Engine source code and put this module source into the `modules/limboai` directory. - Consult the Godot Engine documentation for instructions on [how to build from source code](https://docs.godotengine.org/en/stable/contributing/development/compiling/index.html). - If you plan to export a game utilizing the LimboAI module, you'll also need to build export templates. +- To execute unit tests, compile the engine with `tests=yes` and run it with `--test --tc="*[LimboAI]*"`. ## Contributing diff --git a/doc/getting-started.md b/doc/getting-started.md new file mode 100644 index 0000000..f0fedc0 --- /dev/null +++ b/doc/getting-started.md @@ -0,0 +1,27 @@ +# Getting Started + +> **🛈 Getting the module:** [README: Getting LimboAI](../README.md#getting-limboai). + + +## TL;DR + +- To create your own actions, extend the `BTAction` class. +- To create your own conditions, extend the `BTCondition` class. +- Use script template (available in "Misc → Create script template") + + +## Introduction to Behavior Trees + +**Behavior Trees (BT)** are hierarchical structures used to model and control the behavior of agents in a game (e.g., characters, enemies, entities). They are designed to make it easier to create complex and highly modular behaviors for your games. + +Behavior Trees are composed of tasks that represent specific actions or decision-making rules. Tasks can be broadly categorized into two main types: control tasks and leaf tasks. Control tasks determine the execution flow within the tree. They include `BTSequence`, `BTSelector`, and `BTInvert`. Leaf tasks represent specific actions to perform, like moving or attacking, or conditions that need to be checked. The `BTTask` class provides the foundation for various building blocks of the Behavior Trees. BT tasks can share data with the help of `Blackboard`. + +> **Note:** To create your own actions, extend the `BTAction` class. + +The BehaviorTree is executed from the root task and follows the rules specified by the control tasks, all the way down to the leaf tasks, which represent the actual actions that the agent should perform or conditions that should be checked. Each task returns a status when it is executed. It can be `SUCCESS`, `RUNNING`, or `FAILURE`. These statuses determine how the tree progresses. They are defined in `BT.Status`. + +Behavior Trees handle conditional logic using condition tasks. These tasks check for specific conditions and return either `SUCCESS` or `FAILURE` based on the state of the agent or its environment (e.g., "IsLowOnHealth", "IsTargetInSight"). Conditions can be used together with `BTSequence` and `BTSelector` to craft your decision-making logic. + +>**Note:** To create your own conditions, extend the `BTCondition` class. + +Check out the `BTTask` class documentation in the editor, which provides the foundation for various building blocks of Behavior Trees.