• News
  • Account
    • Subscriptions
    • Orders
    • Account Details
  • Shop
    • gw2cc Licence
    • Plugins
    • Bots
  • Support

Login

User Guide

  • Installing gw2cc
  • Update Channels
  • Using the Attach Mode
  • Activating & Deactivating Plugins
  • Plugins
    • Teleporter

Developer Guide

  • Architecture
  • Getting Started
  • Creating Plugins
  • Making your Mod able to walk
  • Distributing Plugins and Bots
  • Helpfull Topics
    • Starting with Godot
    • Coordinate System
    • Behavior Trees
View Categories
  • Home
  • Docs
  • Developer Guide
  • Helpfull Topics
  • Behavior Trees

Behavior Trees

3 min read

Behavior Trees are a popular tool used in game development and artificial intelligence for controlling the behavior of game characters or agents. A Behavior Tree is a hierarchical structure that organizes the decision-making process of an agent into a tree-like structure. At each node of the tree, an action is performed that either leads to another node in the tree or returns a result.

This figure shows a Behavior Tree for a robotic arm, with green boxes indicating actions and yellow circles indicating conditions. The Sequence node (represented by “->”) combines actions and conditions into a sequence of behaviors, while the Selector node (represented by “?”) selects one behavior from several options. By Aliekor at English Wikipedia, CC BY-SA 3.0, link.

An action is the basic building block of a Behavior Tree, representing a simple task or behavior that an agent can perform. For example, an action could be to move the character to a specific location, to fire a weapon, or to wait for a certain amount of time. An action can either return a success, failure, or running status, indicating whether the action was successful, failed, or is still in progress.

Sequences and Selectors are two types of composite nodes used to create more complex behavior in a Behavior Tree. A Sequence node performs a series of actions in a specific order, where each action is only executed if the previous action was successful. This can be used to implement preconditions for a certain behavior. For example, a sequence could be used to create a behavior for an agent to attack an enemy, where the preconditions might include the agent being close enough to the enemy and having enough ammunition.

A Selector node performs a set of actions until one of them succeeds. This can be used to implement interrupts or events that change an agent’s behavior in response to the environment. For example, a selector could be used to create a behavior for an agent to flee from danger if it detects an enemy nearby, or to search for a new objective if its current objective is no longer available.

The Behavior Tree is rerun in every frame of the game from top to bottom. This means that the behavior of the agent is constantly evaluated and updated based on the current state of the game. By using Behavior Trees, developers can create complex behaviors for game characters that are responsive to changes in the game environment.

This is in contrast to Finite State Machines (FSMs), where the agent’s behavior is determined by its current state and transitions between states are triggered by specific conditions or events. FSMs are better suited for modeling relatively simple behaviors with well-defined state transitions, while Behavior Trees are better suited for more complex, dynamic behaviors that require more flexible decision-making and are continuously evaluated and updated based on the current state of the game environment.

Behavior Trees in gw2cc #

The gw2cc framework already includes a complete and basic implementation of a Behavior Tree, which can be located in the gdbt/ folder. To construct a tree structure, the system already in place in Godot is used, specifically the node and scene tree systems. Actions, conditions, and composite nodes are all simple Godot nodes that can be easily arranged in the editor to form a Behavior Tree. The root of the tree must be a gdbt/BehaviorTree.gd node. By using packed scenes, more complex behaviors can be abstracted and made reusable, which enables a highly modular top-down approach to bot AI.

Updated on February 19, 2023
Coordinate System
Table of Contents
  • Behavior Trees in gw2cc
  • Impressum
  • Terms and Conditions
  • Privacy Policy
  • Refund and Returns Policy
  • Backlinks
The GW2 Custom Client