This project implements an intelligent AI Dungeon Master (DM) for a text-based tabletop role-playing game
This project implements an intelligent AI Dungeon Master (DM) for a text-based tabletop role-playing game[cite: 7]. The core challenge with using Large Language Models (LLMs) for storytelling is their inability to maintain long-term coherence[cite: 9]. This AI DM solves that problem by using a Retrieval-Augmented Generation (RAG) architecture to create a persistent memory system[cite: 22, 23].
The system is designed with a modular three-part structure:
main.py: The main entry point and game loop, handling user interaction.environment.py: Manages all interactions with the Groq API and the LLM, including prompt construction.bot_db.py: Controls the memory system, using ChromaDB to store and retrieve game events.
This architecture ensures that the AI DM can recall past events, maintain narrative continuity, and provide an immersive, evolving gameplay experience where player choices have lasting consequences[cite: 12].
- Python 3.8+
- pip (Python package installer)
Clone this repository to your local machine:
git clone https://github.com/Anuroop128/Dungeon_Master_narrator.ai
cd Dungeon_Master_narrator.ai
Install the required Python packages using the requirements.txt file.
pip install -r requirements.txtMake a directory for the memory by using the code below in the terminal.
mkdir memoryThis project requires an API key from Groq (https://console.groq.com/keys).
For Windows:
set GROQ_API_KEY="your_key_here"For Linux/macOS:
export GROQ_API_KEY="your_key_here"To start the game, run the main.py script from your terminal:
python main.pyYou will be prompted to introduce your character. From there, describe your actions and watch the story unfold. To end the adventure, simply type " quit ".
YouTube video demonstrating the working model of the code