Code2Worlds-2: Physically Plausible Agent Harness for Embodied World Simulation
Organizations: Equal contribution. · School of Computer Science, Peking University, Beijing 100871, China. · Project lead. · School of Computing, National University of Singapore, Singapore.
Abstract
Recent coding large language models (LLMs) can synthesize dynamic 4D worlds from natural language, but the resulting content remains a visual artifact. It lacks physical semantics such as the collision geometry, mass, friction, inertia, and joint structure, required to enable it to simulate the physical world, and its dynamics are scripted to look plausible rather than designed to execute. What is needed is an executable world: one that a physics engine can load and step, resolving contact physically. We present Code2Worlds-2, an extension of Code2Worlds that turns 4D world generation into an embodied world simulation. We keep the original dual-stream generation pipeline intact and append two modules. First, a SimReady Scene Compiler that turns a generated visual scene into a simulator-compatible representation: it assigns collision meshes via convex decomposition, estimates physical attributes with a vision-language model, infers a lightweight support graph, instantiates the engine's contact, friction, and dynamics constraints, and applies a gravity settling pass, before exporting the scene as MuJoCo MJCF. Second, a Simulator-in-the-Loop 4D Refiner that implements an automated agent harness-a compile, simulate, critique and refine loop-that converts visual dynamics into executable rigid and articulated dynamics and evolves the physical settings rather than only the code, replacing the purely visual motion critic with a simulator critic that inspects penetration depth, collision pairs, stability, contact forces, joint limits, and robot reachability. We further propose SimCode4D, a state-based benchmark with five task templates for evaluating embodied simulation. Experiments on SimCode4D and across natural, indoor, industrial, urban, and service scenes show that Code2Worlds-2 produces physically plausible, simulator-compatible, and robot-interactable scenes.
Figures & tables
| Measure | Result | Evidence and acceptance criterion |
| Artifact readiness | ||
| Registered cases with complete contract quartets | 15/15 | Three cases per domain; schema and cross-references are valid |
| Archived and verified authoring source scenes | 12/15 | Compiled M1 worlds and source pointers are retained for all 15 cases |
| Independently loadable M1 worlds | 15/15 | All M1 world endpoints load under the frozen MuJoCo build |
| Executable runtime packages | 15/15 | All task-runtime endpoints load and execute |
| Case-specific probe–validator pairs | 15/15 | Unique hash-bound paths are frozen for every case |
| Method / stage | Build | Task | Physical | RTS | Repairs |
| Fixed-source progression | |||||
| Default export | 33/36 | 63/180 | 75/180 | 45/180 | 0 |
| SimReady scene compilation | 33/36 | 62/180 | 93/180 | 50/180 | 0 |
| SimReady scene compilation feedback repair | 34/36 | 69/180 | 108/180 | 60/180 | 1.61 |
| Matched-prompt comparison | |||||
| Code2Worlds [ 1 ] | 3/3 | 5/15 | 0/15 | 0/15 | – |
| Task family | Cases | Default | Enriched | Repaired |
|---|---|---|---|---|
| Navigation | 4 | 45/60 | 35/60 | 35/60 |
| Pick/transport | 2 | 0/30 | 14/30 | 14/30 |
| Dynamic | 6 | 0/90 | 1/90 | 11/90 |
| Ablated variant | Measure | Full | Ablated |
|---|---|---|---|
| Uniform attributes | RTS | 69/75 | 54/75 |
| Physical pass | 69/75 | 55/75 | |
| Single convex hull | RTS | 15/15 | 10/15 |
| Physical pass | 15/15 | 11/15 | |
| No pose stabilization | Stable | 8/12 | 1/12 |
| Penetration-safe | 11/12 | 0/12 |
| Feedback rule | Build | Task | Physical | RTS |
|---|---|---|---|---|
| No repair | 33/36 | 62/180 | 93/180 | 50/180 |
| Visual only | 36/36 | 84/180 | 112/180 | 67/180 |
| State only | 36/36 | 96/180 | 116/180 | 81/180 |
| Fused, fixed budget | 35/36 | 81/180 | 99/180 | 62/180 |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Case | Domain | Robot | Task family | Goal (frozen prompt) |
|---|---|---|---|---|
| Indoor-1 vacuum living room | Indoor | mobile vacuum | Obstacle nav. | Drive the vacuum east through the living-room corridor, enter the frozen goal, and remain stopped for 0.5 seconds. |
| Indoor-2 go2 living room | Indoor | Unitree Go2 quadruped | Obstacle nav. | Traverse the living room east with the Go2, stay in the frozen corridor, enter the goal, and stop. |
| Indoor-3 vacuum west | Indoor | mobile vacuum | Obstacle nav. | Drive the vacuum west through the indoor corridor, enter the frozen goal, and remain stopped for 0.5 seconds. |
| Industrial-1 agv aisle | Industrial | four-wheel AGV | Obstacle nav. | Drive the four-wheel AGV east along the industrial aisle, hold the lane, enter the goal, and stop. |
| Industrial-2 agv cargo | Industrial | four-wheel AGV with welded cargo | Dynamic interaction | Transport the physically modeled cargo east with the AGV, retain the declared weld attachment, enter the cargo goal, and stop. |
| Industrial-3 weld | Industrial | UR5e welding arm | Dynamic interaction | Trace the frozen weld seam continuously with the UR5e tool tip and finish at rest. |
| Case ID | Room, target, and support | Task family | Goal criterion |
|---|---|---|---|
| E2E-LIVING-PUSH | Living room; ceramic mug on wooden side table | Contact push | tabletop displacement |
| E2E-DINING-TRANSPORT | Dining room; ceramic mug on dining table | Pick and transport | tabletop transfer and lift |
| E2E-KITCHEN-PUSH | Kitchen; ceramic bowl on kitchen worktop | Contact push | worktop displacement |
| Case | Target/support | C2W-A | +M1/M2 | SS |
|---|---|---|---|---|
| Living | Mug/side table | |||
| Dining | Mug/dining table | |||
| Kitchen | Bowl/worktop |
| Seed | Mass scale | Friction scale |
|---|---|---|
| 401 | 1.01934 | 0.97693 |
| 409 | 0.98103 | 0.97091 |
| 419 | 1.04753 | 1.05625 |
| 421 | 0.96823 | 0.94074 |
| 431 | 0.95579 | 1.06771 |
| Case | Condition | Task | Physical | RTS |
|---|---|---|---|---|
| Living | C2W-A | 5/5 | 0/5 | 0/5 |
| +M1/M2 | 5/5 | 5/5 | 5/5 | |
| SS | 0/5 | 5/5 | 0/5 | |
| Dining | C2W-A | 0/5 | 0/5 | 0/5 |
| +M1/M2 | 5/5 | 5/5 | 5/5 | |
| SS | 0/5 | 5/5 | 0/5 |
Physics-Based Simulation
Physics-based simulation models physical systems with equations and numerical solvers, increasingly augmented by learned models for speed and control.
See all 227 papers