Spaces:
Sleeping

byte-vortex commited on
Commit
46a5d1b
ยท
verified ยท
1 Parent(s): b4549e6

Deploy Myco from CI

Browse files
Files changed (1) hide show
  1. ui/gradio_app.py +174 -176
ui/gradio_app.py CHANGED
@@ -1,61 +1,56 @@
1
- """Gradio app composition for Myco."""
2
 
3
  from typing import Any, cast
4
-
5
  import gradio as gr
6
 
7
  from game.engine import (
8
- collect_current,
9
- discover_mushroom,
10
- eat_current,
11
- follow_whisper,
12
- hf_companion_status,
13
- myco_reply,
14
- pick_current,
15
- study_current,
16
  )
17
  from game.state import welcome_history
18
  from models.mushroom import Mushroom
19
  from ui.renderers import (
20
- dex_markdown,
21
- forest_scene,
22
- game_intro_markdown,
23
- game_status_markdown,
24
- hero_markdown,
25
- home_forest_markdown,
26
- mushroom_card,
27
- play_hook_markdown,
28
- progress_markdown,
29
  world_map_markdown,
30
  )
31
 
32
  EMPTY_COLLECTION = None
33
- START_POSITION = (1, 1)
34
 
35
  HOME_MARKDOWN = """
36
  ## Welcome to the Myco forest
37
 
38
- Myco is a tiny forest game portal. Open **๐ŸŽฎ Play** to search for mushrooms,
39
- visit **๐Ÿ“– MycoDex** to review progress, and use **๐Ÿงญ Guide** for the loop.
40
 
41
- **Goal:** solve one mystery: why does Myco remember a forest that vanished before
42
- it was born? Follow clues until the Impossible Mushroom blooms.
43
  """
44
 
45
  GUIDE_MARKDOWN = """
46
  ## How to play
47
 
48
- 1. Go to **๐ŸŽฎ Play**.
49
- 2. Use the controls directly under the forest monitor to move Myco.
50
- 3. Click **Search Clearing** to reveal a mushroom in the current clearing.
51
- 4. Press **Pick** to grab the mushroom like a platformer item โ€” poisonous mushrooms trigger Game Over.
52
- 5. Press **Follow Whisper** to reveal memory fragments. Safe whispers advance the mystery; poison whispers can end the run.
53
- 6. Ask Myco, Study, and Collect safe clues until the Impossible Mushroom reveal appears.
 
 
 
 
 
 
 
 
54
  """
55
 
56
 
57
  def mushroom_card_from_state(current):
58
- """Render a mushroom card from Gradio state."""
59
  if current is None:
60
  return mushroom_card(None)
61
  return mushroom_card(
@@ -67,12 +62,11 @@ def mushroom_card_from_state(current):
67
 
68
 
69
  def search_forest(collection, position):
70
- """Explore the forest and refresh every visible gameplay panel."""
71
  mushroom, current, history = discover_mushroom(collection)
72
- player_position = _safe_position(position)
73
  return (
74
- forest_scene(current, collection, player_position),
75
- game_status_markdown(current, collection, player_position),
76
  mushroom_card_from_state(current),
77
  current,
78
  history,
@@ -82,235 +76,239 @@ def search_forest(collection, position):
82
 
83
 
84
  def ask_companion(message, history, current, collection, position):
85
- """Ask Myco about the active discovery and current journey."""
86
  return myco_reply(message, history, current, collection, position)
87
 
88
 
89
  def collect_discovery(current, collection, history, position):
90
- """Collect the active mushroom and refresh collection-dependent panels."""
91
- updated_collection, updated_history = collect_current(current, collection, history)
92
- player_position = _safe_position(position)
93
  return (
94
- updated_collection,
95
- forest_scene(current, updated_collection, player_position),
96
- game_status_markdown(current, updated_collection, player_position),
97
- dex_markdown(updated_collection),
98
- world_map_markdown(updated_collection),
99
- updated_history,
100
- progress_markdown(updated_collection),
101
  )
102
 
103
 
104
  def pick_discovery(current, collection, history, position):
105
- """Pick the active mushroom as an in-game item with poison risk."""
106
- updated_collection, updated_current, updated_history = pick_current(current, collection, history)
107
- player_position = _safe_position(position)
108
  return (
109
- updated_collection,
110
  updated_current,
111
- forest_scene(updated_current, updated_collection, player_position),
112
- game_status_markdown(updated_current, updated_collection, player_position),
113
  mushroom_card_from_state(updated_current),
114
- dex_markdown(updated_collection),
115
- world_map_markdown(updated_collection),
116
- updated_history,
117
- progress_markdown(updated_collection),
118
  )
119
 
120
 
121
  def follow_story_whisper(current, collection, history, position):
122
- """Follow the active forest whisper and refresh story panels."""
123
- updated_current, updated_history = follow_whisper(current, collection, history)
124
- player_position = _safe_position(position)
125
  return (
126
  updated_current,
127
- forest_scene(updated_current, collection, player_position),
128
- game_status_markdown(updated_current, collection, player_position),
129
  mushroom_card_from_state(updated_current),
130
- updated_history,
131
  )
132
 
133
 
134
  def study_discovery(current, history, collection, position):
135
- """Study the active mushroom and refresh the discovery card."""
136
- updated_current, updated_history = study_current(current, history)
137
- player_position = _safe_position(position)
138
  return (
139
  updated_current,
140
- forest_scene(updated_current, collection, player_position),
141
- game_status_markdown(updated_current, collection, player_position),
142
  mushroom_card_from_state(updated_current),
143
- updated_history,
144
  )
145
 
146
 
147
  def move_player(position, direction, current, collection):
148
- """Move Myco on a tiny 3x3 forest grid and refresh the scene."""
149
- x, y = _safe_position(position)
150
- if direction == "north":
151
- y -= 1
152
- elif direction == "south":
153
- y += 1
154
- elif direction == "west":
155
- x -= 1
156
- elif direction == "east":
157
- x += 1
158
- next_position = _safe_position((x, y))
159
- return (
160
- next_position,
161
- forest_scene(current, collection, next_position),
162
- game_status_markdown(current, collection, next_position),
163
- )
164
-
165
-
166
- def _safe_position(position):
167
- """Return a valid 3x3 player position for Gradio state."""
168
- if position is None:
169
- return START_POSITION
170
- x, y = position
171
- return (max(0, min(2, int(x))), max(0, min(2, int(y))))
172
 
173
 
174
  def block_unsafe_eating(current, history):
175
- """Let Myco prevent unsafe eating while preserving chat state."""
176
  return eat_current(current, history)
177
 
178
 
179
  def open_play_tab():
180
- """Switch from the Home postcard into the playable forest tab."""
181
  return gr.update(selected="play")
182
 
183
 
 
 
 
 
 
 
 
184
  def build_app():
185
- """Build the Gradio interface for Hugging Face Spaces."""
186
- with gr.Blocks(title="Myco") as demo:
 
187
  current_mushroom = gr.State(None)
188
- collection = gr.State([])
189
- player_position = gr.State(START_POSITION)
 
 
190
  gr.HTML(hero_markdown())
191
 
192
  with gr.Tabs(selected="home") as tabs:
 
 
193
  with gr.Tab("๐Ÿ  Home", id="home"):
194
  gr.Markdown(HOME_MARKDOWN)
195
  gr.HTML(home_forest_markdown())
196
- start_play_button = gr.Button("๐Ÿ„ Tap Play โ€” enter the forest", variant="primary")
197
- gr.Markdown(hf_companion_status(), elem_id="ai-status")
 
 
198
 
 
199
  with gr.Tab("๐ŸŽฎ Play", id="play"):
200
  gr.HTML(game_intro_markdown())
201
- gr.HTML(play_hook_markdown())
202
- with gr.Group(elem_id="game-shell"):
203
- scene = gr.HTML(forest_scene(None, EMPTY_COLLECTION, START_POSITION))
204
- with gr.Group(elem_id="near-monitor-controls"):
205
- search_button = gr.Button("๐ŸŽฎ Search Clearing", variant="primary")
 
 
 
 
206
  with gr.Row():
207
- north_button = gr.Button("โฌ†๏ธ")
 
 
208
  with gr.Row():
209
- west_button = gr.Button("โฌ…๏ธ")
210
- pick_button = gr.Button("๐Ÿ„ Pick", variant="primary")
211
- east_button = gr.Button("โžก๏ธ")
212
  with gr.Row():
213
- south_button = gr.Button("โฌ‡๏ธ")
214
- status = gr.Markdown(
215
- game_status_markdown(None, EMPTY_COLLECTION, START_POSITION),
216
- elem_id="quest-log",
217
- )
218
- with gr.Row():
219
- with gr.Column(scale=2):
220
- discovery = gr.Markdown(
221
- mushroom_card(None),
222
- elem_id="discovery-card",
223
- )
224
- with gr.Row():
225
- eat_button = gr.Button("๐Ÿฝ๏ธ Eat?")
226
- whisper_button = gr.Button("๐ŸŒŒ Follow Whisper")
227
- collect_button = gr.Button("๐Ÿ“– Collect")
228
- study_button = gr.Button("๐Ÿ” Study")
229
- with gr.Column(scale=3):
230
- chat = gr.Chatbot(
231
- value=cast(Any, welcome_history()),
232
- label="Myco Chat",
233
- height=360,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  )
235
- with gr.Row():
236
- prompt = gr.Textbox(
237
- label="Ask Myco",
238
- placeholder="Ask Myco what the forest is hiding",
239
- scale=4,
240
- )
241
- ask_button = gr.Button("Ask Myco ๐Ÿ„", scale=1, variant="primary")
242
 
 
243
  with gr.Tab("๐Ÿ“– MycoDex"):
244
  with gr.Row():
245
- progress = gr.Markdown(
246
- progress_markdown(EMPTY_COLLECTION),
247
- elem_id="progress-panel",
248
- )
249
- dex = gr.Markdown(
250
- dex_markdown(EMPTY_COLLECTION),
251
- elem_id="mycodex",
252
- )
253
 
 
254
  with gr.Tab("๐Ÿ—บ๏ธ World Map"):
255
  world_map = gr.HTML(world_map_markdown(EMPTY_COLLECTION))
256
 
 
257
  with gr.Tab("๐Ÿงญ Guide"):
258
  gr.Markdown(GUIDE_MARKDOWN)
259
 
260
- start_play_button.click(open_play_tab, outputs=(tabs,), show_progress="hidden")
 
261
 
262
  search_button.click(
263
  search_forest,
264
- inputs=(collection, player_position),
265
- outputs=(scene, status, discovery, current_mushroom, chat, dex, progress),
266
  )
 
267
  ask_button.click(
268
  ask_companion,
269
- inputs=(prompt, chat, current_mushroom, collection, player_position),
270
- outputs=(prompt, chat),
 
 
 
 
 
271
  )
272
 
273
- for direction, button in (
274
- ("north", north_button),
275
- ("south", south_button),
276
- ("west", west_button),
277
- ("east", east_button),
278
- ):
279
  button.click(
280
  move_player,
281
- inputs=(player_position, gr.State(direction), current_mushroom, collection),
282
- outputs=(player_position, scene, status),
283
  )
284
- prompt.submit(
285
- ask_companion,
286
- inputs=(prompt, chat, current_mushroom, collection, player_position),
287
- outputs=(prompt, chat),
 
288
  )
289
  collect_button.click(
290
  collect_discovery,
291
- inputs=(current_mushroom, collection, chat, player_position),
292
- outputs=(collection, scene, status, dex, world_map, chat, progress),
293
  )
294
  pick_button.click(
295
  pick_discovery,
296
- inputs=(current_mushroom, collection, chat, player_position),
297
- outputs=(collection, current_mushroom, scene, status, discovery, dex, world_map, chat, progress),
298
  )
299
  whisper_button.click(
300
  follow_story_whisper,
301
- inputs=(current_mushroom, collection, chat, player_position),
302
- outputs=(current_mushroom, scene, status, discovery, chat),
303
- )
304
- study_button.click(
305
- study_discovery,
306
- inputs=(current_mushroom, chat, collection, player_position),
307
- outputs=(current_mushroom, scene, status, discovery, chat),
308
  )
309
  eat_button.click(
310
  block_unsafe_eating,
311
- inputs=(current_mushroom, chat),
312
- outputs=(chat,),
313
  )
314
 
315
- demo.queue()
316
  return demo
 
 
1
+ """Gradio game UI for Myco โ€” LLM-powered forest adventure."""
2
 
3
  from typing import Any, cast
 
4
  import gradio as gr
5
 
6
  from game.engine import (
7
+ collect_current, discover_mushroom, eat_current,
8
+ follow_whisper, hf_companion_status, myco_reply,
9
+ pick_current, study_current,
 
 
 
 
 
10
  )
11
  from game.state import welcome_history
12
  from models.mushroom import Mushroom
13
  from ui.renderers import (
14
+ dex_markdown, forest_scene, game_intro_markdown,
15
+ game_status_markdown, hero_markdown, home_forest_markdown,
16
+ mushroom_card, play_hook_markdown, progress_markdown,
 
 
 
 
 
 
17
  world_map_markdown,
18
  )
19
 
20
  EMPTY_COLLECTION = None
21
+ START_POSITION = (1, 1)
22
 
23
  HOME_MARKDOWN = """
24
  ## Welcome to the Myco forest
25
 
26
+ Myco is a tiny AI-powered forest game. Open **๐ŸŽฎ Play** to search for mushrooms,
27
+ visit **๐Ÿ“– MycoDex** to review your collection, and use **๐Ÿงญ Guide** for help.
28
 
29
+ **Goal:** solve one mystery โ€” why does Myco remember a forest that vanished before it was born?
30
+ Follow clues until the Impossible Mushroom blooms inside the MycoDex.
31
  """
32
 
33
  GUIDE_MARKDOWN = """
34
  ## How to play
35
 
36
+ 1. Go to **๐ŸŽฎ Play** and click **๐ŸŽฎ Search Clearing** to discover a mushroom.
37
+ 2. **Myco (the AI) reacts** โ€” read what it senses about the mushroom.
38
+ 3. Choose your action:
39
+ - **๐Ÿ” Study** โ€” Myco examines the mushroom and updates its magic field.
40
+ - **๐Ÿ„ Pick** โ€” grab it as a game item. Poisonous picks = Game Over!
41
+ - **๐Ÿ“– Collect** โ€” add it to the MycoDex for safe keeping and score.
42
+ - **๐ŸŒŒ Follow Whisper** โ€” reveal mystery fragments. Risky on unstudied mushrooms!
43
+ - **๐Ÿฝ๏ธ Eat?** โ€” Myco will stop you every time (for good reason).
44
+ 4. **Ask Myco** anything in the chat โ€” it knows the forest, the mystery, and the mushrooms.
45
+ 5. Use **โฌ†๏ธโฌ‡๏ธโฌ…๏ธโžก๏ธ** to move through the 3ร—3 forest grid.
46
+
47
+ **Scoring:** Common = 10 spores ยท Rare = 35 ยท Legendary = 100 ยท Poison = โˆ’25 + Game Over
48
+
49
+ **Poisonous mushrooms:** Ghost Gill ยท Pepper Pixie ยท Ruby Knuckle ยท Clockwork Chanterelle
50
  """
51
 
52
 
53
  def mushroom_card_from_state(current):
 
54
  if current is None:
55
  return mushroom_card(None)
56
  return mushroom_card(
 
62
 
63
 
64
  def search_forest(collection, position):
 
65
  mushroom, current, history = discover_mushroom(collection)
66
+ pos = _safe_pos(position)
67
  return (
68
+ forest_scene(current, collection, pos),
69
+ game_status_markdown(current, collection, pos),
70
  mushroom_card_from_state(current),
71
  current,
72
  history,
 
76
 
77
 
78
  def ask_companion(message, history, current, collection, position):
 
79
  return myco_reply(message, history, current, collection, position)
80
 
81
 
82
  def collect_discovery(current, collection, history, position):
83
+ updated_coll, updated_hist = collect_current(current, collection, history)
84
+ pos = _safe_pos(position)
 
85
  return (
86
+ updated_coll,
87
+ forest_scene(current, updated_coll, pos),
88
+ game_status_markdown(current, updated_coll, pos),
89
+ dex_markdown(updated_coll),
90
+ world_map_markdown(updated_coll),
91
+ updated_hist,
92
+ progress_markdown(updated_coll),
93
  )
94
 
95
 
96
  def pick_discovery(current, collection, history, position):
97
+ updated_coll, updated_current, updated_hist = pick_current(current, collection, history)
98
+ pos = _safe_pos(position)
 
99
  return (
100
+ updated_coll,
101
  updated_current,
102
+ forest_scene(updated_current, updated_coll, pos),
103
+ game_status_markdown(updated_current, updated_coll, pos),
104
  mushroom_card_from_state(updated_current),
105
+ dex_markdown(updated_coll),
106
+ world_map_markdown(updated_coll),
107
+ updated_hist,
108
+ progress_markdown(updated_coll),
109
  )
110
 
111
 
112
  def follow_story_whisper(current, collection, history, position):
113
+ updated_current, updated_hist = follow_whisper(current, collection, history)
114
+ pos = _safe_pos(position)
 
115
  return (
116
  updated_current,
117
+ forest_scene(updated_current, collection, pos),
118
+ game_status_markdown(updated_current, collection, pos),
119
  mushroom_card_from_state(updated_current),
120
+ updated_hist,
121
  )
122
 
123
 
124
  def study_discovery(current, history, collection, position):
125
+ updated_current, updated_hist = study_current(current, history)
126
+ pos = _safe_pos(position)
 
127
  return (
128
  updated_current,
129
+ forest_scene(updated_current, collection, pos),
130
+ game_status_markdown(updated_current, collection, pos),
131
  mushroom_card_from_state(updated_current),
132
+ updated_hist,
133
  )
134
 
135
 
136
  def move_player(position, direction, current, collection):
137
+ x, y = _safe_pos(position)
138
+ if direction == "north": y -= 1
139
+ elif direction == "south": y += 1
140
+ elif direction == "west": x -= 1
141
+ elif direction == "east": x += 1
142
+ pos = _safe_pos((x, y))
143
+ return pos, forest_scene(current, collection, pos), game_status_markdown(current, collection, pos)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
 
145
 
146
  def block_unsafe_eating(current, history):
 
147
  return eat_current(current, history)
148
 
149
 
150
  def open_play_tab():
 
151
  return gr.update(selected="play")
152
 
153
 
154
+ def _safe_pos(position):
155
+ if position is None:
156
+ return START_POSITION
157
+ x, y = position
158
+ return (max(0, min(2, int(x))), max(0, min(2, int(y))))
159
+
160
+
161
  def build_app():
162
+ with gr.Blocks(title="Myco โ€” AI Forest Game", theme=gr.themes.Soft()) as demo:
163
+
164
+ # โ”€โ”€ State โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
165
  current_mushroom = gr.State(None)
166
+ collection = gr.State([])
167
+ player_position = gr.State(START_POSITION)
168
+
169
+ # โ”€โ”€ Hero โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
170
  gr.HTML(hero_markdown())
171
 
172
  with gr.Tabs(selected="home") as tabs:
173
+
174
+ # โ”€โ”€ HOME โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
175
  with gr.Tab("๐Ÿ  Home", id="home"):
176
  gr.Markdown(HOME_MARKDOWN)
177
  gr.HTML(home_forest_markdown())
178
+ start_play_button = gr.Button(
179
+ "๐Ÿ„ Enter the Forest", variant="primary", size="lg"
180
+ )
181
+ gr.Markdown(f"*{hf_companion_status()}*")
182
 
183
+ # โ”€โ”€ PLAY โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
184
  with gr.Tab("๐ŸŽฎ Play", id="play"):
185
  gr.HTML(game_intro_markdown())
186
+
187
+ # Forest scene + controls
188
+ scene = gr.HTML(forest_scene(None, EMPTY_COLLECTION, START_POSITION))
189
+
190
+ with gr.Row():
191
+ with gr.Column(scale=1):
192
+ search_button = gr.Button("๐ŸŽฎ Search Clearing", variant="primary", size="lg")
193
+ with gr.Column(scale=1):
194
+ gr.Markdown("**Move Myco**")
195
  with gr.Row():
196
+ gr.HTML("<div></div>")
197
+ north_button = gr.Button("โฌ†๏ธ", size="sm")
198
+ gr.HTML("<div></div>")
199
  with gr.Row():
200
+ west_button = gr.Button("โฌ…๏ธ", size="sm")
201
+ pick_button = gr.Button("๐Ÿ„ Pick", variant="primary", size="sm")
202
+ east_button = gr.Button("โžก๏ธ", size="sm")
203
  with gr.Row():
204
+ gr.HTML("<div></div>")
205
+ south_button = gr.Button("โฌ‡๏ธ", size="sm")
206
+ gr.HTML("<div></div>")
207
+
208
+ # Quest log
209
+ status = gr.Markdown(
210
+ game_status_markdown(None, EMPTY_COLLECTION, START_POSITION)
211
+ )
212
+
213
+ # Discovery card + action buttons + chat
214
+ with gr.Row(equal_height=True):
215
+ with gr.Column(scale=2):
216
+ gr.Markdown("### ๐Ÿ„ Current Discovery")
217
+ discovery = gr.Markdown(mushroom_card(None))
218
+ with gr.Row():
219
+ study_button = gr.Button("๐Ÿ” Study", variant="secondary")
220
+ collect_button = gr.Button("๐Ÿ“– Collect", variant="secondary")
221
+ with gr.Row():
222
+ whisper_button = gr.Button("๐ŸŒŒ Follow Whisper", variant="secondary")
223
+ eat_button = gr.Button("๐Ÿฝ๏ธ Eat?", variant="stop")
224
+
225
+ with gr.Column(scale=3):
226
+ gr.Markdown("### ๐Ÿ’ฌ Myco Chat")
227
+ chat = gr.Chatbot(
228
+ value=cast(Any, welcome_history()),
229
+ label="Myco",
230
+ height=400,
231
+ show_label=False,
232
+ )
233
+ with gr.Row():
234
+ prompt = gr.Textbox(
235
+ placeholder="Ask Myco anything about the forest...",
236
+ show_label=False,
237
+ scale=4,
238
+ lines=1,
239
  )
240
+ ask_button = gr.Button("Ask ๐Ÿ„", variant="primary", scale=1)
 
 
 
 
 
 
241
 
242
+ # โ”€โ”€ MYCODEX โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
243
  with gr.Tab("๐Ÿ“– MycoDex"):
244
  with gr.Row():
245
+ progress = gr.Markdown(progress_markdown(EMPTY_COLLECTION))
246
+ dex = gr.Markdown(dex_markdown(EMPTY_COLLECTION))
 
 
 
 
 
 
247
 
248
+ # โ”€โ”€ WORLD MAP โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
249
  with gr.Tab("๐Ÿ—บ๏ธ World Map"):
250
  world_map = gr.HTML(world_map_markdown(EMPTY_COLLECTION))
251
 
252
+ # โ”€โ”€ GUIDE โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
253
  with gr.Tab("๐Ÿงญ Guide"):
254
  gr.Markdown(GUIDE_MARKDOWN)
255
 
256
+ # โ”€โ”€ Event wiring โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
257
+ start_play_button.click(open_play_tab, outputs=[tabs])
258
 
259
  search_button.click(
260
  search_forest,
261
+ inputs=[collection, player_position],
262
+ outputs=[scene, status, discovery, current_mushroom, chat, dex, progress],
263
  )
264
+
265
  ask_button.click(
266
  ask_companion,
267
+ inputs=[prompt, chat, current_mushroom, collection, player_position],
268
+ outputs=[prompt, chat],
269
+ )
270
+ prompt.submit(
271
+ ask_companion,
272
+ inputs=[prompt, chat, current_mushroom, collection, player_position],
273
+ outputs=[prompt, chat],
274
  )
275
 
276
+ for direction, button in [
277
+ ("north", north_button), ("south", south_button),
278
+ ("west", west_button), ("east", east_button),
279
+ ]:
 
 
280
  button.click(
281
  move_player,
282
+ inputs=[player_position, gr.State(direction), current_mushroom, collection],
283
+ outputs=[player_position, scene, status],
284
  )
285
+
286
+ study_button.click(
287
+ study_discovery,
288
+ inputs=[current_mushroom, chat, collection, player_position],
289
+ outputs=[current_mushroom, scene, status, discovery, chat],
290
  )
291
  collect_button.click(
292
  collect_discovery,
293
+ inputs=[current_mushroom, collection, chat, player_position],
294
+ outputs=[collection, scene, status, dex, world_map, chat, progress],
295
  )
296
  pick_button.click(
297
  pick_discovery,
298
+ inputs=[current_mushroom, collection, chat, player_position],
299
+ outputs=[collection, current_mushroom, scene, status, discovery, dex, world_map, chat, progress],
300
  )
301
  whisper_button.click(
302
  follow_story_whisper,
303
+ inputs=[current_mushroom, collection, chat, player_position],
304
+ outputs=[current_mushroom, scene, status, discovery, chat],
 
 
 
 
 
305
  )
306
  eat_button.click(
307
  block_unsafe_eating,
308
+ inputs=[current_mushroom, chat],
309
+ outputs=[chat],
310
  )
311
 
312
+ demo.queue()
313
  return demo
314
+