用分步分解+三智能体协作,让大模型更准地生成可运行的游戏代码。
FactorSmith: Agentic Simulation Generation via Markov Decision Process Decomposition with Planner-Designer-Critic Refinement
- 将复杂仿真拆成小模块,每步只处理少量状态变量,减少上下文压力。
- 三智能体迭代优化:规划者调度、设计者写代码、评论者评分并回滚错误。
- 在PyGame基准上,生成代码错误少、质量高、更贴合用户描述。
从自然语言描述生成可执行仿真仍是难题,因大语言模型在处理大型互连代码库时推理能力有限。本文提出FactorSmith框架,通过结合两种互补思想——基于因子化部分可观测马尔可夫决策过程(POMDP)的结构化上下文压缩,以及分层的规划-设计-评论者智能体工作流——实现代码级可玩游戏仿真的自动合成。受FactorSim [Sun et al., 2024]启发,该方法将仿真规格分解为模块化步骤,每个步骤仅操作相关状态变量的最小子集,从而限制单次LLM调用需处理的上下文范围。借鉴SceneSmith [Pfaff et al., 2025]的智能体三元组架构,每个分解步骤内嵌三个智能体:规划者协调流程,设计者生成代码片段,评论者通过结构化评分评估质量并支持检查点回滚,实现生成过程中的迭代优化。本文形式化了该联合方法,给出了上下文选择与智能体精炼的数学基础,并介绍了开源实现。在PyGame Learning Environment基准上的实验表明,相较于非智能体的因子化基线,FactorSmith生成的仿真具有更好的提示对齐性、更低的运行时错误率和更高的代码质量。
原文摘要 · Abstract (English)
Generating executable simulations from natural language specifications remains a challenging problem due to the limited reasoning capacity of large language models (LLMs) when confronted with large, interconnected codebases. This paper presents FactorSmith, a framework that synthesizes playable game simulations in code from textual descriptions by combining two complementary ideas: factored POMDP decomposition for principled context reduction and a hierarchical planner-designer-critic agentic workflow for iterative quality refinement at every generation step. Drawing on the factored partially observable Markov decision process (POMDP) representation introduced by FactorSim [Sun et al., 2024], the proposed method decomposes a simulation specification into modular steps where each step operates only on a minimal subset of relevant state variables, limiting the context window that any single LLM call must process. Inspired by the agentic trio architecture of SceneSmith [Pfaff et al., 2025], FactorSmith embeds within every factored step a three-agent interaction: a planner that orchestrates workflow, a designer that proposes code artifacts, and a critic that evaluates quality through structured scoring, enabling iterative refinement with checkpoint rollback. This paper formalizes the combined approach, presents the mathematical framework underpinning context selection and agentic refinement, and describes the open-source implementation. Experiments on the PyGame Learning Environment benchmark demonstrate that FactorSmith generates simulations with improved prompt alignment, fewer runtime errors, and higher code quality compared to non-agentic factored baselines.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。