DEV Community

Carlos Fernández-Loría
Carlos Fernández-Loría

Posted on • Updated on

Chronicles of SHARI - 001: Developer Log for a Text-Based Game Master

Welcome, fellow adventurers, to the Chronicles of SHARI! In this series of posts, I will share my team’s progress on the development of SHARI, a text-based game master for enthusiasts of tabletop roleplaying games (TTRPGs).

(Post 2 here is available here.)

Tabletop what?

TTRPGs are an immersive and collaborative form of gaming that transports players into rich, fantastical worlds of their own creation. Dungeons and Dragons (D&D) is a famous example of a TTRPG that has captured the hearts and imaginations of millions. In games like D&D, players assume the roles of brave adventurers, embarking on perilous quests filled with epic battles, intriguing mysteries, and unforgettable moments.

Unlike traditional video games, TTRPGs rely on shared storytelling and imagination, where players assume the roles of unique characters and navigate thrilling adventures guided by a game master. The excitement lies in the boundless freedom to shape your character's destiny, forge deep connections with fellow players, and unravel captivating narratives that unfold in real-time. TTRPGs foster creativity, problem-solving, and teamwork, offering an unparalleled experience where the possibilities are limited only by your collective imagination.

Example of a TTRPG game session.

Now, let me introduce you to SHARI (System for Human-AI Roleplaying Interactions). Our project aims to develop a text-based system capable of assuming the role of a game master, a task traditionally fulfilled by a human player. The game master's responsibilities are multifaceted, encompassing storytelling, world-building, and action resolution, among others. By leveraging the power of large language models (LLMs) like the one behind ChatGPT, we believe SHARI can rise to the challenge and provide a unique and engaging roleplaying experience.

In this exploratory stage of development, we have chosen to focus on accommodating only one player. While SHARI's current single-player limitation may not capture the full splendor of a collective adventure, we are confident that the project holds tremendous potential. SHARI can serve as an exceptional tool to introduce newcomers to the world of TTRPGs and provide a valuable alternative for individuals whose friends may be occupied with other commitments. With SHARI, players can embark on thrilling quests whenever they desire, forging their own heroic tales.

Is this yet another AI project? How is it different from other stuff out there?

Yes, it is. SHARI is inspired by projects like AI Dungeon, which has shown the great potential of AI in crafting immersive roleplaying experiences. In fact, it was my own experience asking ChatGPT to roleplay as a game master that prompted me (pun intended) to explore the idea of developing our own AI-powered system capable of assuming the role of a game master. If you are curious, you can check that original interaction here.

So, what sets SHARI apart from alternatives like AI Dungeon and ChatGPT? Let's delve into SHARI's features:

  • Reliable Game Master: While ChatGPT can easily deviate from its role as a game master, SHARI will not, ensuring a continuous and immersive experience for players.

  • Preserved Player Agency: Other AI systems for interactive storytelling tend to narrate actions for the player's character without explicit player input. SHARI will respect and uphold player agency. It will refrain from assuming or dictating actions for the player, allowing players to maintain full control over their characters' choices.

  • Rule-Based Action Resolution: TTRPGs thrive on rule systems that govern gameplay mechanics and outcomes. While ChatGPT and AI Dungeon lack this integration, SHARI will incorporate user-defined rule systems. This inclusion will enable SHARI to accurately resolve in-game actions and determine outcomes based on established rules, enhancing the authenticity of the roleplaying experience.

  • Memory: A common challenge with ChatGPT and AI Dungeon is their tendency to forget prior interactions, leading to inconsistencies in the narrative. SHARI will take into account past interactions, ensuring a cohesive and coherent storyline where previous choices and events influence future developments.

  • User-Defined Scenarios: Immersing oneself in adventures crafted by others is a cherished aspect of TTRPGs. SHARI will allow players to select and instruct the AI game master to run user-defined roleplaying scenarios.

How are you planning to build this?

Before I delve into the details, I want to clarify that we are still in the process of figuring things out. I'm very passionate about TTRPGs and extremely curious about the potential of LLMs, so I view this project mostly as an opportunity for personal enjoyment and exploration. This means we will likely try a bunch of different ideas along the way.

That said, we do have a general plan in mind. But before I tell you about the plan, let's first talk about the most obvious alternative to SHARI: using a prompt completion system like ChatGPT. I mentioned above the use of ChatGPT as a system capable of assuming the role of a game master. This alternative relies on developing a powerful LLM capable of learning how to be a game master based on text data. In this scenario, there is no need to code a specific "game master algorithm." Instead, we could gather sufficient data on conversations between game masters and players, which would enable us to construct a prompt completion system that is capable of responding as a game master would.

Example of a game master based on ChatGPT.

But here's the thing—although my interaction with ChatGPT as a game master yielded reasonable results, I don't think we could achieve all the goals we have for SHARI by solely relying on an LLM, even if we were to fine-tune the LLM with game mastering conversations. I believe it would be too difficult to precisely control what the model is learning from the data or to improve specific aspects where the model is not performing well. Therefore, our approach will not revolve around "collecting better data" or enhancing the game mastering capabilities of the LLM through fine tuning, although these aspects could certainly complement our solution later on.

Our approach entails developing an actual "game master algorithm" and implementing it with the assistance of LLMs.

At its core, an algorithm is comprised of instructions and a control flow that governs its execution. Consequently, our vision involves implementing the "game master algorithm" as a control flow that utilizes prompt calls to LLMs, with each call corresponding to the execution of a specific step in the algorithm. Therefore, the crux of the matter lies in (a) devising the appropriate flow and (b) formulating the suitable prompt calls to execute the steps within this flow.

The flow aspect will draw heavily from domain expertise, including my experience as a game master for the past 20 years and that of many other game masters who have written extensively on how to play TTRPGs the "right way". For example, we are drawing inspiration from "The Useless Pontification on Roleplaying Theory" by the Angry GM:

Let's examine the fundamental core of role-playing exchange—the step-by-step process of 'how to play an RPG.'

  1. The DM presents a situation.
  2. The players imagine their characters within that situation and determine how their characters respond.
  3. The DM determines the outcome and describes the results, thereby creating a new situation.

This is the essence of a role-playing game. However, step three is slightly more intricate, and can be broken down into the following:

3a. The DM determines the feasibility of the action.
3b. The DM determines whether the outcome should be determined randomly.

3b1. The DM devises a method for random outcome determination.
3b2. The DM either rolls a die or instructs the player to do so.
3b3. The DM determines the outcome of the die roll.

3c. The DM decides on an outcome.
3d. The DM describes the outcome to the players.

(We call this process of determining the results of actions "Action Resolution" or "Adjudicating Actions")

Steps 3a to 3d essentially form the foundation of a "game master algorithm" for action resolution. They outline how a game master should proceed to ascertain what occurs next. Therefore, the core of our plan involves structuring SHARI responses as a control flow that encompasses several prompt calls to one or more LLMs, rather than assuming that the LLM can resolve everything in a single call.

Example of a game master based on a series of prompt calls to ChatGPT.

Note that, if any of the steps in the flow turns out to be too complex to be resolved in a single prompt call, we could further decompose that step into a series of prompt calls. My intuition tells me that when there are certain steps where the language model doesn't perform very well on its own, it should be possible to improve its performance by breaking down the problem into smaller pieces.

As for the actual technology that we will use to implement the control flow of prompt calls, we are going with the Semantic Kernel library developed by Microsoft. This Software Development Kit (SDK) integrates LLMs with conventional programming languages like C# and Python. I will talk more about Semantic Kernel in future posts, after making progress on the actual implementation of SHARI. If you're interested in learning more about Semantic Kernel, I highly recommend checking out the amazing tutorial by John Maeda.

Who are you again?

Hi there! I'm Carlos, a dungeon master turned data science professor at the Hong Kong University of Science and Technology. While my existing research focuses on machine learning for causal inference, I've been captivated by the potential of LLM-based systems like ChatGPT. This fascination has inspired me to dive into the world of building AI systems with LLMs, and what better way to start than by creating our own game master?

Allow me to introduce you to my incredible team. I've assembled a group of talented individuals who share a deep interest in exploring the capabilities of LLMs. We are fortunate to have the expertise of Javier Loría as our Technical Lead, along with the development skills of Daniel Granados and Diego Granados. Andrea Loría takes charge as our Scrum Master, ensuring smooth coordination and efficient project management. Additionally, Simón Echavarría brings valuable business insights to the table, as we envision the possibility of turning this project into a viable product and, hopefully, a successful business venture.

What's the project status?

After several months of talking about the project, we finally started coding a couple of weeks ago! Currently, none of us are working on this project full time. However, we are committed to pushing the project forward every week, even if it's just a small step. We have a set of exciting ideas that we're eager to explore and implement.

At this stage, we only have a simple chatbot that leverages OpenAI's LLMs to respond to user conversations. Our current focus is on improving the chatbot so that it can maintain its role as a game master without breaking character. We want to ensure that the interactions with the system remain immersive and align with the experience of playing a TTRPG.

Your comments and feedback are more than welcome! Whether you have ideas for features you'd like to see in the system or suggestions for its implementation, we value your input. Your engagement will play a crucial role in shaping the direction of our project.

We'll continue to provide updates here every month or so, so stay tuned for more exciting developments!

Top comments (0)