# Chapter 15: The AI System

The AI system is implemented using a behavior tree. A behavior tree is a model of the decision process of an agent in a game. It represents a set of decisions, which take the form of nodes in a tree structure. These nodes are of two types: leaf nodes (`Action`) and internal nodes (`Selector` and `Sequence`).

Leaf nodes represent actions, the basic building blocks of behavior. Each action returns a `BehaviourTreeResult`, which can be either `Success`, `Failure`, or `Running`.

Internal nodes, `Selector` and `Sequence`, each contain a vector of other nodes. They decide which of their child nodes will be processed and in what order. A `Selector` node will return immediately with a `Success` result as soon as one of its child nodes returns `Success`. On the other hand, a `Sequence` node will stop processing and return `Failure` as soon as one of its child nodes fails.

The `tick` method is called to process the behavior tree. It executes the action, selector, or sequence based on the node type, thus driving the AI's decision-making process.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lados-organization.gitbook.io/goku/chapter-15-the-ai-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
