Immersive Roleplaying, Built
and Driven by AI
Introduction
An idea came to my head after watching the video of Deborah Ann Woll introducing Jon Bernthal to the world of Dungeons & Dragons.
What if artificial intelligence could take on the role of Dungeon Master, crafting dynamic worlds, weaving intricate narratives, and responding to player inputs with limitless creativity?
That is what I set out to accomplish with this project, to combine the power of artificial intelligence with the magic of roleplaying games.
However, I had never designed a game before, nor had I ever played Dungeons & Dragons. And one thing for sure, I would have been sued for trademark infringement if I had tried to create an AI Dungeon Master for Dungeons & Dragons.
So instead, I set out to build something original. A game with everything I ever wanted - a limitless, immersive medieval RPG.
Vision
My goal for this project is to integrate the traditional aspects of roleplaying games such as character progression, dynamic relationships, combat, and interactive storytelling with artificial intelligence.
I want to create an experience where artificial intelligence can facilitate both actions and storytelling, responding dynamically to player choices instead of relying on pre-written and pre-scripted events.
I believe that artificial intelligence can push the boundaries for roleplaying games by removing constraints and limitations to allow for emergent storytelling, deeper player agency, and a limitless world that feels alive.
I swing my sword at the bandit’s arm.
You launch a swift slash with your sword aimed at the bandit’s arm. The blade connects, cutting through fabric and drawing a quick gasp from your foe. Dealt 10 slashing damage to the right arm.
The bandit lunges forward with a shortsword, aiming for your abdomen. The tip barely scrapes past your chainmail, leaving a sharp sting. Received 5 piercing damage to the torso.
I thrust my sword towards the enemy’s chest.
With a determined thrust, your sword pierces forward, targeting the enemy’s chest. The tip finds a gap in the armor, sending a shiver of pain through your opponent. Dealt 12 piercing damage to the torso.
The bandit shakes off the damage and raises his shield, bracing for your next attack. Damage dealt and received is reduced next turn.
What do you do?
Do
Say
Combat Flow Demonstration
Mechanics
This project is designed around four core systems that are interconnected to create an immersive and dynamic roleplaying experience.
Each system uses artificial intelligence to create a dynamic world, where every action and decision has an impact. Whether through the character themselves, the outcome of battles, or past choices, all of these factors influence how the world responds to the player.
Character System
Stats that progress through actions, an immersive health system, traits, and history that influence roleplaying.
Combat System
Turn-based combat facilitated by AI, based on player input, and outcomes are determined by player, weapon and armour stats.
Story System
AI-driven quest system with dynamic objectives, evolving narratives, and unique character interactions based on player choices.
World System
Time-based world with coordinate travel, AI-generated locations and characters, and memory retention for persistence.
Artificial Intelligence
As of March 2025, this project plans to use OpenAI’s GPT-4o mini model for its in-game artificial intelligence system.
From my research, this model is highly-rated for its strong multimodal reasoning and function-calling capabilities at a relatively low cost, making it suitable for integration into the game’s systems and high-volume token usage.
GPT-4o mini
Input Context Window
128K tokens
Maximum Output Tokens
16.4K tokens
Input Pricing
$0.15 per million tokens
Output Pricing
$0.60 per million tokens
MMLU
82.0%
MMMU
59.4%
HellaSwag
Not available
GSM8K
Not available
HumanEval
87.2%
MATH
70.2%
IFEval
Not available
Textual Intelligence
Generates dynamic, context-aware dialogue and responses based on player choices and world events.
Multimodal Reasoning
Processes multiple data types, such as text, stats, and game logic to adapt responses.
Function Calling
Triggers in-game mechanics, such as stat calculations, event progression, and combat outcomes.
Limitations
However, one challenge encountered during early development was the time it took to generate a semi-detailed player character, including stats and equipment.
This raises concerns about how NPC generation at scale may affect performance, since the game world also relies on generated characters with unique histories and roles.
To address this, I will have to focus on optimizing the generation speed without compromising the quality of the output. This includes implementing pre-determined parameters, assigning different AI models to specific tasks, and exploring the potential of running multiple AI models concurrently to distribute processing load efficiently.
export const generatePlayer = async (): Promise<any> => { const prompt = { role: "system" as const, content: "Generate an time-period accurate 11th century medieval male character that satisfy this schema and output output only in JSON format that adheres exactly to the following schema. For equipment, only use items from the following lists: Available Armor: ${JSON.stringify(armor, null, 2)} Available Armor: ${JSON.stringify(armor, null, 2)} Schema to follow: { firstName: { type: String, required: true }, lastName: { type: String, required: true }, createdAt: { type: Date, default: Date.now }, birthday: { type: Date, required: true },
Player Generation Snippet
Technical Stack
For this project, I am using Next.js, a React framework to build the frontend. The backend is powered by Node.js with Express to manage game logic, interactions with artificial intelligence, and API requests. For the database, I am using MongoDB for its NoSQL, document-oriented structure.
Since I have limited experience with full-stack development, I have to use artificial intelligence with third-party extensions such as Roo Code and Cline to perform the duties and responsibilities of a Technical Lead. These extensions allow artificial intelligence to access the entire repository, providing a broader context for development.
Working with artificial intelligence presents its unique challenges. Choosing what model you use with Roo Code or Cline is important. Models optimized for reasoning with a large context window tend to perform better in development workflows but come at a higher cost compared to standard chat models.
Finding the right balance between efficiency, accuracy, and affordability is key to the success of development.
o3-mini
Codeforces
2036
SWE-bench
42.9%
LiveCodeBench
65.4%
GPQA Diamond
76.8%
Input Pricing
$1.10
Output Pricing
$4.40
Claude 3.5 Sonnet
Codeforces
717
SWE-bench
50.8%
LiveCodeBench
38.9%
GPQA Diamond
65.0%
Input Pricing
$3.00
Output Pricing
$15.00
Gemini 2.0 Flash
Codeforces
N/A
SWE-bench
51.8%
LiveCodeBench
34.5%
GPQA Diamond
58.6%
Input Pricing
$0.10
Output Pricing
$0.40
R1 Distill Qwen 32B
Codeforces
1691
SWE-bench
32.8%
LiveCodeBench
57.2%
GPQA Diamond
62.1%
Input Pricing
$0.12
Output Pricing
$0.18
Next.js
A React framework for building fast, scalable web applications with server-side rendering (SSR) and static site generation (SSG).
Node.js
A JavaScript runtime that allows server-side development, handling asynchronous operations efficiently with its event-driven architecture.
MongoDB
A NoSQL database that stores data in flexible, JSON-like documents, making it ideal for handling unstructured or evolving data.
Roadmap
Development began with OpenAI’s GPT-4o mini, but as the project evolved, I pivoted toward third-party extensions like Roo Code and Cline while exploring a number of different artificial intelligence models.
While working on the equipment management system, I encountered a significant roadblock, which led me to restart the project from scratch. All of the agentic artificial intelligence models I used did not understand the code written by GPT-4o mini at all.
Starting from scratch will allow the artificial intelligence model and third-party extensions to write their own code, and have a complete understanding of the repository’s context and structure.
Moving forward, I plan to wait until AMD provides ROCm support for Linux, as my RX 6800 GPU is currently unsupported. Once support is available, I intend to run DeepSeek R1 Distill Qwen 14B locally, allowing for greater control over fine-tuning and cost.
As I wait, I am going to deepen my understanding of agentic artificial intelligence models and create documentation for the architecture, planning process, and coding process to improve the efficiency of the artificial intelligence model.
Phase 1
1.0
ROCm Support for Linux
Phase 2
2.0
Backend Architecture
3.0
Character System
4.0
Combat System
Phase 3
5.0
World System
6.0
Quest System
© 2025 Brian Mac. All Rights Reserved.