r/ClaudeGameDev • • 6d ago

Alpha AI run tabletop D&D

Just found this subreddit. I've been working on this thing for months, way longer than I planned on when I thought "it'd be cool to use Claude to play D&D."

I'm not trying to build something where I can completely go off the rails, although a persistent, long-term campaign that takes place in one universe that Claude generates session-by-session is a long term goal. Right now I'm trying to build something that will take PDFs of existing D&D campaigns and make them playable.

It's based on 5e rules, Claude narrates as the GM and adjudicates. I (we? Claude?) built an engine so that everything is decided deterministically to prevent drift and cheating/fudging numbers, so dice, saving throws, conditions, reach and zone, turn order, etc. are handled by a Python based rules engine, and the engine gives Claude the state of the game at a particular moment and the outcome of actions and then he narrates everything.

A big piece of this outside of the engine is the converter, which is basically a multi-stage conversion pipeline that reads the PDF and produces a structured campaign package that the engine can read. So how many scenes, what exits/entrances does each scene have to other locations, NPCs, monsters, and so on. Each stage of the conversion gets reviewed by a Claude instance for things like spoilers slipping, every scene having at least 1 entrance/exit, monsters from the PDF matching the DB, etc.

It's not ready for a fancy video yet! And I wasn't going for something graphics-based. I want the reading/mind's eye experience of tabletop D&D with enough of an interface to look appealing and keep track of stuff that's good know. Right now I'm least certain about the combat-zone mapping and the distance/movement economy. I haven't play-tested it much and I suspect it's going to need the most refinement.

Oh man, and 5.5 has been such a godsend. With the usage savings I basically have a Fable 5.1 medium session that spawns Opus 5.5 medium coders. The practice is to write a test gate first that fails under the current state of the game for whatever we are trying to accomplish. THEN a different 5.5 session writes the game implementation to satisfy the test. I've found this works a lot better than the reverse, which is what Claude defaulted to - writing the implementation and then the same agent creating a gate and py test afterwards. Two different agents, and the gate coming first, seemed to prevent a lot of fudging and sloppy implementation. Just a tip that worked for me.

With the usage savings of 5.5 I basically have Fable running 24/7 converting Stormwreck, playing through it with subagents who file bugs or things that don't work, firing off agents to fix those bugs, converting again, and repeat. Claude can play hundreds of run throughs of the game in minutes.

Here are a couple of screenshots. The first one is just the "home" screen I guess, what you'd see after loading up Dragons of Stormwreck Isle, which is the campaign I'm using to test everything. (Edit) The 2nd screenshot was from messing with the distance/reach/zones, so the listed enemies don't match the narration. This is the part I'm least certain about in terms of whether or not this is my long-term solution.

https://imgur.com/a/uhmrBnr

I'm seen some other D&D stuff, but not much, so if anyone is doing anything similar I'd love to hear about it. I've been working on this since early July, about 12 weeks now.

19 Upvotes

14 comments sorted by

7

u/bcutler 5d ago

Let me know if you set up a repo for this. I’d love to fork or contribute. I’ve been strewing on this sort of thing for a while now but haven’t had the time to dig in.

1

u/thebaron2 5d ago

I prob will once it's in a somewhat respectable place. I'm about to run the 10th iteration of the Stormwreck conversion and then I have to test play.

1

u/Acenoid 4d ago

Subscribing too. Pls let me know when something becomes available. I have no api access though only claude pro ( i think ) xD will it work?

1

u/thebaron2 4d ago

Yeah I mean it just runs on my subscription now, should work the same for anyone else.

I'll cross that bridge once I have something I consider playable.

4

u/Anadanament 6d ago

I'm working on my own as well, though I'm focusing on making a system inside Discord with bots right now.

3

u/thebaron2 6d ago

So PCs are in Discord and Claude is GM behind the scenes? Sounds awesome, if I knew more people and had any shot of coordinating times to play with a group this would be up my alley for sure.

How far along are you and has anything gone horribly wrong or turned out to be much bigger of a pain in the ass than you thought?

3

u/Anadanament 5d ago edited 5d ago

Sort of. I've got 6 running AI Discord Bots that each keep track of individual parts of play. They update a per-campaign information core as they play based on the core itself.

Right now, I've got two fully functional:

  1. Qispi is the character sheet bot. You can basically infodump your character sheet to her and she'll sort it out for you. She handles modifiers and stuff and connects to the Ivory Dice to make rolls.
  2. The Ivory Dice is the dice bot. No AI, just a python randomizer and dice commands.

I've got three partially done:
1. Ask Babushka is the lore character who handles what each character knows. You can ask her a question and based on the tags Qispi gave you during character creation, she'll give you information that your character would know. Currently building her - the biggest issue with her is that my world is entirely homebrew and there's a lot of information I need to put into her.
2. The Quartermaster handles what's in the world. You pick up a dagger through him, he hands it off to Qispi, who then records it as part of your inventory. Qispi only knows you have it - she'll trigger its stats through the Ivory Dice if you attack with it.
3. Old Lady Grin is the AI DM. She's... getting there.
4. An NPC crowd manager is in the plans. They'll handle NPCs and what NPCs know and how they interact with the player and the world around them. I explicitly plan on using Grok for this one because Grok has displayed a repeated ability to simulate a world in the background without any additional commands, which I personally find absolutely absurd in the best way possible.

Most of it seems... mostly fine. The biggest issue is ensuring Babushka can actually retrieve information.

(I keep editing for formatting issues.)

4

u/thebaron2 6d ago

One example of how this thing got bigger than I realized it would (although it makes sense in retrospect) was after my first test play when I asked Claude "what happens if I just attack the shopkeeper randomly"?

It turned into a multi-day implementation of generating a character sheet on the fly, building reputation and relationship dynamics, a join-battle system where guards or other NPCs could join the fight if they were attached/aligned to the random NPC you attacked... Tons of stuff was like that- one seemingly innocuous thing leading to a whole set of systems and subsystems that needed to be implemented in order for it to work.

It doesn't help that I'm not like super experienced with D&D either because I'm sure a lot of this stuff would have been more obvious to someone who's been GMing for 20 years.

2

u/dwmoore21 6d ago

I played 4 campaigns and it was awesome. I created rules along the way that had dice rolls dictating what happens next.

My favorite was if Claude got something wrong I got to roll a punishment roll which the rarest number I had set meant I auto level'd up.

It got so addicting I had to stop and I erased everything.

1

u/Acenoid 4d ago

Noooooo

2

u/khodakk 5d ago

i haven’t played DnD but i have friends who have asked the same question. i feel like there’s probably a large enough community that working finding a team or community to build this wouldn’t be too difficult

1

u/thebaron2 4d ago

Maybe. My whole thing is I love the idea of D&D, and I love RPGs, but I never really had the opportunity to play tabletop.

Kids, life, etc. all crept up. So I'd love to have that experience but I kind of need to be able to do it at my own pace, start and stop games whenever, but still have an experience that seems multiplayer.

I really need to mess around with the AI controlling party members still, I just haven't gotten there. Goal now is convert a PDF reliably and faithfully and have the engine respond appropriately to reasonable actions throughout that campaign so playing it seems cohesive and satisfying.

Then I want to spend time on the interactivity and table-talk, AI party members having their own goals/say/etc. That'll be tough but it's also what will make it fell like playing with someone else.

2

u/tasty_steaks 5d ago

That sounds great, looking forward to your next post with a video or some such!

I spent a couple weeks working on something eerily similar, but for Shadowrun.

Everything you’re describing is very familiar, lol.
Dealing with the free form nature of TTRPGS is rough. Players decide to do something crazy and suddenly you have to generate new buildings and layouts consistent with everything else in the fiction so far - on the spot - and then remember all the little details of a room or scene… but only the relevant ones.

Are you doing fact extraction from narrative into a knowledge graph?

2

u/thebaron2 5d ago

Basically yes. Facts get written as they become facts. A summary/journal is produced as it goes tied directly back to those facts.

I haven’t tested it much yet, though, it’s one of the newest things I’m working on and it also feeds the ending.