projects / ai & ml / living npcs
Experiment 2025

Living NPCs —
IA generativa en juegos retro

¿Qué pasa cuando intentas darle memoria persistente y personalidad coherente a los NPCs de un juego estilo Pokémon usando un LLM? Este es el registro técnico de lo que funcionó, lo que no, y por qué el problema es más interesante de lo que parece.

Python LLMs GPT-4o-mini Prompt Engineering Gestión de Contexto Presupuesto de Tokens Few-shot Streaming
Ver el informe del experimento completo →

Los NPCs clásicos son cognitivamente planos — they say the same things, forget every interaction, and have no sense of the world around them. The question was simple: can you fix this with an LLM? And if yes, at what cost in latency, tokens and coherence?

Built a three-module system — episodic memory, personality consistency and world awareness — all running within a constrained token budget. Tested across 220 evaluated conversations, iterating from v0.1 to v0.4 with measurable improvements at each step.

01
The temperature tradeoff is real

Higher temperature produces more creative, "in-character" responses — but also more repetitiveness. The sweet spot was identified experimentally across 30 samples per temperature value.

02
Lost in the middle is a core challenge

LLMs struggle with information buried in the middle of long contexts. Memory architecture had to be designed around this — not just appending history but structuring it for retrieval.

03
Latency breaks immersion before cost does

The immersion-breaking threshold was identified at a specific response time. Beyond that, players notice the delay — making latency a harder constraint than token cost in practice.

04
Local models are the real endgame

GPT-4o-mini makes the experiment viable for prototyping. But for production, a local model of sufficient quality would cut cost per session dramatically — and eliminate latency from API calls.

GPT-4o-mini
Core LLM for NPC responses and personality
Python
Memory module, prompt engineering and evaluation
Prompt Engineering
System prompt architecture for personality and constraints
Plotly
Latency, memory accuracy and cost visualizations