JA EN
LearnAgents
·★ MEMBER·PAPER·13 min read

Paper Walkthrough: Code as Worlds — An Agent That Writes the World Down as Runnable Code

A close read of Code-as-World, which represents physical worlds as executable code and searches for world hypotheses through a propose–execute–render–verify loop. The three parts of an EWR, the agentic discovery loop, the QuantiPhy results, and the limits the paper itself admits.

ModalityimageTaskagents

Code as Worlds: Agentic Discovery of Executable World Representations for Physical Reasoning

Primary source — what this article is built on

undefined2026-08-27undefined2026-09-03same month

Code as Worlds: Agentic Discovery of Executable World Representations for Physical ReasoningHanyang Wang, Yimo Cai, Weiliang Chen et al. · 2026-08-27 · v1arXiv:2608.27549Paper page·PDF
undefined

Physical understanding and reasoning depend on forming compact and generalizable representations of the world. While modern vision-language models can recognize and explain diverse physical events, they often lack explicit representations of the underlying mechanisms-such as object states, physical parameters, and governing dynamics-needed for reliably reasoning how the world evolves and responds to interventions. In this work, we introduce Code-as-World, a paradigm that represents physical worlds through executable world representations. By expressing physical composition, dynamic evolution, and visual appearance as executable code, Code-as-World provides a compact, quantitatively grounded, and controllable abstraction of the physical world. To construct such representations from multimodal observations, such as natural-language descriptions or real-world videos, we develop an agentic discovery loop inspired by abductive reasoning, where an agent proposes, executes, renders, verifies, and iteratively refines executable world hypotheses. As a concrete application, we use verified executable worlds to provide scalable physical supervision for training vision-language models on quantitative physical reasoning. Experiments show that Code-as-World-VL achieves state-of-the-art performance on QuantiPhy and surpasses leading proprietary models, highlighting the potential of executable world representations as a scalable foundation for physical intelligence.


"What Happened" and "Why It Happens" Are Different Problems

The paper this article walks through is "Code as Worlds: Agentic Discovery of Executable World Representations for Physical Reasoning" (arXiv:2608.27549, published 27 August 2026 — a technical report from MirroS, Tsinghua University, Peking University and Nanyang Technological University).

Its claim, in summary: physical understanding and reasoning depend on being able to form compact, generalizable representations of the world. Today's vision-language models (VLMs) can recognize and explain a wide range of physical events, but they carry no explicit representation of the underlying machinery — object states, physical parameters, governing dynamics — so they cannot reliably reason about how the world will evolve or how it will respond to intervention. The paper therefore proposes Code-as-World, which represents a physical world as an executable world representation. Write physical composition, dynamic evolution and visual appearance as code, and you get an abstraction of the world that is compact, quantitatively grounded and controllable. To build such a representation from multimodal observations — a natural-language description, or a real video — the authors design an agentic discovery loop that proposes, executes, renders, verifies and revises. Finally, verified executable worlds are used as supervision to teach VLMs quantitative physical reasoning.

The framing in §1 is the clearest part: the phenomenon–mechanism dichotomy. A phenomenon states what happened; a mechanism explains why, and predicts what would happen under different conditions. A play-by-play commentator is a master of the former, which says nothing about their ability to draw the blueprint.

Every Existing World Representation Has a Hole in It

Section 2 lines up the three established families.

Pixels (video generation). If you only optimize future-pixel prediction, the model never has to decide whether a change on screen came from camera motion or object motion, or whether an object was briefly occluded or ceased to exist. A visually plausible future is not necessarily a physically correct future.

3D (reconstruction, inverse graphics). Forcing a model to recover geometry, viewpoint and appearance is a strong constraint, but reconstructability does not imply interpretability. Recovering an object's 3D shape does not explain why it falls once its support is removed.

Natural language. "A person picks up a cup" is an excellent abstraction — it keeps entities, actions and relations while discarding clutter. But precise geometry, trajectories, contact relations and physical parameters are hard to encode in a handful of discrete tokens. Language is a semantic interface, not a complete physical state.

The strengths are complementary, the paper argues. What is needed is a representation that is semantic like language, structured like reconstruction, and able to model temporal evolution like a generative model.

Writing the World as Runnable Code

Hence Code-as-World. Code is a structured, compositional abstraction that holds entities, relations, physical parameters and events explicitly as operations over states (§3). Concretely, an Executable World Representation (EWR) has three components (§3.1).

p=(C,E,A)Pexecp=\left(\mathcal{C},\mathcal{E},\mathcal{A}\right)\in\mathcal{P}_{\mathrm{exec}}
(1)

Plainly: a single world pp can be written as a triple — what is in it (C\mathcal{C}), how it changes (E\mathcal{E}), and how it looks (A\mathcal{A}). Here Pexec\mathcal{P}_{\mathrm{exec}} is the space of all valid executable worlds.

What the equation says, in words: do not hold a world as one picture or one video — hold it as three separate documents, its contents, its motion and its look. Only the three bundled together make an executable world, and Pexec\in\mathcal{P}_{\mathrm{exec}} is the condition that the bundle is in a form a simulator can actually run.

The split pays off because each component can be inspected, edited and executed independently. Section 4.3.2 shows the payoff directly: change only the initial velocity direction of a bowling ball and get a different trajectory; re-render the same collision from a global view or from either car.

FIG 1Iterative descent into a valley — where you start decides which valley you land in, which is exactly how the discovery loop can settle on a "locally plausible" world

Discovery Is a Loop, Not a One-Shot Guess

Recovering this representation from incomplete observations is fundamentally an inverse problem. The paper reaches for abduction: searching, from noisy and incomplete evidence, for the hypothesis that best explains it while obeying a principle of simplicity — the way scientific discovery has proceeded from heliocentrism to Newton's laws (§1, §4.2).

So world representation is formulated as an agentic discovery loop rather than a single prediction. Because code is executable, each representation can be treated as a testable world hypothesis. One iteration has five stages (§4.2, Algorithm 1):

  1. Propose — update the EWR from the evidence η\eta, the current hypothesis, and the previous round's feedback Δ\Delta
  2. Instantiate — compile it into simulator-ready parameters θ\theta
  3. Execute — run it to get a full state trajectory τ\tau, with contacts, collisions and event outcomes explicitly recorded
  4. Render — turn τ\tau into predicted observations; for video input, also project into depth maps, masks and image-plane trajectories
  5. Verify — compare prediction against evidence at selected key frames and aggregate the discrepancies into Δ\Delta

Δ\Delta then tells the agent locally which component to revise next. The loop terminates when the current EWR explains the input sufficiently well and parsimoniously; if the iteration budget runs out first, the hypothesis is rejected.

Evidence construction splits by modality (§4.1). In the text-driven path, the agent extracts entities, spatial relations, physical events and intended outcomes from the prompt, then fills in the geometry and camera settings that text never pins down using physical priors and reasonable defaults. In the video-driven pat

What's behind this

§

Members-only from here

371 walkthroughs, 26 textbook chapters, 48 student units and 6 close readings — all included for $4.99/mo, with three new explainers every day. Cancel any time; access runs to the end of the period.

Already a member? Sign in to keep reading

References

  1. Hanyang Wang, Yimo Cai, Weiliang Chen, Jiawei Chi et al.. (2026-08-27) Code as Worlds: Agentic Discovery of Executable World Representations for Physical Reasoning. arXiv:2608.27549Paper page·PDF

This article is written from the source paper above. Where they differ, the original is authoritative.

Comments

Sign in to comment