Source-linked AI summary
Think Offline, Act in Real Time: Self-Improving Visual Game Agents through Code
Zipeng Qiu, Shusheng Xu, Jiale Li, Yukun Zhou, Chenyue Li, Wenshuang Li, Tongkai Yang, Binhang Yuan
TL;DR
In unfamiliar real-time visual games, an agent must learn from a few attempts while the game continues running and only the screen is observable. The paper compares a model that acts during play with a program revised between attempts. On GameWorld, code as policy attains higher mean progress than the trained controller and leads in all five categories.
Problem
The paper asks how an agent can turn a few attempts into an effective policy for an unfamiliar game that runs while the agent thinks and is observed only through its screen.
Source: §1 · p. 2Method
The paper adapts real-time chunking for a trained controller and has a model develop, test, and revise an executable visual-control program between game executions.
Source: §1 · p. 3Results
47.80% mean progress for the best code-development submission versus 30.90% for one RTC-2B episode across 170 GameWorld tasks, with gains in all five categories.
Source: §1 · p. 3Takeaways & Limitations
The findings support storing what the model learns in a program that acts in real time, while the model reasons between executions.
Source: §6 · p. 16Continuous action supply under the stated queue conditions requires P ≥ L and C ≥ L, so the result is bounded by the periodic fixed-latency setting with fresh observations and no additional scheduling delay.
Source: §2.1 · p. 5
Abstract
from arXiv · showhide
Pre-trained models can read screens and reason about games, yet on an unfamiliar game, an agent still has to learn to play. We ask how an agent can self-improve on such a game from a few of its own attempts, in real-time visual games where the agent sees only the screen and the game keeps running while the agent thinks. We study two kinds of policy that can carry this improvement. In model as policy, a model selects actions during play; we adapt real-time chunking so that committed actions keep executing while the model reasons, and train a 2B controller for this interface. In code as policy, a model writes, tests, and revises a program between attempts, and the program acts during play. Across 170 GameWorld tasks, with at most eight one-minute executions per run, code as policy reaches 47.80% mean progress, against 30.90% for our trained controller, and leads in all five game categories. Improving the controller's weights on a single game, by contrast, yields only modest gains. These results favor letting a model think offline and storing what it learns in a program that acts in real time. Project repository: https://github.com/TabibitoQZP/SIGame
1 Introduction
The paper asks how an agent can turn a few attempts at an unfamiliar, continuously running visual game into an effective policy. It compares a model that acts during play with a program revised between attempts, reporting stronger GameWorld progress for code as policy.
1 Introduction
- Real-time play limits attempts because the game keeps running while the agent thinks, and each attempt consumes actual play time.A failed strategy may reflect perception, planning, or action timing, so misdiagnosis can waste an attempt.Source: §1 · p. 2
- Model as policy stores learning in model parameters, whereas code as policy stores it in a program that interprets observations and selects actions.The model must reason while the game moves; a code policy must recover state from pixels.Source: §1 · p. 2
- The open question is which policy type better uses a few attempts in a running game observed only through its screen.Prior approaches address parts of the problem but do not settle this comparison in the stated setting.Source: §1 · p. 2
- 47.80% mean progress across 170 GameWorld tasks for code as policy versus 30.90% for one RTC-2B episode, with gains in all five categories.The code result uses the best submission from a run of at most eight one-minute executions.Source: §1 · p. 3
2 Model as Policy
The model-as-policy approach keeps a model selecting actions during play while the game continues to advance. Its queue-conditioned real-time chunking interface overlaps action execution and inference; the controller is trained broadly and then further trained on Stack.
2 Model as Policy
- The model policy maps available context to action chunks, requiring runtime scheduling so actions continue while the next reply is generated.Both policy types use screenshots and keyboard–mouse inputs, and internal game state is not exposed.Source: §2 · p. 3
2.1 Real-Time Chunking
- At 200 ms ticks, RTC samples the latest frame and dispatches from a FIFO queue while inference runs concurrently; the model conditions on visual history and unexecuted actions.A valid new chunk is appended without reinserting consumed actions or replacing or reordering the remaining queue.Source: §2.1 · p. 4, Figure 2 · p. 4
2.2 Training the Controller
- The controller is trained on games separate from GameWorld: teacher demonstrations train reasoning and action chunks, followed by request-level reinforcement learning from score changes.The demonstrations are not filtered by task success; initial episode-level GRPO showed no clear improvement.Source: §2.2 · p. 5
2.3 Self-Improvement in Weights
- For Stack, RTC-2B is further trained using an independent simulator, with SFT followed by two RL variants, then evaluated in simulation and in the running original game.The training procedure is revised from evaluation results, with humans adjusting only between stages.Source: §2.3 · p. 5, Figure 3 · p. 6
3 Code as Policy
In code as policy, a model develops an executable program between attempts, and that program processes screenshots and chooses actions during gameplay. Execution records guide revisions, while separate execution and development budgets constrain the process.
3 Code as Policy
- Code as policy changes the program rather than model weights, separating reasoning between executions from the program’s response to new screenshots during play.The program maintains visual state estimates and selects actions without the developer model choosing actions during execution.Source: §3 · p. 6, §3.1 · p. 6
3.1 Self-Improvement through Code
- A developer can begin from an interaction trajectory or initial screenshot, inspect evidence, test code offline, and revise after executions using recorded frames, input and timing records, and errors.Later edits cannot change a submitted program during its execution, and feedback excludes private evaluator progress and success signals.Source: §3.1 · pp. 6–7
3.2 Allocating the Self-Improvement Budget
- Code policies make one-action decisions on the 200 ms clock, using the latest available frame after a slow call instead of replaying missed observations.Four independent developers are compared with four developers exchanging code and public execution evidence midway under matched total submission and output-token caps.Source: §3.1 · p. 7, §3.2 · p. 7
4 Experiments
Across GameWorld, code development outperforms direct control, while real-time chunking and broad training make a small controller competitive. The experiments also compare how initial evidence and development budgets shape results.
4.1 Benchmark and Metrics
- GameWorld [7] covers 170 tasks across 34 games and five categories; detailed comparisons use a 31-task subset of each game's demanding 05 task.Progress and success are task-averaged percentages; evaluator scores are not shown to policies or developers.Source: §4.1 · p. 8
4.2 Real-Time Execution
- On the 31-task subset, 6s RTC reaches 26.46% mean progress versus the baseline’s 24.99%, while 3s RTC reaches 21.83%.At 6s, success is 11.29% versus the baseline’s 7.26%; the 3s queue is empty on 53.12% of ticks versus 42.62% at 6s.Source: §4.2 · p. 9
4.3 Training and Self-Improvement in Weights
- RTC-2B reaches 21.82% mean progress, matching Qwen3.8-27B’s 21.83% under the same 3s configuration, but retains a large Puzzle gap.SFT makes replies reliable; RL then raises progress from 17.68% to 21.82% with validity and empty-queue rates nearly unchanged.Source: §4.3 · pp. 10–11, Figure 4 · p. 10
- On Stack’s original game, specialized RL reaches a mean height of 3.25 layers versus RTC-2B’s 1.75 across four games per controller; none of the evaluated controllers completes the 30-layer tower.Separately, in the independent simulator, a hand-written controller completed 14 of 16 games using the same RGB requests and fixed 3-second delay.Source: §4.3 · p. 11
4.4 Self-Improvement through Code
- Across 170 tasks, code development reaches 47.80% progress and 27.79% success, versus RTC-2B’s 30.90% and 12.65%, leading in all five categories.Puzzle shows the largest progress gain, from 35.74% to 70.81%.Source: §4.4 · pp. 12–13, Table 6 · p. 13
- With Qwen3.8-27B fixed, code development reaches 32.30% progress from a trajectory and 32.26% from one frame, versus 26.46% for direct 6s control.On the 31-task subset, trajectory-initialized development has higher mean progress on 20 tasks and lower on 8; the single-frame start achieves nearly identical mean progress.Source: §4.4 · p. 13, Table 7 · p. 14
4.5 Allocating the Self-Improvement Budget
- With matched total caps, the best of four independent runs reaches 65.21% progress and 44.71% success, versus 59.82% and 39.41% for the peer-reviewing team.The second independent run adds 10.04 points of best-attained progress; the third and fourth add 4.59 and 2.78 points.Source: §4.5 · pp. 14–15, Table 9 · p. 15
- Peer inspection can redirect a stalled developer: D adopts A’s grid tracking and planning approach, then reaches six apples on its fifth Snake submission.D had received no valid review of its own; the exchange transferred an already successful approach.Source: §4.5 · pp. 14–15, Figure 5 · p. 15
5 Related Work
Prior work spans visual game control, executable policies, self-improvement, and collaborative development. This paper places code-based self-improvement in continuously running visual games, where a program built from screenshots and execution records selects every action.
Visual game agents and real-time execution
- Visual game-control research studies gameplay-corpus-trained controllers, inference latency, and committed-action chunking; this work adapts committed actions to discrete inputs and evaluates latency and task performance.GameWorld supplies standardized tasks across diverse games, including continuously running environments.Source: §5 · p. 16
Executable policies and self-improvement
- Prior executable-policy work ranges from robot programs and reusable game skills to visual-control systems, while this study revises screenshot-based policies between executions without internal-state access.The program, rather than a model, selects each action during play.Source: §5 · p. 16
Independent development and collaboration
- Prior collaboration research includes debate and role-based software development; this paper compares communication with independent exploration under equal submission and token caps.The cited re-evaluations find debate does not consistently outperform self-consistency or ensembling.Source: §5 · p. 16
6 Conclusion
The paper compares model-as-policy and code-as-policy self-improvement for unfamiliar real-time visual games. Code development leads across GameWorld categories and retains a mean advantage when the developer model is fixed, while controller weight improvements on one game are modest.
6 Conclusion
- Code as policy attains higher progress across all five GameWorld categories, with its mean advantage persisting when the model is fixed.The conclusion contrasts this with only modest gains from improving a controller’s weights on a single game.Source: §6 · p. 16
- Independent attempts reach higher best scores than midpoint peer review under matched submission and token caps, though peer evidence can redirect a stalled developer.The design places policy-improving reasoning between executions and leaves visual estimation and control to the program during play.Source: §6 · p. 16
A Additional Evaluation Details
- Appendix A describes task coverage, execution protocols, development resources, score aggregation, main-comparison measurements, scoring corrections, and initialization details.It supplements the main comparisons with additional evaluation details.Source: A Additional Evaluation Details · p. 19
A.1 Task Coverage and Scoring
The appendix specifies benchmark coverage and scoring, execution and development protocols, and how to interpret the system comparisons. It also reports controller, latency, initialization, and same-model analyses, with their sampling and scope qualifications.
A.1 Task Coverage and Scoring
- The full benchmark keeps all 170 tasks in the denominator, including zero-scored Captain Callisto tasks and execution failures; the 31-task subset excludes games unsupported by the input interface and Captain Callisto.Task _05 is used for each of 31 games; its index does not define a common difficulty level across games.Source: §A.1 · p. 19
A.2 Execution and Development Protocols
- Each code submission freezes the policy for an execution, and the developer can inspect selected frames, input and timing records, and errors before revising it.The program receives an RGB array and prior local state, returns an action and updated state, and has no internal game variables; attempts consume one of at most eight opportunities.Source: §A.2 · pp. 19–20
A.3 Interpreting the Development Comparison
- Code-development and direct-control results compare complete systems with different interfaces, budgets, contexts, action interfaces, and generation settings.A direct-control run is one 180-second episode; independent development allows up to eight 60-second executions and 256K output tokens.Source: §A.3 · p. 20
A.4 Additional Controller Comparisons
- Qwen3.5-2B scores higher through the GameWorld baseline than through RTC, while comparisons with trained controllers indicate RTC pays off only after the controller learns to use it.The untrained model struggles to produce valid RTC chunks, and the interfaces differ in context and action representation.Source: §A.4 · p. 21
A.5 Latency Measurements
- Latency analysis covers 868 episodes and 38,238 requests, but request and release statistics use different sample sets and do not measure screenshot-to-first-action delay.Latency includes service queuing, transmission, generation, and client processing; hardware and load varied across evaluation batches.Source: §A.5 · p. 21
A.6 Initialization Comparison
- Trajectory initialization’s paired 95% intervals span zero for both mean progress and per-task maximum progress.The comparisons pair trajectory and initial-frame starts across 31 tasks; two initial-frame and eight trajectory sessions lack valid scores and remain zero in the fixed denominators.Source: §A.6 · p. 22
A.7 Same-Model Comparison
- The same-model subset uses only task _05 objectives, and its descriptive game-level bootstrap intervals are uncorrected for multiple comparisons.The mean-progress interval includes zero for the trajectory start against RTC at 6s, while every per-task maximum-progress interval excludes zero.Source: §A.7 · pp. 22–23
A.8 Task- and Game-Level Comparisons
Task- and game-level comparisons show code development ahead on most tasks and games, while direct control retains advantages on some games. The appendix also reports same-model and collaborative-team comparisons and identifies the training stages used to obtain RTC-2B.
A.8 Task- and Game-Level Comparisons
- Code development has higher four-run mean progress on 111 of 170 tasks versus 28 for direct control, and leads on 27 of 34 games.The best-of-four comparison favors code on 91 tasks versus 14; its largest game gains are Wordle (+84 points), 2048 (+51), Minesweeper (+46), and Breakout (+46), while direct control leads most on World’s Hardest Game 2 (−22) and Tetris (−19).Source: Table 13 · p. 23, §A.8 · p. 23, Figure 6 · p. 24
- At least one of four code runs solves 76 tasks, compared with 40 for direct control; 41 are solved only by code and five only by direct control.Neither condition solves 89 tasks.Source: Table 13 · p. 23, §A.8 · p. 23
- With the model fixed on the 31-task subset, code development has higher mean progress than RTC at 6s on 20 trajectory-start tasks and 22 single-frame-start tasks.On 170 tasks, the collaborative team’s best progress exceeds independent best-of-four on 27 tasks, ties on 95, and is lower on 48.Source: §A.8 · p. 23
B Training RTC-2B
- RTC-2B training uses three stages: a separate browser-game collection with host-side scores, supervised fine-tuning from Qwen3.8-27B demonstrations, and online reinforcement learning.All training precedes evaluation on different GameWorld games with a continuously running clock and official task scoring.Source: B Training RTC-2B · p. 24
B.1 Training Games
The training pipeline selects browser games with programmatically checked runtime conditions and source-analyzed score signals, then trains RTC-2B through supervised imitation and request-level reinforcement learning. The protocol fixes training-time delay and assigns rewards to the actions each request actually controlled.
B.1 Training Games
- The collection starts from 2,522 js13kgames titles, then filters for runtime compatibility and reliable, performance-linked scores; 395 games pass.A coding agent identifies objectives, controls, game boundaries, and a canonical score; the strict filter excludes games with unsuitable runtime dependencies or reward properties.Source: §B.1 · p. 24, Table 14 · p. 25
B.2 RL Interaction Protocol
- RL pauses the browser during generation and advances 15 committed ticks before appending a chunk, fixing observations at least three seconds old.Episodes start with 15 neutral ticks, plan for 30 actions, and allow at most 32 requests or 960 ticks; evaluation instead uses actual latency while the game runs.Source: §B.2 · p. 25
B.3 Supervised Fine-Tuning
- SFT retains 31,626 complete, syntactically valid requests from 382 Qwen3.8-27B episode archives, without filtering for score or success.The supervision includes 2,852 valid requests from episodes that ended in harness failure, so the checkpoint imitates valid RTC behavior rather than only successful play.Source: §B.3 · p. 25
B.4 Online Reinforcement Learning
- Request-level RL rewards score changes over actions actually controlled, masks ambiguous or negative deltas, and compares valid request returns across episodes at matching indices.Valid zero deltas remain; negative deltas are masked because the score reader cannot distinguish a game penalty from a hidden reset. Group-relative advantages use peer episodes with valid requests at the same index.Source: §B.4 · p. 26
B.5 Training and Evaluation Conditions
RTC-2B training uses fixed simulated delays and generic, uninstructed games, while evaluation transfers the controller to continuously running GameWorld tasks with instructions and actual latency. The appendix describes a separate effort to specialize the controller’s weights on Stack.
B.5 Training and Evaluation Conditions
- Evaluation tests transfer from fixed-delay training on generic, uninstructed games to continuously running, instructed GameWorld tasks with actual latency.Training and evaluation both use a 200 ms tick and queue-conditioned visual context; the host score reader supplies training rewards only.Source: §B.5 · pp. 26–27, Table 15 · p. 27
C Specializing the Controller’s Weights: Stack
- On Stack 27_05, GPT-6 Astra led a single-game weight-specialization effort involving an independent simulator, generated supervision, controller training, and iterative procedure revisions.Humans adjusted the effort only between stages.Source: C Specializing the Controller’s… · p. 27
C.1 Original-Game Evaluation
On the original Stack game, specialized controller weights make modest progress and no controller completes the tower; simulator experiments likewise fall short of the goal. The same-game comparison reports higher progress for code development, and a 2048 program illustrates a separate visual code policy.
C.1 Original-Game Evaluation
- 3.25 layers was the specialized RL controller’s mean Stack height, versus 2.25 for specialized SFT and 1.75 for RTC-2B; no controller completed the tower.The four-game original-game evaluation includes actual inference latency; RL improved on its SFT parent on three seeds and tied on one.Source: §C.1 · p. 27, Table 16 · p. 27
C.2 Simulator and Interface
- The Stack simulator reproduces sliding, bouncing, dropping, trimming, and failure at zero overlap, but uses no original-game assets, levels, or trajectories.The controller receives RGB requests rather than block coordinates, speed, reference actions, or rewards; the simulator advances committed actions during a three-second generation delay.Source: §C.2 · pp. 27–28
C.3 Supervised Specialization
- On a second seed group with varied layouts, the visual-clock checkpoint reaches 5.88 layers against 3.63 for its parent.The checkpoint followed full-parameter SFT on mixed examples and further training on examples varying block speed and scene layout; several other explored procedures did not improve on the checkpoints.Source: Table 17 · p. 28, §C.3 · p. 28
C.4 Reinforcement Learning in a Simulator
- On eight held-out simulated seeds, the audited-reward controller reaches 4.00 layers, versus 3.75 for the relative-advantage run and 3.50 for the parent; none completes the tower.The audited-reward adapter reaches 3.25 layers in the original game. It remains active, but its precision stays below what the tower requires.Source: §C.4 · p. 29
- Code development averages 43.55% progress across Stack’s five tasks, versus 6.75% for RTC-2B; on task 27_05, the audited-reward controller reaches 10.83%.On task 27_05, code development averages 16.67% progress and reaches 36.67% in its best of four runs. Hand-written reference controllers complete 16 of 16 games with true state and 14 of 16 with RGB-only input under fixed delay.Source: §C.4 · p. 29
D An Interpretable Code Policy for 2048
- A 153-line 2048 program uses visual parsing and a compact action rule to complete the task’s 1024-point objective without runtime generative-model or neural-vision calls.The program estimates the board from pixels, retains its own state, and acts during the live game loop.Source: D An Interpretable Code Policy for 2048 · p. 29
D.1 From Pixels to a Decision Rule
The 2048 policy estimates the board from RGB pixels, reconciles observations with its predicted previous move, and selects actions using a local move model. Recorded execution shows the target score was reached well before the end of the episode, while computation remained much faster than the game tick.
D.1 From Pixels to a Decision Rule
- The policy samples median RGB values from 3 × 3 patches in each cell, matches them to a stored palette, and reconciles the resulting board with its previous move prediction.This produces a visual board estimate from pixels alone and helps handle unknown cells or potentially stale images.Source: §D.1 · p. 29
- For the estimated board, the policy favors up and left, chooses the direction with more merges when both are valid, alternates on ties, and falls back to other moves or waiting.In the Figure 7 example, moving up predicts a merge while moving left leaves the board unchanged, so the program emits press(up).Source: §D.1 · p. 29, Figure 7 · p. 30
D.3 Recorded Gameplay and Execution Timing
- The recorded 60-second episode first samples the 1024-point target at 25.57 seconds and ends with a sampled score of 3192.The target is sampled at 25.57 seconds; Figure 8’s 59.8-second screenshot shows 3176 before the final host score sample.Source: §D.3 · p. 31, Figure 8 · p. 32
- Policy round-trip time is 5.47 ms at the median, but input dispatch waits until the next 200 ms tick after the observation.In Figure 9, computation takes 4.96 ms and input send occurs 201.01 ms after the observation tick; dispatch delay includes the wait for the next tick.Source: §D.3 · p. 31, Figure 9 · p. 32
E RTC Timing Analysis and Context Construction
The section formalizes how queued actions cover inference latency and constrain response to new visual evidence, then describes the request context and traces peer-informed code changes.
E.1 Action Coverage and Response Windows
- Under periodic steady-state assumptions, continuous coverage requires P ≥ L and C = T ≥ L, giving a planning horizon Hplan = P + C ≥ 2L.The analysis assumes constant latency, fresh observations, a nonempty queue, and no resets or extra scheduling or actuation delays.Source: §E.1 · pp. 32–33
- A timely correction requires W(e) ≥ D(e); when P = C = T = L, a response window of at least 2L covers every event-arrival phase in the idealized model.New evidence can affect actions only after the committed prefix, and longer delays postpone that opportunity.Source: §E.1 · p. 33
E.2 Visual Context and Request Scheduling
- Controller requests combine up to seven frames spanning 18 seconds with recent input and reset events, queued actions, and timing and execution context.The context distinguishes dispatched or failed-to-dispatch inputs from actions still awaiting execution; prior model reasoning is not carried forward.Source: §E.2 · p. 33
- The shared trajectory bundle is collected once per task using 15-tick chunks for up to 60 seconds and 20 requests, without an artificial response floor.It contains public visual observations and executed-input and timing records, but excludes raw model replies and private evaluator scores.Source: §E.2 · p. 34
F Peer Evidence and Changes in Development Direction
- The peer-evidence analysis traces adoption and correction cases from prior approach through inspected evidence, code change, and execution outcome.Cases are selected for traceability; developers receive public screenshots, input and timing records, and runtime feedback, while private evaluator scores are used only in the analysis.Source: F Peer Evidence and Changes in… · p. 34
F.1 Snake: Learning by Reviewing a Successful Peer
- In one Snake session, two submissions reached two and three apples before the output-token budget ran out, while repeated offline edits received no third online test.The offline revisions revisited head–tail identification, turn timing, and pixel thresholds.Source: §F.1 · p. 34
- After D adopted A’s grid-occupancy tracking and search, it reached a final successful submission despite an intervening lookahead regression.D’s earlier controller reached only one apple; the later lookahead change regressed to four apples before D restored the prior approach.Source: §F.1 · pp. 34–35
F.2 NS-Shaft: Correcting a Persistent Waiting Rule
A peer critique led branch A to replace a waiting rule that conflicted with remaining supported on a platform. Later debugging produced a successful run, though further changes also caused regressions.
F.2 NS-Shaft: Correcting a Persistent Waiting Rule
- After review, submission 5 removes aligned-target waiting branches and adds a standing-state rule to move off the current support.The critique identified that waiting conflicted with the player still being supported by the current platform.Source: §F.2 · p. 35
- 18.330 seconds on submission 7 followed regressions and steering corrections; submission 8 then fell to 13.997 seconds.Survival rose from 6.793 seconds on submission 4 to 12.014 on submission 5, then fell to 2.525 on submission 6.Source: §F.2 · p. 35, Figure 11 · p. 35
- Figure 12 contrasts the supported player near the top of the scene in submission 4 with later gameplay in submission 7; survival durations come from evaluator run summaries.The selected frames show scenes before and after revision.Source: Figure 12 · p. 36
Related papers
This paper cites
- Voyager: An Open-Ended Embodied Agent with Large Language Models2023
- ChatDev: Communicative Agents for Software Development2023
- Dota 2 with Large Scale Deep Reinforcement Learning2019
- GameWorld: Towards Standardized and Verifiable Evaluation of Multimodal Game Agents2026
- Gym-Anything-RT: Scaling Real-Time Environments for Vision-Language Agents2026
- PyRUA-REAL: Robot Exploration and Adaptive Learning through RSI in the Real World2026