sqfoo commited on
Commit
8c3f36d
ยท
verified ยท
1 Parent(s): b084cfa

Update README.md

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