Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
54fb116
Add project docs, report template, and baseline agent
lzx-nju Jul 3, 2026
d3ca184
Update gitignore for LaTeX and local caches
lzx-nju Jul 4, 2026
76cc340
Add task 4 baseline state machine and update docs
lzx-nju Jul 4, 2026
fa942bf
实现了task1,2的形式化,为task3,4,5形式化提供框架
praline0831 Jul 5, 2026
ed85a23
Improve pixel-based baseline for tasks 3 and 4
cooperr3165 Jul 5, 2026
dae296a
Complete task 5 baseline and update project notes
cooperr3165 Jul 5, 2026
3daf13a
task1-5环境形式化全部完成
praline0831 Jul 6, 2026
bd2e5ee
Update report with final evaluation results
cooperr3165 Jul 6, 2026
bba76b2
Generate report PDF
cooperr3165 Jul 6, 2026
700debd
Add task 5 symbolic policy proof
cooperr3165 Jul 6, 2026
9f32b24
task1-5策略形式化全部完成
praline0831 Jul 6, 2026
cfb0cf9
更新形式化文件命名
praline0831 Jul 7, 2026
7802a81
Fix report consistency and rebuild PDF
cooperr3165 Jul 7, 2026
f448805
Add strategy framework completeness proof
cooperr3165 Jul 7, 2026
c405968
Fill final team member names
cooperr3165 Jul 7, 2026
7510c52
Add lean-toolchain and update report with 10-seed evaluation
lzx-nju Jul 8, 2026
55bd586
task1-4由硬编码改为BFS,task5改BFSdebug进行到一半
praline0831 Jul 9, 2026
b7cb6bf
task5有改进,但像素对齐逻辑在某些位置导致agent无法移动,需要进一步调试或恢复旧代码
praline0831 Jul 9, 2026
94f1ce3
Merge branch 'CrazyJassBread:main' into main
praline0831 Jul 9, 2026
cbaafc5
Align Task1 Lean proof with BFS policy
xuHaob1 Jul 9, 2026
8cbd7ea
Merge remote-tracking branch 'upstream/main'
lzx-nju Jul 10, 2026
11c86e0
适配评测脚本 safe 模式,移除 reward_signals 依赖
lzx-nju Jul 10, 2026
f461e02
更新评测结果与报告:safe 模式 10 seed 评测
lzx-nju Jul 10, 2026
d85cdfc
修复 Task1 Lean warning,报告补充 original 评测说明
lzx-nju Jul 10, 2026
2f7c08b
修复task4的spatial a,b,未改c
praline0831 Jul 11, 2026
3597e32
修复task4的spatial_c:abyss tile 上 final_chest 探测
lzx-nju Jul 11, 2026
9255f9a
修复task1-3 spatial变体,更新robustness suite评测结果
lzx-nju Jul 11, 2026
4110106
task2-4策略形式化也改为BFS模式
praline0831 Jul 12, 2026
2e2cb0e
适配可逆颜色变体,color部分通过3/5
praline0831 Jul 13, 2026
834afca
修复task_5导航执行层7个bug,task_1-4无回归
lzx-nju Jul 13, 2026
5e25912
优化task_5 original至success_rate=1.000并更新报告
praline0831 Jul 14, 2026
91324b0
task5: fix start room detection + update report with color/spatial va…
praline0831 Jul 15, 2026
5fb193f
task5: fix spatial_a/b variants with no_attack_tiles and diagonal_block
praline0831 Jul 16, 2026
1ba1f94
Complete Task 5 formalization and robustness support
cooperr3165 Jul 17, 2026
702fbfb
Add provisional 500-episode robustness log for review
cooperr3165 Jul 17, 2026
d1d9579
Sync report/JSON/progress consistency and add run-evidence appendix
lzx-nju Jul 18, 2026
db7db21
Add milestone/progress tables and student IDs
lzx-nju Jul 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.venv/
.venv*/

*.egg-info
dist/
Expand All @@ -9,8 +9,13 @@ __pycache__/
*.pyd
*.log
*.bak
.coverage
.DS_Store
.idea/
.pytest_cache/
.mypy_cache/
.ruff_cache/
.ipynb_checkpoints/

self_use/
.vscode/
Expand All @@ -19,5 +24,33 @@ self_use/

CLAUDE.md
.claude/
.trae/

# 临时调试脚本与备份
_debug_*.py
_debug_*.txt
_debug_output.txt
_old_*.txt
_test_*.py
_test_*.txt
_*.npy
_eval_*.json

# 临时评测结果(保留正式的 eval_results.json)
docs/Mathematical_logic/report/eval_*_quick.json
docs/Mathematical_logic/report/eval_safe_*.json
docs/Mathematical_logic/report/eval_t*_pure.json
docs/Mathematical_logic/report/eval_task5_fix.json
docs/Mathematical_logic/report/eval_robust_*.json

# LaTeX temporary files
*.aux
*.bbl
*.blg
*.fdb_latexmk
*.fls
*.out
*.toc
*.synctex.gz


48 changes: 48 additions & 0 deletions _debug_sprite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from __future__ import annotations

import sys
from pathlib import Path

import numpy as np

PROJECT_ROOT = Path(__file__).resolve().parent
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))

from nesylink.env import make_env
from nesylink.core.constants import ACTION_LABELS, ACTION_LEFT, ACTION_RIGHT, ACTION_UP, ACTION_DOWN
from student_agent.baseline_policy import PLAYER_COLORS


def green_bounds(frame):
xs, ys = [], []
for color in PLAYER_COLORS:
mask = np.all(frame == color, axis=2)
yy, xx = np.nonzero(mask)
if len(xx) > 0:
xs.append(xx); ys.append(yy)
xs = np.concatenate(xs); ys = np.concatenate(ys)
return int(xs.min()), int(xs.max()), int(ys.min()), int(ys.max()), int(xs.mean()), int(ys.mean())


def run():
env = make_env(task_id="mathematical_logic/task_1", observation_mode="pixels")
obs, info = env.reset(seed=0)
# move right a few ticks, then left, then up, then down - observe green bounds vs engpos
plan = [("right", 3), ("left", 6), ("up", 3), ("down", 6)]
action_map = {"right": ACTION_RIGHT, "left": ACTION_LEFT, "up": ACTION_UP, "down": ACTION_DOWN}
pos = info["agent"]["position_px"]
xmin, xmax, ymin, ymax, xmean, ymean = green_bounds(obs)
print(f"init engpos={pos} green xmin={xmin} xmax={xmax} ymin={ymin} ymax={ymax} mean=({xmean},{ymean}) left_min={xmin-4} left_mean={xmean-8}")
for direction, ticks in plan:
a = action_map[direction]
for _ in range(ticks):
obs, r, term, trunc, info = env.step(a)
pos = info["agent"]["position_px"]
xmin, xmax, ymin, ymax, xmean, ymean = green_bounds(obs)
print(f"{direction} engpos=({pos[0]:.0f},{pos[1]:.0f}) green x[{xmin},{xmax}] y[{ymin},{ymax}] mean=({xmean},{ymean}) left_min={xmin-4} left_mean={xmean-8}")
env.close()


if __name__ == "__main__":
run()
66 changes: 66 additions & 0 deletions _debug_task12.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from __future__ import annotations

import sys
from pathlib import Path

import numpy as np

PROJECT_ROOT = Path(__file__).resolve().parent
if str(PROJECT_ROOT) not in sys.path:
sys.path.insert(0, str(PROJECT_ROOT))

from nesylink.env import make_env
from nesylink.core.constants import ACTION_LABELS
from student_agent.baseline_policy import Policy


def run(task_id: str, seed: int = 0, max_steps: int = 1000):
env = make_env(task_id=task_id, observation_mode="pixels")
obs, info = env.reset(seed=seed)
policy = Policy()
policy.reset(seed=seed, task_id=task_id)
print(f"=== {task_id} seed={seed} ===")
prev_tile = None
for step in range(1, max_steps + 1):
action = policy.act(obs, info)
tile = policy.history.facing if False else None
# detect player tile from obs
pt = policy.detect_player_tile(obs)
keys = int(info.get("inventory", {}).get("keys", 0))
label = ACTION_LABELS[action] if action < len(ACTION_LABELS) else str(action)
monster = policy.detect_monster_tile(obs) if task_id.endswith("task_2") else None
agent = info.get("agent", {})
pos = agent.get("position_px", None)
det_px = policy.detect_player_px(obs)
last_msg = info.get("engine", {}).get("last_message") if "engine" in info else None
events = [r.get("name") for r in info.get("events", {}).get("records", [])]
prev_action = getattr(run, "_pa", None)
prev_pos = getattr(run, "_pp", None)
meaningful = (
pt != prev_tile
or action != prev_action
or events
or "blocked" in str(events)
or pos != prev_pos and (pos is None or prev_pos is None or abs(pos[0] - prev_pos[0]) + abs(pos[1] - prev_pos[1]) > 15)
)
marker = ""
if pt == prev_tile and action in (1, 2, 3, 4) and "blocked" in str(events):
marker = " <-- BLOCKED"
prev_tile = pt
run._pa = action
run._pp = pos
if meaningful or marker:
print(
f"step {step:3d} tile={pt} engpos={pos} detpx={det_px} keys={keys} facing={policy.history.facing} "
f"action={label} events={events} monster={monster}{marker}"
)
obs, reward, terminated, truncated, info = env.step(action)
if terminated or truncated:
print(f" -> terminated={terminated} truncated={truncated} reason={info.get('terminal_reason')}")
break
env.close()


if __name__ == "__main__":
task = sys.argv[1] if len(sys.argv) > 1 else "mathematical_logic/task_1"
run(task)
Loading