> For the complete documentation index, see [llms.txt](https://sniveler-code.gitbook.io/dots/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sniveler-code.gitbook.io/dots/project-ai-behavior-architect/section-1/core-concepts-and-architecture.md).

# 🧠 Core Concepts & Architecture

To get the most out of **AI Behavior Architect**, it is helpful to understand how it operates under the hood. The framework relies on three core DOTS pillars to achieve maximum performance:

#### ⚙️ 1. Automated Code Generation

Behavior Trees are inherently polymorphic (e.g., a generic "Node" can be an Action, a Sequence, or a Condition). Standard ECS does not support polymorphism well, as everything must be strictly typed data.

To bypass this, **AI Behavior Architect** uses a **Code Generator**. When you save your graph, the tool reads your nodes and automatically generates partial struct systems that process your specific logic. You never have to manually register nodes into systems; the architect wires it all up for you.

#### 📦 2. Blob Assets (BlobAssetReference)

When you bake your sub-scene, the framework reads your visual `Graph Asset` and converts the tree's layout into a `BtBlob` (a Blob Asset).

> 🚀 **Why Blob Assets?**\
> Blob Assets guarantee that the entire structure of your behavior tree is stored in a single, contiguous block of unmanaged memory. This makes navigating the tree incredibly cache-friendly and allows it to be safely read inside Burst-compiled multithreaded jobs.

#### 💾 3. Unmanaged State Buffers

Because a Behavior Tree needs to remember what it was doing last frame (e.g., waiting for a timer, or running a custom action), it requires memory. **AI Behavior Architect** allocates unmanaged `DynamicBuffer<T>` components directly onto your Agent Entity during the baking process:

* `BtNodeState`: Stores internal timers and loop counters (e.g., for Wait or Repeater nodes).
* `BtActionState`: Tracks which custom actions are currently running and their results.
* `BtBlackboardEntry`: A 16-byte unmanaged wrapper that stores your Blackboard variables (`floats`, `ints`, `bools`, and `Entity` references) directly on the memory chunk.

Because all state data is strictly unmanaged and tightly packed on the Entity, the runtime evaluator **never triggers the Garbage Collector**.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://sniveler-code.gitbook.io/dots/project-ai-behavior-architect/section-1/core-concepts-and-architecture.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
