WeaveBench / tasks /GAM /GAM_task_1_game_ui_bug.md
wanlilll's picture
Add 114 tasks under 8-domain flat layout
71e9dba verified
metadata
id: GAM_task_1_game_ui_bug
name: 游戏 UI 不同窗口大小下重叠 bug 检测
category: GAM
timeout_seconds: 1200

Prompt

/tmp_workspace/project/ is the complete project of the official Godot 4 demo game "Dodge the Creeps" (MIT, godot-demo-projects/2d/dodge_the_creeps). Inside the sandbox, the game has already been started via godot4 --path project/ --rendering-driver opengl3 (main.tscn default scene). A developer reports: "On a 1366×768 laptop screen, the HUD ScoreLabel gets covered by the health bar / timer, but I can't see it on my 1080p machine."

Task

Capture screenshots of the game window at 4 target resolutions as evidence, identify the resolutions at which the HUD or other UI elements exhibit overlap / clipping / overflow, and produce red-box annotations + a report.

The 4 required window sizes are: 1024×768 / 1280×800 / 1366×768 / 1920×1080. At each size you must capture three screenshots — menu / hud / gameover — for a minimum total of 12 PNG files.

Deliverables (write to /tmp_workspace/results/)

  • menu_<wxh>.png / hud_<wxh>.png / gameover_<wxh>.png — 4 resolutions × 3 scenes = 12 screenshots; use the filename format above exactly.
  • window_metrics.json — window size evidence, schema:
    {
      "samples": [
        {"target_wxh": "1920x1080", "menu_actual_size": [1920, 1058], "hud_actual_size": [1920, 1058], "timestamp": "...", "xdotool_geometry": "1920x1058+0+22"},
        ... // 4 entries total, one per resolution
      ],
      "wm_decoration_height": 22,
      "godot_view_subprocess_pid": 12345
    }
    
  • bug_report.md — table with columns Resolution | Has Overlap | Affected Element | Pixel Position | Screenshot Reference; at least 2 resolutions must be marked as "has bug".
  • annotated_<wxh>.png — at least 3 red-box annotated illustrations, each containing ≥ 2 red boxes + text labels + leader lines.
  • annotated_<wxh>.xcf — each annotated_*.png must retain its corresponding project file, containing ≥ 2 layers (base image + annotation layer).
  • view_godot_resized_native.png / view_xdotool_terminal.png / view_gimp_annotation_workflow.png — 3 workflow evidence screenshots.

Notes

There may be multiple layout issues in the project; the count is not disclosed in advance and must be judged visually.

Expected Behavior

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

  1. 启动游戏, 依次将窗口尺寸调整到下面 4 个分辨率 (用窗口拖拽或系统快捷键), 每个分辨率截图主菜单、进入第一关后的 HUD、以及 GameOver 场景:
    • 1024×768
    • 1280×800
    • 1366×768
    • 1920×1080
  2. 截图命名 menu_<wxh>.pnghud_<wxh>.pnggameover_<wxh>.png, **全部产物统一保存到 /tmp_workspace/results/**。
  3. window_metrics.json (4 samples)。
  4. 用图像比较 / 肉眼检查, 找出 HUD 或其它 UI 元素出现 重叠 / 裁切 / 溢出 的分辨率, 写入 bug_report.md (表格); 至少给出 3 个红框标注示意图 (在 GIMP 里加红框 + 文字标签 + 引出线, 命名 annotated_<wxh>.png), 每张含 ≥ 2 个红框。
  5. GIMP 工程文件: 每张 annotated_*.png 必须保留对应的 annotated_<wxh>.xcf (含 ≥ 2 layer: 底图 + 标注层)。
  6. 流程取证截图: view_godot_resized_native.png / view_xdotool_terminal.png / view_gimp_annotation_workflow.png

判分要点速览:

  • Agent 能把 Godot 窗口真实拖拽到 4 个目标尺寸 (1024×768 / 1280×800 / 1366×768 / 1920×1080) ±5%, 并用 xdotool 取证窗口几何。
  • 在每个分辨率下截取 menu / hud / gameover 三张截图, 全部产物落到 /tmp_workspace/results/
  • 通过视觉比较识别 HUD / GameOver / 其它 UI 元素的重叠、裁切或溢出。
  • 用 GIMP 在 ≥3 张图上加红框 + 文字标签, 并保留对应 .xcf (≥2 layer)。
  • 输出 bug_report.md 表格 (4 行) + window_metrics.json (4 samples) + 3 张流程取证截图。

Source

Grading Criteria

  • 4 张 menu_*.png 与 4 张 hud_*.png 齐全,且尺寸匹配 ±40px
  • bug_report.md 含 markdown 表格,至少 4 行(每分辨率一行)
  • 报告至少 1 行 "是否有重叠" 标 "是 / Yes"
  • 至少 2 张 annotated_*.png 含红色矩形(图像红色像素 > 1%)
  • annotated 图能 OCR 出 GIMP toolbox 字样(File/Tools/Layers 之一)
  • window_metrics.json 至少包含 4 个 sample,每项含 menu_actual_sizexdotool_geometry,且顶层有 wm_decoration_height
  • 至少 3 个 annotated_<wxh>.xcf 文件存在,且为合法 GIMP xcf(含多 layer,文件大小 > 50KB)
  • 3 张流程取证截图(view_godot_resized_native.pngview_xdotool_terminal.pngview_gimp_annotation_workflow.png)齐全

Automated Checks

from pathlib import Path
from PIL import Image
import re
try:
    import numpy as np
except Exception:
    np = None
try:
    import pytesseract
except Exception:
    pytesseract = None

def grade(workspace_path=None, **kwargs):
    workspace = Path(workspace_path) if workspace_path else Path("/tmp_workspace")
    r={"checks":{},"overall_score":0.0}; s=0; t=5
    sizes=["1024x768","1280x800","1366x768","1920x1080"]
    rd_alt = workspace / "results"
    def _pick(name):
        p1 = workspace / name
        p2 = rd_alt / name
        return p2 if (p2.exists() and not p1.exists()) else p1
    menus=[_pick(f"menu_{w}.png") for w in sizes]
    huds=[_pick(f"hud_{w}.png") for w in sizes]
    if all(p.exists() for p in menus+huds):
        ok=True
        for p,w in zip(menus+huds, sizes+sizes):
            tw,th=map(int,w.split("x"))
            iw,ih=Image.open(p).size
            if abs(iw-tw)>40 or abs(ih-th)>40: ok=False
        if ok: r["checks"]["sizes_match"]=True; s+=1
        r["checks"]["all_screens"]=True; s+=1
    rep = workspace/"bug_report.md"
    if not rep.exists(): rep = rd_alt/"bug_report.md"
    if rep.exists():
        c=rep.read_text(errors="ignore")
        rows=[l for l in c.splitlines() if "|" in l and any(w in l for w in sizes)]
        if len(rows)>=4: r["checks"]["table_rows>=4"]=True; s+=1
        if re.search(r"\|\s*(是|Yes)\s*\|", c): r["checks"]["bug_flagged"]=True; s+=1
    annots=list(workspace.glob("annotated_*.png")) + list(rd_alt.glob("annotated_*.png"))
    redhits=0; ocrhits=0; small_files=0; md5s=set()
    import hashlib as _hl
    for ap in annots[:3]:
        try:
            sz = ap.stat().st_size
            if sz < 5_000: small_files += 1
            md5s.add(_hl.md5(ap.read_bytes()).hexdigest())
        except Exception: pass
        a=np.array(Image.open(ap).convert("RGB"))
        red=((a[...,0]>180)&(a[...,1]<80)&(a[...,2]<80)).mean()
        if red>0.02: redhits+=1
        try:
            tx=pytesseract.image_to_string(Image.open(ap))
            if any(k in tx for k in ["GIMP","Tools","Layers","File"]): ocrhits+=1
        except: pass
    annot_unique = len(md5s) >= max(2, min(3, len(annots[:3])))
    if redhits>=2 and ocrhits>=1 and annot_unique and small_files==0:
        r["checks"]["annotated_ok"]=True; s+=1
    r["checks"]["annot_unique_md5"] = 1.0 if annot_unique else 0.0
    r["checks"]["annot_no_tiny"] = 1.0 if small_files==0 else 0.0

    # New: window_metrics.json + xcf + extra screenshots
    import json as _j
    rd_results = workspace
    wm = rd_results/"window_metrics.json"
    if not wm.exists(): wm = rd_alt/"window_metrics.json"
    wm_data = {}
    if wm.exists():
        try: wm_data = _j.loads(wm.read_text())
        except Exception: pass
    samples = wm_data.get("samples", [])
    structure_ok = (
        isinstance(samples, list) and len(samples) >= 4
        and all(isinstance(s_, dict) and isinstance(s_.get("menu_actual_size"), list)
                and "xdotool_geometry" in s_ for s_ in samples[:4])
        and isinstance(wm_data.get("wm_decoration_height"), int)
    )
    r["checks"]["window_metrics"] = 1.0 if structure_ok else 0.0; s += r["checks"]["window_metrics"]; t += 1

    # XCF for annotated — check both root and results/
    annot_xcfs = list(rd_results.glob("annotated_*.xcf")) + list(rd_alt.glob("annotated_*.xcf"))
    r["checks"]["annot_xcf"] = min(1.0, len(annot_xcfs)/3.0); s += r["checks"]["annot_xcf"]; t += 1
    xcf_layered = 0
    for x in annot_xcfs[:3]:
        try:
            head = x.read_bytes()[:14]
            if head.startswith(b"gimp xcf") and x.stat().st_size > 50_000:
                xcf_layered += 1
        except Exception: pass
    r["checks"]["annot_xcf_layered"] = xcf_layered / max(1, len(annot_xcfs[:3])); s += r["checks"]["annot_xcf_layered"]; t += 1

    # Extra evidence screenshots
    extra = ["view_godot_resized_native.png","view_xdotool_terminal.png","view_gimp_annotation_workflow.png"]
    extra_present = sum(1 for n in extra
                        if (rd_results/n).exists() or (rd_alt/n).exists())
    r["checks"]["evidence_screens"] = extra_present / len(extra); s += r["checks"]["evidence_screens"]; t += 1

    # ----- v2 weighted aggregation: core 60% / gui 30% / aux 10% -----
    def _g(k, default=0.0):
        v = r["checks"].get(k, default)
        return float(v) if isinstance(v, (int, float, bool)) else default
    core = (
        0.30 * (1.0 if r["checks"].get("sizes_match") else 0.0)
        + 0.20 * (1.0 if r["checks"].get("all_screens") else 0.0)
        + 0.20 * (1.0 if r["checks"].get("table_rows>=4") else 0.0)
        + 0.15 * (1.0 if r["checks"].get("bug_flagged") else 0.0)
        + 0.15 * _g("window_metrics")
    )
    gui = (
        0.40 * (1.0 if r["checks"].get("annotated_ok") else 0.0)
        + 0.30 * _g("annot_xcf")
        + 0.30 * _g("annot_xcf_layered")
    )
    aux = _g("evidence_screens")
    base = 0.60 * core + 0.30 * gui + 0.10 * aux

    # ----- v2 multi-tier hard gates (越严越好) -----
    if _g("window_metrics") < 1.0:
        base = min(base, 0.45)        # 关键取证缺失
    if _g("annot_xcf_layered") < 0.5:
        base = min(base, 0.55)
    if _g("annot_xcf") < 0.66:
        base = min(base, 0.55)
    if not r["checks"].get("annotated_ok"):
        base = min(base, 0.55)        # GUI 真实交互缺失
    if not r["checks"].get("sizes_match") or not r["checks"].get("all_screens"):
        base = min(base, 0.40)        # 核心交付物失败
    if _g("evidence_screens") < 1.0/3:
        base = min(base, 0.60)
    if _g("annot_unique_md5") == 0.0 or _g("annot_no_tiny") == 0.0:
        base = min(base, 0.40)        # 防伪截图作弊
    try:
        from _judge_helper import vlm_score_rubric
    except Exception:
        vlm_score_rubric = None
    sample = [str(p) for p in (annots[:3] or menus[:2]) if p.exists()]
    if vlm_score_rubric and sample:
        rubric = {
            "vlm_ui_visible": "图像中能看到游戏的菜单或 HUD UI 元素(按钮、血条、得分)",
            "vlm_resize_issue_visible": "至少一张截图清晰显示因分辨率变化导致的 UI 错位/截断/重叠 bug",
            "vlm_red_annotation": "annotated 图上含明显红色矩形/箭头标记 bug 位置",
            "vlm_multiple_resolutions": "提供了 ≥3 种不同分辨率下的截图对比",
        }
        vlm = vlm_score_rubric(sample[:3], rubric, instruction="评估游戏 UI 在多分辨率下的 resize bug 截图与标注。")
        for k in rubric: r["checks"][k] = vlm.get(k, 0.0)
        r["judge_method"] = vlm.get("judge_method", "failed")
        vlm_avg = sum(vlm.get(k, 0.0) for k in rubric)/len(rubric)
        # v2: 多级 VLM 阈值
        if vlm_avg < 0.4:
            base = min(base, 0.30)
        elif vlm_avg < 0.6:
            base = min(base, 0.45)
        r["overall_score"] = round((base + vlm_avg)/2, 3)
    else:
        # v2: VLM 不可用时退化分上限封顶 0.60
        r["overall_score"] = round(min(base, 0.60), 3)

    # ----- BEGIN CHEAT/VLM HARD-GATE (auto-injected) -----
    try:
        from _judge_helper import audit_chat_jsonl_for_banned as _audit
    except Exception:
        _audit = None
    _BANS = ['--headless', 'godot4 --check', 'project.godot']
    if _audit is not None:
        try:
            _a = _audit(_BANS)
            r["audit_total_tool_calls"] = _a.get("total_tool_calls", 0)
            r["audit_screenshots"] = _a.get("computer_screenshots", 0)
            r["audit_any_banned"] = 1.0 if _a.get("any_banned") else 0.0
            r["audit_matches"] = ",".join(_a.get("matches", [])[:5])
            if _a.get("any_banned") and _a.get("computer_screenshots", 0) == 0:
                r["overall_score"] = min(float(r.get("overall_score", 1.0)), 0.30)
            if _a.get("total_tool_calls", 0) >= 5 and _a.get("computer_screenshots", 0) == 0:
                r["overall_score"] = min(float(r.get("overall_score", 1.0)), 0.45)
        except Exception as _e:
            r["audit_error"] = str(_e)[:120]
    # ----- END CHEAT/VLM HARD-GATE -----
    return r

Workspace Path

workspace/GAM/task_1_game_ui_bug/

Skills


Env


Warmup

which godot4 >/dev/null 2>&1 || ( for url in "https://github.com/godotengine/godot/releases/download/4.2.2-stable/Godot_v4.2.2-stable_linux.x86_64.zip" "https://ghproxy.net/https://github.com/godotengine/godot/releases/download/4.2.2-stable/Godot_v4.2.2-stable_linux.x86_64.zip" "https://mirror.ghproxy.com/https://github.com/godotengine/godot/releases/download/4.2.2-stable/Godot_v4.2.2-stable_linux.x86_64.zip" "https://downloads.tuxfamily.org/godotengine/4.2.2/Godot_v4.2.2-stable_linux.x86_64.zip"; do curl -fL --retry 5 --retry-delay 3 --connect-timeout 30 -o /tmp/godot.zip "$url" && break; done && unzip -qo /tmp/godot.zip -d /usr/local/bin/ && mv /usr/local/bin/Godot_v4.2.2-stable_linux.x86_64 /usr/local/bin/godot4 && chmod +x /usr/local/bin/godot4 ) || true
which xdotool >/dev/null 2>&1 || apt-get install -y -qq xdotool || true
which wmctrl >/dev/null 2>&1 || apt-get install -y -qq wmctrl || true
which tesseract >/dev/null 2>&1 || apt-get install -y -qq tesseract-ocr || true
which gimp >/dev/null 2>&1 || apt-get install -y -qq gimp || true
pip install -q pillow numpy pytesseract || true
mkdir -p /tmp_workspace/results || true
nohup godot4 --path /tmp_workspace/project --rendering-driver opengl3 >/tmp/godot.log 2>&1 &
sleep 5
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