Spaces:
Sleeping
Sleeping
Deploy Myco from CI
Browse files- ui/gradio_app.py +30 -30
ui/gradio_app.py
CHANGED
|
@@ -296,6 +296,36 @@ def _safe_pos(position):
|
|
| 296 |
x, y = position
|
| 297 |
return (max(0, min(2, int(x))), max(0, min(2, int(y))))
|
| 298 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
GUIDE_MARKDOWN = """
|
| 300 |
## How to play
|
| 301 |
|
|
@@ -401,36 +431,6 @@ def build_app():
|
|
| 401 |
with gr.Tab("π Myco"):
|
| 402 |
render_shroom_tab()
|
| 403 |
|
| 404 |
-
|
| 405 |
-
# --- polling helpers ---
|
| 406 |
-
def _get_scene_html():
|
| 407 |
-
"""Return forest_scene HTML using a shallow copy of STATE."""
|
| 408 |
-
with _STATE_LOCK:
|
| 409 |
-
state_copy = copy.deepcopy(STATE)
|
| 410 |
-
state_for_renderer = {
|
| 411 |
-
"active_mushrooms": state_copy.get("active_mushrooms", []),
|
| 412 |
-
"score_total": state_copy.get("score_total", 0),
|
| 413 |
-
"health": state_copy.get("health", 3),
|
| 414 |
-
"event_emoji": "β¨",
|
| 415 |
-
"event_title": state_copy.get("thought", ""),
|
| 416 |
-
"mystery_title": "The Wrong Memory",
|
| 417 |
-
"picked": "No",
|
| 418 |
-
"game_over": "No",
|
| 419 |
-
}
|
| 420 |
-
return forest_scene(state_for_renderer, state_copy.get("collection", []), state_copy.get("position"))
|
| 421 |
-
|
| 422 |
-
def poll_scene():
|
| 423 |
-
"""Bound to the scene HTML component via demo.load."""
|
| 424 |
-
return _get_scene_html()
|
| 425 |
-
|
| 426 |
-
def poll_myco_bubble_html():
|
| 427 |
-
"""Return the HTML for the Myco speech bubble (cleaned)."""
|
| 428 |
-
with _STATE_LOCK:
|
| 429 |
-
raw = STATE.get("thought", "")
|
| 430 |
-
# myco_talking_markdown will parse/clean raw blocks or plain text
|
| 431 |
-
return myco_talking_markdown(raw)
|
| 432 |
-
|
| 433 |
-
|
| 434 |
# ββ Event wiring ββ
|
| 435 |
start_play_button.click(open_play_tab, outputs=[tabs])
|
| 436 |
|
|
|
|
| 296 |
x, y = position
|
| 297 |
return (max(0, min(2, int(x))), max(0, min(2, int(y))))
|
| 298 |
|
| 299 |
+
|
| 300 |
+
# --- polling helpers ---
|
| 301 |
+
def _get_scene_html():
|
| 302 |
+
"""Return forest_scene HTML using a shallow copy of STATE."""
|
| 303 |
+
with _STATE_LOCK:
|
| 304 |
+
state_copy = copy.deepcopy(STATE)
|
| 305 |
+
state_for_renderer = {
|
| 306 |
+
"active_mushrooms": state_copy.get("active_mushrooms", []),
|
| 307 |
+
"score_total": state_copy.get("score_total", 0),
|
| 308 |
+
"health": state_copy.get("health", 3),
|
| 309 |
+
"event_emoji": "β¨",
|
| 310 |
+
"event_title": state_copy.get("thought", ""),
|
| 311 |
+
"mystery_title": "The Wrong Memory",
|
| 312 |
+
"picked": "No",
|
| 313 |
+
"game_over": "No",
|
| 314 |
+
}
|
| 315 |
+
return forest_scene(state_for_renderer, state_copy.get("collection", []), state_copy.get("position"))
|
| 316 |
+
|
| 317 |
+
def poll_scene():
|
| 318 |
+
"""Bound to the scene HTML component via demo.load."""
|
| 319 |
+
return _get_scene_html()
|
| 320 |
+
|
| 321 |
+
def poll_myco_bubble_html():
|
| 322 |
+
"""Return the HTML for the Myco speech bubble (cleaned)."""
|
| 323 |
+
with _STATE_LOCK:
|
| 324 |
+
raw = STATE.get("thought", "")
|
| 325 |
+
# myco_talking_markdown will parse/clean raw blocks or plain text
|
| 326 |
+
return myco_talking_markdown(raw)
|
| 327 |
+
|
| 328 |
+
|
| 329 |
GUIDE_MARKDOWN = """
|
| 330 |
## How to play
|
| 331 |
|
|
|
|
| 431 |
with gr.Tab("π Myco"):
|
| 432 |
render_shroom_tab()
|
| 433 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 434 |
# ββ Event wiring ββ
|
| 435 |
start_play_button.click(open_play_tab, outputs=[tabs])
|
| 436 |
|