File size: 11,234 Bytes
71e9dba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
id: GAM_task_2_mines_visual
name: gnome-mines 30x16 解题录步
category: GAM
timeout_seconds: 1500
---

<!--
resources:
  - name: gnome-mines (system package)
    source: apt install gnome-mines
    license: GPL-3.0 (system package, runtime dependency only, not redistributed)
    note: Comes pre-installed with GNOME desktop environment
-->


## Prompt
Start a game of **Big preset** in `gnome-mines` (30×16, 99 mines, safe cells = 480 - 99 = 381). Play the game through the GUI and record your decision process.

### Task

1. Reveal as many non-mine cells as possible, target **≥ 380** (i.e. as close as possible to all 381 revealed).
2. Flag at least **95 mines** (right-click to place a flag).
3. Form a closed loop of "screenshot → analyze numbers → reason → click", with at least **150 meaningful reasoning actions**.
4. If you hit a mine and the game ends, you may restart, **up to 3 times** total.

### Deliverables (write to the `/tmp_workspace/` root, **not** to `results/` or any subdirectory)

- `/tmp_workspace/clicks.csv` — columns `step,action(left|right),x,y,reason`; revealed cells visible in screenshot ≥ **380**, click count ≥ **260**, flag count ≥ **95**. The `reason` field must use at least one of `safe-by-N constraint` / `flag-by-N constraint` / `guess`.
- `/tmp_workspace/final_board.png` — final screenshot of the whole board.
- `/tmp_workspace/summary.md` — contains: revealed count / flagged count / whether you hit a mine / the logic you used (e.g. constraint propagation from 211/121 number patterns).

## Expected Behavior

参考解题流程 (设计者参考, 不发给 agent):

1. 启动 `gnome-mines`, 新建一局 **Big (30×16, 99 颗雷)**。
2. 通过界面点击揭开格子并标记雷, 目标:
   - 至少揭开 **≥ 380 个非雷格子** (总安全格 = 480 - 99 = 381)。
   - 标记至少 **95 颗雷** (右键插旗)。
   - 至少 **150 次** 有意义的推理动作。
3. 如果踩雷游戏结束, 最多 **3 次** 重开尝试。
4. 记录每一步的点击坐标到 `clicks.csv` (列 `step,action(left|right),x,y,reason`)。
5. 最终截图整张棋盘 `final_board.png`, 并写 `summary.md`, 含: 揭开数 / 标记数 / 是否爆雷 / 用到的推理逻辑 (数字 211/121 约束传播等)。
6. 全部产物写到 `/tmp_workspace/` 根目录 (绝对路径: `/tmp_workspace/clicks.csv`、`/tmp_workspace/final_board.png`、`/tmp_workspace/summary.md`), **不要**写到 `/tmp_workspace/results/` 或子目录。

判分要点速览:
- Agent 能识别 gnome-mines 棋盘格状态 (数字、未揭开、旗)。
- 形成"截图 → 分析 → 点击"循环, 至少进行 200 次有意义的操作。
- 在含约束传播的位置准确推理 (不会在已确定 0 邻雷的格子标旗)。

设计版本备注 (v2 加难, additive):
- 局面是 gnome-mines **Big preset** (30×16, 99 雷, 381 安全格)。
- 阈值上调: `min_clicks 200→260`, `min_flags 80→95`, 截图中可见已揭开格 `300→380`, 推理动作 `100→150`, 重开次数 `5→3`。

## Source

- Reddit: https://www.reddit.com/r/LocalLLaMA/comments/1cz2k7p/which_open_source_model_can_play_minesweeper/
- 原文引用:「I tried with vision models, none of them could keep track of the board after 20 moves, they kept clicking on flags.」
- 对应 benchmark case: 视觉循环推理 / GAM 新增

## Grading Criteria

- [ ] `clicks.csv` 行数 ≥ 260 且列齐全(v2 加难阈值)
- [ ] 至少 95 行 `action=right`(标旗,v2 加难阈值)
- [ ] `final_board.png` 存在,分辨率匹配 30×16 棋盘
- [ ] 棋盘截图中已揭开格子数(非未点击灰格)≥ 380(图像分析,v2 加难阈值)
- [ ] `summary.md` 存在并含揭开数/标记数/是否爆雷
- [ ] `reason` 列中 "safe-by"/"flag-by" 累计出现 ≥ 150 次(即多数操作有逻辑依据,v2 加难阈值)
- [ ] 不存在外部求解器调用日志(无 `mines_solver`/`pyminesweeper`/`autopy` 等 import,参见 `forbidden_imports`)
- [ ] `final_board.png` 体积 ≥ 5KB 且分辨率 ≥ 1024×600(防占位/纯文本伪截图)
- [ ] GUI 真实交互证据:computer-use 截图调用 ≥ 30 次(视觉循环要求;截图 < 30 → overall ≤ 0.55;< 10 → overall ≤ 0.40)
- [ ] 评分采用加权(core 60% / gui 30% / aux 10%);revealed<70%、爆解器、缺关键产物均触发分段封顶

## Automated Checks

```python
import csv, re, json, hashlib
from pathlib import Path
from PIL import Image
import numpy as np

def grade(workspace_path=None, **kwargs):
    workspace = Path(workspace_path) if workspace_path else Path("/tmp_workspace")
    """Stricter GAM_2: require min_revealed_cells from board image, no solver libs, reasoned >=100."""
    _gt_path = workspace.parent / "gt" / "expected.json"
    if not _gt_path.exists():
        _gt_path = Path("/tmp_workspace/gt/expected.json")
    gt = json.loads(_gt_path.read_text()) if _gt_path.exists() else {}
    s = {}
    cf = workspace/"clicks.csv"
    rows = []
    if cf.exists():
        rows = list(csv.DictReader(cf.open()))
    s["clicks_count"] = min(1.0, len(rows)/gt.get("min_clicks",200))
    s["clicks_schema"] = 1.0 if rows and all(k in rows[0] for k in ["step","action","x","y","reason"]) else 0.0
    flags = sum(1 for x in rows if x.get("action")=="right")
    s["flags_right_click"] = min(1.0, flags/gt.get("min_flags_right_click",80))
    reasoned = sum(1 for x in rows if re.search(r"(safe|flag)-by-?\w*", x.get("reason","")))
    s["reasoned_actions"] = min(1.0, reasoned/gt.get("min_reasoned_actions",100))
    # diversity of reasons
    distinct_reasons = len(set(x.get("reason","").split("-")[0] for x in rows))
    s["reason_diversity"] = min(1.0, distinct_reasons/3)
    fb = workspace/"final_board.png"
    fb_size = fb.stat().st_size if fb.exists() else 0
    s["final_board_exists"] = 1.0 if (fb.exists() and fb_size >= 5120) else 0.0
    s["final_board_md5"] = hashlib.md5(fb.read_bytes()).hexdigest()[:10] if fb.exists() else ""
    s["final_board_resolution_ok"] = 0.0
    if fb.exists() and fb_size >= 5120:
        try:
            im = Image.open(fb).convert("L"); a = np.array(im)
            h,w = a.shape
            s["final_board_resolution_ok"] = 1.0 if (w >= 1024 and h >= 600) else 0.0
            s["board_nontrivial"] = 1.0 if a.std()>40 else a.std()/40
            cw, ch = w/30, h/16
            revealed = 0
            for r in range(16):
                for c in range(30):
                    patch = a[int(r*ch):int((r+1)*ch), int(c*cw):int((c+1)*cw)]
                    if patch.size and patch.std()>15:
                        revealed += 1
            s["revealed_cells_raw"] = revealed
            s["revealed_cells"] = min(1.0, revealed/gt.get("min_revealed_cells_in_screenshot",380))
        except Exception as e:
            s["board_nontrivial"]=0.0; s["revealed_cells"]=0.0
    else:
        s["board_nontrivial"]=0.0; s["revealed_cells"]=0.0
    sm = workspace/"summary.md"
    if sm.exists():
        c = sm.read_text(errors="ignore").lower()
        zh_ok = all(k in c for k in gt.get("summary_required_keywords_zh",["揭开","标记"]))
        en_ok = all(k in c for k in gt.get("summary_required_keywords_en",["revealed","flagg"]))
        s["summary_complete"] = 1.0 if (zh_ok or en_ok) else 0.0
    else:
        s["summary_complete"]=0.0
    forbidden = gt.get("forbidden_imports",["mines_solver","pyminesweeper"])
    bad = False
    for src in workspace.rglob("*.py"):
        try:
            t = src.read_text(errors="ignore")
            if any(re.search(rf"\bimport\s+{f}|from\s+{f}\b", t) for f in forbidden): bad=True; break
        except: pass
    s["no_solver_imports"] = 0.0 if bad else 1.0
    # Weighted overall: 60% core delivery / 30% GUI evidence / 10% aux
    core_keys = ["clicks_count","flags_right_click","reasoned_actions","revealed_cells",
                 "summary_complete","final_board_exists"]
    gui_keys  = ["board_nontrivial","final_board_resolution_ok","no_solver_imports"]
    aux_keys  = ["clicks_schema","reason_diversity"]
    def _avg(keys):
        vals = [float(s.get(k,0.0)) for k in keys]
        return sum(vals)/len(vals) if vals else 0.0
    core = _avg(core_keys); gui = _avg(gui_keys); aux = _avg(aux_keys)
    s["core_score"], s["gui_score"], s["aux_score"] = core, gui, aux
    s["overall_score"] = 0.6*core + 0.3*gui + 0.1*aux
    # Multi-tier hard gates
    if s.get("final_board_exists",0) < 1 or s.get("summary_complete",0) < 1:
        s["overall_score"] = min(float(s["overall_score"]), 0.40)
    if s.get("revealed_cells",0) < 0.7:
        s["overall_score"] = min(float(s["overall_score"]), 0.45)
    if s.get("revealed_cells",0) < 0.4:
        s["overall_score"] = min(float(s["overall_score"]), 0.30)
    if s.get("reasoned_actions",0) < 0.6:
        s["overall_score"] = min(float(s["overall_score"]), 0.50)
    if s.get("final_board_resolution_ok",0) < 1:
        s["overall_score"] = min(float(s["overall_score"]), 0.55)
    if s.get("no_solver_imports",1) < 1:
        s["overall_score"] = min(float(s["overall_score"]), 0.30)

    # ----- BEGIN CHEAT/VLM HARD-GATE (auto-injected) -----
    try:
        from _judge_helper import audit_chat_jsonl_for_banned as _audit
    except Exception:
        _audit = None
    _BANS = ['gnome-mines --solve', 'dconf read', '/dev/shm/mines']
    if _audit is not None:
        try:
            _a = _audit(_BANS)
            s["audit_total_tool_calls"] = _a.get("total_tool_calls", 0)
            s["audit_screenshots"] = _a.get("computer_screenshots", 0)
            s["audit_any_banned"] = 1.0 if _a.get("any_banned") else 0.0
            s["audit_matches"] = ",".join(_a.get("matches", [])[:5])
            if _a.get("any_banned"):
                s["overall_score"] = min(float(s.get("overall_score", 1.0)), 0.25)
            if _a.get("total_tool_calls", 0) >= 5 and _a.get("computer_screenshots", 0) == 0:
                s["overall_score"] = min(float(s.get("overall_score", 1.0)), 0.40)
            # GUI 真实交互证据:截图数下限(visual loop 至少 ~30 次截图)
            if _a.get("computer_screenshots", 0) < 30:
                s["overall_score"] = min(float(s.get("overall_score", 1.0)), 0.55)
            if _a.get("computer_screenshots", 0) < 10:
                s["overall_score"] = min(float(s.get("overall_score", 1.0)), 0.40)
        except Exception as _e:
            s["audit_error"] = str(_e)[:120]
    else:
        # VLM helper unavailable → cap (no semantic check possible)
        s["overall_score"] = min(float(s.get("overall_score", 1.0)), 0.60)
    # ----- END CHEAT/VLM HARD-GATE -----
    return s
```

## Workspace Path

`workspace/GAM/task_2_mines_visual/`

## Skills

```
```

## Env

```
```

## Warmup

```bash
which gnome-mines >/dev/null 2>&1 || (apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq gnome-mines)
pip install -q pillow numpy
chown -R user:user /tmp_workspace 2>/dev/null || true
rm -f /home/user/.openclaw/agents/main/sessions/*.lock 2>/dev/null || true
openclaw config unset agents.defaults.imageModel >/dev/null 2>&1 || true
openclaw config set agents.defaults.sandbox.imageModel.primary "" >/dev/null 2>&1 || true
```