# Codex writes control programs from simulator code, rivalling reinforcement learning

A preprint finds that OpenAI's Codex coding agent, given a simulator's source code, can write readable control programs that match or beat standard reinforcement learning on many benchmark tasks, using far less trial and error. Fine-grained physical control remains the exception.

- Category: Agents
- Readiness level: II (Benchmarked) on Science Underway's four-step scale, as proposed
- Published: 2026-11-29
- Editor: Stefan Perdal
- URL: https://scienceunderway.com/articles/codex-writes-control-programs-from-simulator-code-rivalling-reinforcement-learni

## The study

Do We Still Need Reinforcement Learning When We Can Read the World Model? (preprint, not peer reviewed). arXiv 2611.34656. https://arxiv.org/abs/2611.34656

## At a glance

- What it shows: An AI coding assistant read the code of simulated games and control tasks, then wrote its own rule-based programs to play them. These programs often did as well as, or better than, systems trained the usual way by long trial and error, and needed far less practice.
- What it does not show: It does not show that trial-and-error training is obsolete. The programs did worse on tasks needing delicate physical control, and nothing was tested on real machines or on systems whose code is incomplete or wrong.
- Why it matters: Where a system is defined in software, such as a simulator or a digital twin, reading its rules may be a cheaper route to a working controller than training one. The result is also a readable program that people can inspect and fix.

## What the study shows

Reinforcement learning, where a model learns by trial and error from rewards, usually needs huge amounts of practice. The authors asked whether that practice is needed when the environment's own source code can be read. They call this code a readable world model: a description of how the environment reacts to each action.

They gave OpenAI's Codex coding agent, running a model the paper calls gpt-6-astra, the code of each environment. The agent wrote a control program, tested it in the environment or, in offline tasks, checked it against recorded data, and revised it, with no human in the loop. The finished programs saw only the same observations as the trained systems they were compared with.

The tests covered StarCraft unit battles (SMAC), multi-agent coordination, grid navigation (MiniGrid), landing and walking tasks (Box2D), and offline tasks from D4RL and BabyAI, where only a fixed dataset is available. The authors report that the written programs beat the standard model-free reinforcement learning baselines in 15 of 16 online tasks.

The programs also needed far less experience to reach set targets. On one MiniGrid task they needed under 1,800 environment steps, against 400,000 for DreamerV3, a leading model-based method. On the two-legged walker the saving was small.

Results were mixed on offline data. The programs scored best on maze navigation and kitchen tasks, but clearly worse on simulated running robots (MuJoCo) and robot hands (Adroit). Where precise continuous control matters, trained systems still led.

Reading the code itself helped, but not everywhere. Compared with an agent given only task descriptions, code access raised scores in 8 of 16 online tasks, lowered them in 3 and tied in 5. The largest gains came on harder control tasks and on an offline kitchen task with few successful examples.

This is a preprint and has not been peer reviewed.

## Our reading

In our reading, the headline question in the paper's title is answered more modestly than it is posed. The study shows that for many standard benchmarks, a strong coding agent can write a good controller by reading the rules. It does not show that reinforcement learning is unnecessary, and the authors say as much in their discussion.

The practical point is about where effort goes. Trained systems spend millions of steps discovering what the code already states. The coding agent spends from about a thousand to a few hundred thousand steps checking and fixing a program it reasoned out. For a team that owns its simulator, this changes the first thing to try.

A concrete example: a warehouse operator with a software model of its conveyor and picking system could ask a coding agent to write dispatch rules from that model. Engineers could then read, test and adjust those rules, rather than train an opaque policy for weeks. The study does not test such a system, so this remains an extrapolation.

The rest of the article (what it means, limits, what to watch) is free for members: https://scienceunderway.com/articles/codex-writes-control-programs-from-simulator-code-rivalling-reinforcement-learni

## How this was made

An AI model read the study and wrote this article in the structure Science Underway uses. An editor reviewed it and approved it for publication. Check the original study before you rely on the details.

---
Source: Science Underway, https://scienceunderway.com/. Please link to the article when you cite it.
