惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
爱范儿
爱范儿
Vercel News
Vercel News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Martin Fowler
Martin Fowler
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
Blog — PlanetScale
Blog — PlanetScale
博客园 - 【当耐特】
人人都是产品经理
人人都是产品经理
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - Franky
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
H
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
G
Google Developers Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How I built a self-hosted AI Gamemaster that actually enf...
Jean Schmitz · 2026-05-13 · via DEV Community

Jean Schmitz

Have you ever wondered if an LLM could actually make a capable Gamemaster? If you have ever tried to play or build a text adventure with a standard AI model, you know the architectural frustration. The AI acts like a hyperactive improv partner. If you type 'I jump over the moon and slay the dragon with a spoon', the model simply hallucinates: 'Yes, you do that.' There is no state management, no constraints, and zero real game mechanics. But what if you combined a deterministic, rule-based RPG engine with an omniscient generative AI Gamemaster?

I wanted a genuine RPG experience with a strict Gamemaster, so I built TaleWeaver. It is an open-source, self-hosted RPG engine that generates dynamic worlds on the fly.

Here is how I solved the "LLM Amnesia" and enforced strict game mechanics using a 2-Pass Architecture.

The Problem: Mixing Mechanics and Narrative

LLMs are fantastic at writing atmospheric prose, but they are terrible at tracking state, hitpoints, and inventory items. If you force a single prompt to manage complex math and write a cinematic story simultaneously, the model will hallucinate.

The Solution: The 2-Pass Engine

I split the workload into two distinct processes to keep the game state intact:

1. Pass 1: The Rule Engine

When a user submits an action, a fast, highly logical model evaluates the input against the current game state. It performs hidden D20 stat rolls, checks the inventory, and calculates damage.

  • Output: A strict JSON GameEvent that mutates the database (e.g., updating HP, moving an NPC to a new scene, or adding loot).

2. Pass 2: The Gamemaster

Once the database state is safely updated, a creative narrative model takes the raw JSON outcome and translates it into an immersive, atmospheric response.

The Tech Stack

I built this engine to be completely self-hosted and robust:

  • Backend: Python and FastAPI. The database is SQLite, fully tenant-ready with UUID-based primary keys.
  • Frontend: Vue.js for a snappy, app-like experience.
  • Dynamic Cartography: The engine automatically renders a live directed graph map of the discovered scenes using Rough.js.
  • TTS Audio: Integrated Gemini 3.1 Flash TTS and ElevenLabs. The engine parses director notes to build dramatic tension directly into the audio output.

Bring Your Own Key (BYOK) & Local Execution

The entire stack is containerized with Docker for a frictionless 1-click setup. It uses the LiteLLM adapter under the hood. You simply plug in your API key for top-tier models, which are highly recommended to handle the complex JSON reasoning.

I also added experimental support for local Ollama execution. It is tough to get smaller local models to consistently output complex nested JSON, but it is a fun challenge to push the boundaries of offline play.

Check out the code

You can find the repository, the complete JSON manifest specifications, and the setup scripts here:
https://github.com/jschm42/taleweaver