🐉 AI Dungeon Master
A web-based D&D adventure game powered by Google's Gemini AI. Experience dynamic, AI-generated storytelling with persistent campaigns, randomized characters, and immersive settings.
✨ Features
- AI-Powered Dungeon Master — Dynamic storytelling that adapts to your choices
- Randomized Adventures — Each reset generates new characters, settings, and themes
- Persistent Campaigns — Your progress is automatically saved
- Multiple Themes — Medieval Fantasy, Steampunk, Sci-Fi, Post-Apocalyptic, and more
- Character Variety — Random races (Human, Elf, Dwarf, Orc) and classes (Warrior, Mage, Rogue, Engineer, Cleric)
- Dark/Light Mode — Toggle between themes for comfortable play
- CLI & Web Modes — Play in your terminal or browser
📋 Prerequisites
- Python 3.12 or higher
- Node.js 18+ and npm
- Google Gemini API key
🚀 Getting Started
1. Clone the Repository
git clone https://github.com/Cillian-Cooke/hackathon.git
cd hackathon
2. Set Up Environment Variables
Create a .env file in the project root:
touch .env
Add your Gemini API key to the .env file:
GEMINI_API_KEY=your_gemini_api_key_here
📝 Getting a Gemini API Key:
- Go to Google AI Studio
- Sign in with your Google account
- Click "Create API Key"
- Copy the key and paste it in your
.envfile
3. Install Python Dependencies
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
4. Install Frontend Dependencies
npm install
🎮 Running the Game
Web Mode (Recommended)
Start both the backend server and frontend in separate terminals:
Terminal 1 — Backend:
source venv/bin/activate # If not already activated
uvicorn server:app --reload
Terminal 2 — Frontend:
cd my-react-app
npm run dev
Open your browser to http://localhost:5173
CLI Mode
For a terminal-based experience:
source venv/bin/activate
python cli.py
🎯 How to Play
- Start — The AI Dungeon Master sets the scene
- Type Actions — Enter what your character does (e.g., "I search the room", "Attack the goblin")
- Special Commands:
📖 Summary of Story— Get a recap of your adventure👤 Player Status— View your character's stats and abilities🔥 Reset Campaign— Start a completely new adventure
🏗️ Project Structure
ai-dungeon-master/
├── my-react-app/ # Node Modules and React Deps
│ └── src/
│ └── main.jsx # React application entry
├── cli.py # CLI game engine & DM logic
├── server.py # FastAPI backend server
├── style.css # Application styles
├── index.html # HTML entry point
├── .env # Environment variables (create this)
├── .gitignore # Git ignore rules
├── requirements.txt # Python dependencies
├── package.json # Node dependencies
└── README.md # This file
📦 Dependencies
Python
fastapi— Web framework for the APIuvicorn— ASGI servergoogle-genai— Gemini AI SDKpython-dotenv— Environment variable managementpydantic— Data validation
Frontend
react— UI frameworkreact-icons— Icon componentsvite— Build tool and dev server
🔧 Configuration
The game can be customized by modifying constants in cli.py:
| Setting | Description | Default |
|---|---|---|
GEMINI_MODEL |
AI model to use | gemini-2.5-flash |
TOTAL_STAT_POINTS |
Points for character stats | 30 |
max_output_tokens |
Response length limit | 2048 |
🤝 Contributing
Contributions are welcome! Feel free to:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the MIT License — see the LICENSE file for details.
🙏 Acknowledgments
- Google Gemini for the AI capabilities
- FastAPI for the excellent Python web framework
- Vite for the blazing fast frontend tooling
Log in or sign up for Devpost to join the conversation.