Spaces:
Sleeping
Sleeping
File size: 5,178 Bytes
cf73536 48176ed cf73536 14a9514 4a0bfe5 ea9bbd1 cf73536 8c3f36d 62940b6 8c3f36d cf73536 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | ---
title: Mini DungeonGame
emoji: ๐
colorFrom: green
colorTo: red
sdk: gradio
sdk_version: 6.18.0
python_version: '3.11'
app_file: app.py
pinned: false
license: mit
hf_oauth: true
short_description: This is an LLM Interactive Dungeon RPG
social_media: https://youtu.be/BBRy5JsOpSI
tags:
- track:Thousand_Token_Wood
- badge:off_brand
- badge:best_demo
- badge:bonus_quest_champion
- badge:judges'willcard
---
# โ๏ธ Mini Dungeon Adventure
<p align='center'>
<img src="./pics/image.png" width="650" height="480">
</p>
An AI-powered text-based fantasy RPG built with **Gradio** and **Hugging Face Inference API**.
The player explores a dangerous dungeon by typing natural language actions. Instead of selecting predefined choices, an LLM interprets the player's response and maps it to the appropriate game action.
You can find the demo video here: https://youtu.be/BBRy5JsOpSI
---
## ๐ฎ Overview
**Mini Dungeon Adventure** is a lightweight interactive RPG where:
- The player types any action they want
- The LLM understands the player's intent
- The game engine updates the world state
- The story progresses through connected events
- The adventure ends depending on survival, resources, and decisions
Example:
```
Player : I raise my sword and attack the guardian.
LLM : Action -> PHYSICAL_ATTACK
GAME : HP-20, Move to the next state
```
The goal is to create the feeling of an open-ended adventure while maintaining a controlled narrative structure.
---
## โจ Features
### ๐ง Natural Language Action System
Players are not limited to buttons.
Possible inputs:
```
"Attack the monster"
"Try to negotiate"
"Use my magic"
"Run away"
"Search the room"
```
The LLM classifies the intent and connects it to the correct game transition.
---
### ๐บ๏ธ Branching Story Graph
The adventure consists of multiple connected events. For example,
```
Entrance
|
-------------------
| | |
Battle Magic Run Away
```
The graph is controlled by the game engine rather than generated freely by the LLM.
This provides:
- Consistent story progression
- Predictable game states
- Replayable paths
Play it and explore differnet endings.
## ๐ Story
The player enters an ancient dungeon beneath a volcanic mountain.
Deep inside lies an ancient dragon.
However, the dragon is not simply a monster.
Long ago, the dragon discovered a dangerous magical core beneath the mountain. If the energy became unstable, the volcano would erupt and destroy the kingdom.
The dragon remained underground to:
- Contain the volcano
- Absorb unstable energy
- Prevent disaster
Humans misunderstood the dragon's purpose and believed it was the source of the danger.
The player must decide:
- Fight the dragon
- Escape with treasure
- Discover the truth
---
## ๐ฒ Game Mechanics
The player has three main attributes:
| Attribute | Description |
|---|---|
| โค๏ธ HP | Health points. Reaches 0 โ defeat |
| ๐ฎ MP | Mana points. Used for magic actions |
| ๐ช Coin | Currency collected during the adventure |
```
HP: 75
MP: 40
Coin: 120
```
---
## ๐งฉ Architecture
The system is divided into three parts:
```
Player Input
|
v
LLM Intent Classifier
|
v
Game Engine
|
v
Next Story Event
```
---
### 1. LLM Layer
The model: **Qwen/Qwen2.5-7B-Instruct**, used to classify the player's response.
### 2. Game Engine
The engine handles:
- HP changes
- MP consumption
- Coin rewards
- Event transitions
- Ending conditions
The LLM does **not** directly control game state.
### 3. Event System
Each event contains:
```
Event:
title
description
images
possible_actions
next_events
```
## ๐ ๏ธ Tech Stack
| Technology | Purpose |
| -------------------------- | --------------------- |
| Python | Core implementation |
| Gradio | Web interface |
| Hugging Face Inference API | LLM inference |
| Qwen2.5 | Action understanding |
| Pillow | Image processing |
| MoviePy | Adventure recap video |
## ๐ Running Locally
### Install dependencies
```bash
pip install -r requirements.txt
```
### Set Hugging Face token
Create an environment variable:
```bash
export HF_TOKEN="your_token_here"
```
or add it through Hugging Face Space Secrets.
### Run
```bash
python app.py or main.py
```
## ๐ฎ Future Improvements
Potential extensions:
```
- More dungeon chapters
- Inventory system
- Enemy combat simulation
- Character classes
- Persistent player save system
- More advanced LLM action planning
```
## ๐ Design Philosophy
This project explores a hybrid approach:
```
Use AI for understanding player creativity, but use traditional game logic for control.
```
The LLM provides flexibility.
The game engine provides reliability.
Together they create a more interactive text adventure experience.
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|