# NPC Engine

## **Overview**

\
The NPC Engine employs advanced large language models (LLMs) combined with fine-tuned reinforcement learning agents to create adaptive, context-aware non-playable characters. These NPCs interact naturally with players, dynamically update their behaviors, and evolve their decision-making strategies based on player input and environmental stimuli.

## Model Type & Architecture

* Core LLM: At the heart is a state-of-the-art LLM, such as a transformer-based model, pre-trained on a diverse dataset of dialogues, game narratives, character interactions, and behavior scripts.
* Reinforcement Learning (RL) Layer: NPC behaviors are refined through RL by simulating in-game scenarios. Rewards are defined by metrics like player engagement, quest completion rates, and narrative satisfaction. The RL layer helps NPCs adapt to new conditions and improve over time.
* Memory Storage (Vector Databases): The NPC Engine uses vector databases to store NPC “memories” — embeddings of previous conversations, decisions, and player interactions. This enables long-term recall and context continuity. The engine retrieves these memories as needed, maintaining coherent character arcs.
* Retrieval-Augmented Generation: When generating dialogues or actions, the engine looks up relevant context from the vector database. It then fuses the retrieved context with the core LLM’s output, ensuring each NPC’s behavior and personality feel consistent over time.

## Underlying Tech

* Language Modeling: Transformer-based LLMs (GPT-like architecture), trained on diverse in-game dialogues and lore.
* Reinforcement Learning Training: RL from Human Feedback (RLHF), plus RL with simulation environments to align NPC behaviors with desired outcomes.
* Vector Database: High-performance vector stores for fast similarity search, enabling retrieval of past interactions and learned behaviors.


---

# 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://docs.altura.com/altura-documentation/altura-intelligence/npc-engine.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.
