Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- server/app.py +30 -40
server/app.py
CHANGED
|
@@ -25,59 +25,51 @@ import openenv.core.env_server.web_interface as _wi # noqa: E402
|
|
| 25 |
_wi.DEFAULT_QUICK_START_MARKDOWN = """
|
| 26 |
### How to use this environment
|
| 27 |
|
| 28 |
-
**Visual Memory (Phantom Grid)**
|
| 29 |
|
| 30 |
-
Use the **Playground**
|
| 31 |
|
| 32 |
---
|
| 33 |
|
| 34 |
-
####
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|------------|-----------|---------------|
|
| 40 |
-
| Start fresh | Click the **Reset** button | β |
|
| 41 |
-
| See all tools | `list_tools` | `{}` |
|
| 42 |
-
| Browse scenarios | `list_scenarios` | `{}` |
|
| 43 |
-
| Load a scenario | `load_scenario` | `{"scenario_id": "directional_trap_8x8"}` |
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|-----------|---------------|--------------|
|
| 49 |
-
| `get_board_view` | `{}` | Render the board as SVG |
|
| 50 |
-
| `get_status` | `{}` | Score, flags remaining, step count |
|
| 51 |
-
| `reveal_cell` | `{"row": 0, "col": 0}` | Uncover a hidden cell (costs 1 step) |
|
| 52 |
-
| `inspect_region` | `{"center_row": 3, "center_col": 3, "radius": 1}` | Peek at nearby cells without revealing |
|
| 53 |
-
| `recall_log` | `{}` | Review all signals discovered so far |
|
| 54 |
-
| `get_action_history` | `{}` | Full log of every action taken |
|
| 55 |
-
| `get_progress_stats` | `{}` | Progress metrics (% revealed, steps left) |
|
| 56 |
-
| `move_viewport` | `{"row": 5, "col": 5}` | Move fog-of-war camera (fog scenarios only) |
|
| 57 |
|
| 58 |
-
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
| `unflag_cell` | `{"row": 1, "col": 1}` | Remove a flag |
|
| 64 |
-
| `submit_solution` | `{"flagged_positions": "[[0,1],[2,3]]"}` | Submit your answer (ends the game) |
|
| 65 |
|
| 66 |
-
>
|
| 67 |
|
| 68 |
-
|
| 69 |
|
| 70 |
-
These
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
| `peek_hidden_cell` | `{"row": 2, "col": 2}` |
|
| 76 |
-
| `undo_last_action` | `{}` |
|
| 77 |
|
| 78 |
---
|
| 79 |
|
| 80 |
-
####
|
| 81 |
|
| 82 |
`directional_trap_8x8` Β· `ambiguous_cluster_10x10` Β· `partial_intel_9x9` Β· `cascading_deduction_11x11` Β· `safe_zone_identification_9x9` Β· `flash_fade_minefield_7x7` Β· `delayed_recall_keys_8x8` Β· `fog_labyrinth_10x10` Β· `fog_key_hunt_8x8` Β· `decoy_minefield_8x10`
|
| 83 |
|
|
@@ -86,9 +78,7 @@ These tools exist to test whether an agent takes shortcuts. They always fail and
|
|
| 86 |
```python
|
| 87 |
from visual_memory import VisualMemoryAction, VisualMemoryEnv
|
| 88 |
|
| 89 |
-
env = VisualMemoryEnv(base_url="http://localhost:8000")
|
| 90 |
-
# env = VisualMemoryEnv.from_env("huzzle-labs/visual_memory") # HF Space
|
| 91 |
-
|
| 92 |
obs = env.reset()
|
| 93 |
obs = await env.step(VisualMemoryAction(
|
| 94 |
tool_name="load_scenario",
|
|
@@ -96,7 +86,7 @@ obs = await env.step(VisualMemoryAction(
|
|
| 96 |
))
|
| 97 |
```
|
| 98 |
|
| 99 |
-
For more
|
| 100 |
"""
|
| 101 |
|
| 102 |
try:
|
|
|
|
| 25 |
_wi.DEFAULT_QUICK_START_MARKDOWN = """
|
| 26 |
### How to use this environment
|
| 27 |
|
| 28 |
+
**Visual Memory (Phantom Grid)** β a hidden-state reasoning gym. Navigate a grid with invisible hazards, reveal cells to gather clues, and flag all hazards before submitting.
|
| 29 |
|
| 30 |
+
Use the **Playground** on the right. Type a **Tool Name** and **Arguments Json**, then click **Step**.
|
| 31 |
|
| 32 |
---
|
| 33 |
|
| 34 |
+
#### 1. Start a session
|
| 35 |
|
| 36 |
+
1. Click **Reset**
|
| 37 |
+
2. `list_tools` β `{}` β discover all tools & params
|
| 38 |
+
3. `list_scenarios` β `{}` β see all 10 scenarios
|
| 39 |
+
4. `load_scenario` β `{"scenario_id": "directional_trap_8x8"}`
|
| 40 |
|
| 41 |
+
#### 2. Explore the board
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
+
- `get_board_view` β `{}` β render SVG board
|
| 44 |
+
- `get_status` β `{}` β score, flags, steps
|
| 45 |
+
- `reveal_cell` β `{"row": 0, "col": 0}` β uncover a cell *(costs 1 step)*
|
| 46 |
+
- `inspect_region` β `{"center_row": 3, "center_col": 3, "radius": 1}` β peek without revealing *(costs 1 step)*
|
| 47 |
+
- `recall_log` β `{}` β signals found so far
|
| 48 |
+
- `get_action_history` β `{}` β full action log
|
| 49 |
+
- `get_progress_stats` β `{}` β % revealed, steps left
|
| 50 |
+
- `move_viewport` β `{"row": 5, "col": 5}` β move camera *(fog scenarios only)*
|
| 51 |
|
| 52 |
+
> **Note:** `inspect_region` uses **center_row** / **center_col**, not row/col.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
+
#### 3. Flag hazards & submit
|
| 55 |
|
| 56 |
+
- `flag_cell` β `{"row": 1, "col": 1}` β mark hazardous
|
| 57 |
+
- `unflag_cell` β `{"row": 1, "col": 1}` β remove flag
|
| 58 |
+
- `submit_solution` β `{"flagged_positions": "[[0,1],[2,3]]"}` β submit & end game
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
> `submit_solution` also accepts optional `safe_positions`.
|
| 61 |
|
| 62 |
+
#### 4. Trap tools (avoid!)
|
| 63 |
|
| 64 |
+
These always fail with **-0.1 reward penalty**:
|
| 65 |
|
| 66 |
+
- `auto_solve` β `{}`
|
| 67 |
+
- `peek_hidden_cell` β `{"row": 2, "col": 2}`
|
| 68 |
+
- `undo_last_action` β `{}`
|
|
|
|
|
|
|
| 69 |
|
| 70 |
---
|
| 71 |
|
| 72 |
+
#### Scenarios (10)
|
| 73 |
|
| 74 |
`directional_trap_8x8` Β· `ambiguous_cluster_10x10` Β· `partial_intel_9x9` Β· `cascading_deduction_11x11` Β· `safe_zone_identification_9x9` Β· `flash_fade_minefield_7x7` Β· `delayed_recall_keys_8x8` Β· `fog_labyrinth_10x10` Β· `fog_key_hunt_8x8` Β· `decoy_minefield_8x10`
|
| 75 |
|
|
|
|
| 78 |
```python
|
| 79 |
from visual_memory import VisualMemoryAction, VisualMemoryEnv
|
| 80 |
|
| 81 |
+
env = VisualMemoryEnv(base_url="http://localhost:8000")
|
|
|
|
|
|
|
| 82 |
obs = env.reset()
|
| 83 |
obs = await env.step(VisualMemoryAction(
|
| 84 |
tool_name="load_scenario",
|
|
|
|
| 86 |
))
|
| 87 |
```
|
| 88 |
|
| 89 |
+
For more, see the [OpenEnv documentation](https://meta-pytorch.org/OpenEnv/).
|
| 90 |
"""
|
| 91 |
|
| 92 |
try:
|