The enginethat gives lifeto your NPCs

Emotion · Memory · Context

Preview of the Affekt Town demo, a town of NPCs with moods and memory
Open the full version

Same game, plus the live panel: each character's mood, stress and memory, and which AMD model wrote every line.

Try this in 30 seconds

  1. Ask Marta the price of a potionThe number comes from the game engine, so it is always the same.
  2. Be kind… then insult herHer mood, stress and memory change. The price does not.
  3. Change the clockOpen the full version at night: she says how late it is and the town goes dark.
  • Gemma 4 on AMDNPC dialogue is generated by a model on AMD Token Factory
  • Code decidesThe model only phrases the line; the engine controls prices and a guard corrects wrong ones
  • 226 testsPrice guard and fallback lines: the game keeps going
  • < $0.003Estimated cost of a 30-line play session

Who is it?

Affekt is a narrative engine for video games developed by Catarina Team. Plain code decides what each NPC feels, remembers, and knows; a language model only phrases the final line. The result: NPCs that answer in character without inventing prices, items, or relationships. The model is swappable: the demo runs Gemma 4 on AMD Token Factory, and the goal is a small fine-tuned model on the player’s own machine

Features

  • 4D Emotional State

    Each NPC tracks valence, initiative, stress, and inertia. Together they set its mood: friendly, neutral, tense, or hostile.

  • Three-Layer Memory

    Short, medium, and long term, with importance-based consolidation and forgetting. NPCs remember what mattered.

  • 80/20 Philosophy

    80% deterministic logic, 20% language model. The model never changes game state, and a fact guard replaces any price that differs from the engine’s.

  • World Graph

    NPCs, places, items, and events live in a graph, in memory or persisted to Neo4j, so every line is grounded in the world.

  • Free-Text Understanding

    A rule-based parser reads intent, tone, offered price, and item. An optional model resolves ambiguous lines, and NPCs fall back to deterministic lines if it is unreachable.

FAQ

The model is swappable. The demo runs Gemma 4 on AMD Token Factory. The engine can also load a local GGUF model, and the goal is a small fine-tuned model running on the player’s machine (planned, not trained yet). If the model is unreachable or times out, NPCs answer with a deterministic line for their mood and the game continues.

80% of the work is plain code: emotion, memory, the world graph, and intent parsing. The remaining 20% is the model phrasing the final line from facts the engine already chose.

A four-dimensional vector (valence, initiative, stress, and inertia) that decides each NPC’s mood and how it reacts to the player.

Three layers: short, medium, and long term. Importance-based consolidation decides what is kept and what is forgotten.

The engine controls them. Facts come from the world graph and the model never changes game state. A fact guard also replaces any price in a reply that differs from the engine’s before the player sees it.

The core is written in Python 3.9+ using only the standard library. Create an engine with create_engine() and call process_action() to get the NPC’s line, mood, and intent.

Affekt is developed by Catarina Team as part of the AMD Developer Hackathon: ACT III.