MAX CAPACITY@maxcapacity
I built a fully autonomous D&D campaign engine that plays itself.
Three AI players. One AI dungeon master. CrewAI orchestrating. DeepSeek running the brains. Python handling all the bookkeeping. Cost: about $0.20 per session.
It runs daily, updates a blog with session recaps, and maintains a wiki of every NPC, location, and faction the party encounters.
The hard part wasn't getting AI to play D&D. The hard part was getting it to play a *campaign*. Multiple sessions. Multiple adventures. Characters that level up. A world that remembers.
Some of what I had to solve:
When an adventure completes (3 sessions each), Python detects it, loads the next adventure file, resets the state, and keeps going. No human needed. 20 adventures across 4 acts, all mapped out.
Milestone leveling fires automatically between adventures. HP by class hit die, new class features, spell slots, cantrips. A level 3 fighter knows he has Action Surge. A level 1 fighter doesn't. The agents' prompts update to match.
The wiki was a disaster at first. 155 entries in 10 sessions, mostly junk like "the door" and "cast fireball." Rewrote the Wiki Keeper with strict filtering: named NPCs, named locations, named factions, unique items only. Session 1 now produces ~15 clean entries.
Story summaries were ballooning. 1,500+ words by session 10, eating context window and burning tokens. Now they get condensed to key plot points when an adventure wraps.
The DM kept skipping rest periods. Six sessions, no long rest, party running on fumes. So when a new adventure starts, Python injects a mandatory rest and resupply block into the DM's opening prompt.
Biggest lesson: you have to be very clear about what Python owns vs. what the AI owns. Session tracking, adventure progression, level data? Python. The AI touches none of it. The moment you let the DM agent "help" manage state, it will hallucinate session counts and break everything.
Still early. Need to test multi-session persistence over weeks, not days. But the foundation is solid and the sessions are genuinely fun to read.
Fully autonomous AI D&D. $0.20 a session. The future is weird.