Skip to content

From Watching to Playing: Auto-Playing Video Games with a Self-Constructed Code World Model

Yao Tong, Jiaxin Qi, Yan Cui, Yuhua Zheng, Jianqiang Huang

cs.AI

Abstract

Vision-language model (VLM) agents can play video games by selecting actions from successive screenshots, but calling a VLM at each decision step incurs prohibitive time and token costs. Compiling a VLM's game knowledge into reusable code would amortize these costs, yet raw visual gameplay entangles autonomous physics with player actions, obscuring the transition dynamics a compiled model needs. To address both challenges, we present PlaySmith, an agent harness that constructs three modules from visual gameplay. First, a visual Observer detects game objects and tracks them across frames with persistent identity. Second, action-conditioned displacement (ACD) links actions to object motion, guiding construction of a stateful Predictor that distinguishes action-driven motion from autonomous physics. Third, a controller uses the Predictor to evaluate candidate action sequences multiple steps ahead and executes the selected action. Across eight 2D browser games, PlaySmith achieves competitive scores relative to direct VLM gameplay using the same backbone, while consuming no VLM tokens during evaluation episodes per game and reducing mean per-step latency from 4.526 to 0.293 seconds. These results demonstrate that a self-constructed code world model can be more practical than direct VLM play in settings requiring repeated deployment.

Create a lesson