A new benchmark surfaced on Hacker News this week that grades large language models on a uniquely creative task: acting as a Dungeons & Dragons 5th Edition Game Master. D20 Bench automates the evaluation of an LLM's ability to manage game state, adhere to rules, and generate coherent narrative—all scored by executable code rather than human judgment.
Type: Automated Benchmark | Grading: Code Execution | Tasks: 5 | License: MIT
What D20 Bench Tests
The benchmark presents an LLM with five distinct tasks core to running a D&D 5E session. Each prompt requires the model to parse a game state, apply rules, and produce a JSON output that is mechanically correct. The tasks are:
- Initiative Order: Order combatants based on rolled initiative.
- Attack Resolution: Calculate the success of an attack, including hit, damage, and potential critical hits.
- Ability Check: Resolve a skill or ability check against a Difficulty Class (DC).
- Spell Lookup: Retrieve accurate spell details from the SRD (Systems Reference Document).
- Rules Arbitration: Answer a player's question by citing the correct rule.
The system grades responses by executing Python code that validates the LLM's JSON output against the game's official mechanics. This eliminates subjective scoring and provides a deterministic, reproducible metric.
Benchmarks and Early Results
The project's initial run provides a baseline for several leading models. Scores reflect the percentage of tasks where the model's JSON output passed all code-based validation checks.
| Model | D20 Bench Score | Context Window | Notes |
|---|---|---|---|
| GPT-4 Turbo | 80% | 128K | Most consistent on rules and state tracking. |
| Claude 3 Opus | 60% | 200K | Struggled with specific attack resolution logic. |
| GPT-3.5 Turbo | 40% | 16K | Frequent formatting errors in JSON output. |
| Llama 3 70B | 20% | 8K | High failure rate on spell lookup and complex arbitration. |
The results highlight a significant gap between top-tier and mid-range models on this task. The 80% score for GPT-4 Turbo suggests strong capabilities in parsing complex instructions, maintaining state, and applying logical rulesets—skills that extend beyond gaming into areas like workflow automation and technical support.
How to Run the Benchmark
Running D20 Bench locally requires Python and API keys for the models you wish to test. The process is designed for developers.
- Clone the repository:
git clone https://github.com/username/d20-bench(Check the project's Hacker News page for the official repo link). - Install dependencies:
pip install -r requirements.txt - Set API keys: Add your OpenAI, Anthropic, or other provider keys to a
.envfile. - Execute the test: Run
python run_benchmark.py --model gpt-4-turboto test a specific model.
The script will run all five tasks, print the model's responses, and output a final score. You can review the detailed JSON outputs and the grader's comments for each failure.
"Understanding the Grading Code"
The benchmark's core is its grader.py module. For each task, it:
validate_attack).
Pros, Cons, and Key Trade-offs
Advantages:
- Objective, Code-Graded Scoring: Removes human rater bias and variance, ensuring perfect reproducibility.
- Tests Composite Reasoning: Combines instruction following, state tracking, rule application, and structured output generation in one test.
- Open and Extensible: The MIT-licensed code allows anyone to add new tasks or modify existing ones.
Limitations:
- Narrow Domain Focus: Excellence here may not generalize to all reasoning tasks.
- No Narrative Quality Assessment: The code only checks mechanical correctness, not creativity, flavor, or player engagement.
- Small Initial Task Set: With only five tasks, the score has limited statistical significance.
Bottom line: D20 Bench is a highly specific but rigorously objective test for a complex, multi-step reasoning skill.
Alternatives and Comparisons
Most LLM benchmarks test knowledge (MMLU), reasoning (GPQA), or coding (HumanEval). D20 Bench occupies a niche in testing interactive, stateful rule-following. Closer comparisons include:
| Benchmark | Focus | Grading Method | Output Type |
|---|---|---|---|
| D20 Bench | D&D 5E Game Mastering | Code Execution | JSON |
| ChatArena | Multi-Agent Conversation | Human / Heuristic | Free Text |
| WebArena | Web Task Automation | Code Execution | Action Sequence |
| HotpotQA | Multi-Hop Factual QA | Accuracy | Text Answer |
For developers building AI for games, interactive fiction, or complex customer support bots that require following a guide, D20 Bench offers a more targeted stress test than general knowledge benchmarks. Tools like WebArena share its code-graded philosophy but for a different domain.
Who Should Use This Benchmark
This benchmark is valuable for:
- AI Game Developers: Testing NPC dialogue systems or procedural content generators that must respect game rules.
- Researchers exploring LLMs' ability to operate within constrained, rule-based environments.
- Prompt Engineers designing complex, multi-step chain-of-thought prompts who need a test for structural consistency.
You can likely skip this benchmark if: Your work focuses solely on traditional NLP tasks (summarization, sentiment), pure code generation, or open-ended creative writing without strict output formats.
The Verdict on LLMs as Game Masters
D20 Bench proves that even advanced models like GPT-4 Turbo are not flawless rules engines, failing 20% of the time on basic D&D mechanics. This benchmark provides a crucial, automated checkpoint for a specific application of LLMs. Its real value lies not in declaring a "best" model, but in giving developers a tool to quantify regression or improvement in an LLM's ability to follow complex instructions and manage state—a capability critical for the next wave of autonomous AI agents. The path to reliable AI Dungeon Masters is now a measurable one.

Top comments (0)