feat: Add AntWar2 - #2
Open
NemotionalDamage wants to merge 3 commits into
Open
Conversation
wkj2333666
requested changes
Jul 28, 2026
wkj2333666
left a comment
Collaborator
There was a problem hiding this comment.
自动 AI 审阅已通过最新 SSE 链路完整执行,结论为 fail,共 17 条 findings。主要阻塞项包括:策略 manifest 在制品元数据更新前写入,导致规则/RL/外部策略重载后变成不同 agent;同时回合和多操作验证存在顺序依赖与重复计费;get_legal_actions 返回值无法 round-trip 给 step;非 smoke PPO 路径会因包装器类型直接崩溃,且训练目标、ppo_epochs 和随机种子不正确;评测选择与持久化 summary 会记录错误或不完整结果;外部 agent 缺少 timeout/隔离,zip 导入未真正导入,population 路径存在越界风险。请逐项修复并补 round-trip、对称性、非 smoke PPO、持久化及安全边界测试。完整 annotations:https://github.com/SAST-agent/AgentBenchFramework/actions/runs/30274923306/job/90181293895
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
为 AntWAR2 游戏搭建完整的基础设施:引入 rank05 选手的游戏引擎,按 BaseEnv 接口封装;构建统一策略层、策略库管理、对战矩阵、预算记录,以及评测、Coding Agent 迭代、RL 训练三大入口。完整闭环可端到端跑通,所有产出符合 CI 数据契约。
核心功能
游戏引擎与环境
env/_antwar2/,所有SDK.引用已重写AntWar2Env(BaseEnv)封装引擎,缓冲玩家0操作,在玩家1行动时统一结算opponent回调,切换为单智能体 RL 自对弈模式统一策略接口
BaseStrategy(BaseAgent)- 抽象基类,定义act()/reset()/save()/load()RuleStrategy- 内置策略(hold/random/greedy/pragmatic)+ 自定义模块RLStrategy- torch 策略(卷积+MLP+actor/critic),缺失时降级为贪心ExternalStrategy- 4字节长度前缀 JSON stdio 驱动外部进程策略库与数据划分
Population- 版本化磁盘注册表,支持注册、加载、历史记录、ZIP 导入DataSplit- train/validation/hidden-test 划分,hidden 集训练时不可见对战矩阵与预算
PayoffMatrix- 全配对胜率矩阵,支持增量评估(O(n))BudgetRecorder- 累计环境交互、wall-clock、API/token、GPU 成本三大入口
eval_entry- 单策略评测 / 多策略对比(PayoffMatrix 循环赛)iter_entry- Coding Agent 迭代(加载→edit_fn→注册→评测→接受/拒绝)rl_entry- PPO 训练(torch 可用)或贪心 smoke test(torch 缺失)接入
register_env("antwar2", AntWar2Env)agentbench antwar2 {eval, iterate, train}CLIAntWar2Env修复内容
load_strategy()循环依赖:改为懒加载导入子类DataSplit.load()未解包assignment键:修复后正确读取划分配置cli.pyPython 3.10 兼容性:tomllib改为懒加载并增加tomli回退验证
在 WSL Ubuntu-22.04(Python 3.10、numpy、无 torch)环境下:
设计说明
run.toml + summary.json + cost_summaryiter_entry的edit_fn可替换为真实 LLM