Code2Games: Enabling Coding Agents for Gaming World Generation
Organizations: School of Computer Science, Peking University · La Trobe University
Abstract
Generating a high-quality gaming world from a natural-language game intent requires joint reasoning about scene structure, spatial layout, gameplay objectives, interactive entities, and executable gameplay logic. Existing coding agents can generate individual assets, scenes, or scripts, but often struggle to maintain consistency across these components. We propose Code2Games, an agentic framework that builds a structured gaming world upon a base Blender world generated from the same game intent. Code2Games coordinates scene analysis, gameplay planning, constrained gaming-world generation, and gaming-engine customization through a shared scene-gameplay representation with persistent element correspondence. After world generation, Code2Games adapts the generated world to Unreal Engine 5 and employs an execution-guided reconstruction process that uses compilation diagnostics, runtime feedback, and gameplay test results to resolve inconsistencies arising during engine adaptation. To systematically evaluate gaming-world generation, we introduce the GameCode4D benchmark, which comprises ten fixed game prompts spanning different levels of scene and gameplay complexity. We evaluate the generated results across four dimensions: visual quality, interactive fidelity, multimodal artifact quality, and playable-game quality. Experiments demonstrate that, compared with direct gaming-world generation by coding agents and existing baseline methods, Code2Games consistently improves the visual quality and interactive fidelity of generated gaming worlds, as well as the quality of the resulting games after engine adaptation.
Figures & tables
| Method | Visual Quality | Interactive Fidelity | ||||
|---|---|---|---|---|---|---|
| IQ | Dynamic | Motion | Setting | Inter. | Physics | |
| OpenGame + Qwen3.8-Max | 62.8 | 80.5 | 94.1 | 78.5 | 65.0 | 67.0 |
| AutoUE + Qwen3.8-Max | 63.1 | 82.2 | 93.8 | 80.3 | 65.8 | 68.7 |
| Claude Code + Claude Opus 5 | 63.6 | 81.8 | 95.1 | 80.0 | 66.0 | 68.4 |
| Codex + GPT-5.6 Sol | 63.3 | 83.2 | 94.9 | 80.7 | 67.8 | 69.2 |
| Qwen Code + Qwen3.8-Max | 61.7 | 77.8 | 93.5 | 75.2 | 60.8 | 64.8 |
| Variant | Setting | Inter. | Physics | M | D | V |
|---|---|---|---|---|---|---|
| w/o Scene Representation | 78.2 | 71.5 | 72.8 | 60.5 | 49.8 | 55.0 |
| w/o Gameplay Specification | 82.1 | 69.8 | 73.5 | 62.0 | 51.5 | 56.2 |
| w/o Scene Constraints | 83.4 | 74.1 | 66.2 | 64.5 | 53.0 | 57.8 |
| Full Code2Games | 87.5 | 75.8 | 73.9 | 68.8 | 56.7 | 61.0 |
Appendix figures & tables23 assets
Supplementary material from the paper’s appendix.
Appendix
| Variant | M | D | V | A |
|---|---|---|---|---|
| Unconstrained Realization | 58.0 | 45.0 | 52.0 | 45.0 |
| + Region Compatibility | 62.0 | 50.0 | 55.5 | 50.0 |
| + Geometric Feasibility Checks | 65.0 | 53.0 | 58.0 | 53.0 |
| + Full Scene-Constrained Selection | 68.8 | 56.7 | 61.0 | 57.0 |
| ID | Prompt Content | Game Scenario | Core Interactions |
|---|---|---|---|
| 01 | Create a first-person sci-fi assault on a red desert ridgeline. Eliminate three hostile sentries and secure the remote signal relay. | FPS | Shoot; survive; secure relay |
| 02 | Create a first-person sci-fi combat sweep on a red-desert ridgeline. Track and eliminate three hostile sentries, then secure the remote signal uplink. | FPS | Track; eliminate; secure uplink |
| 03 | Create a third-person monster hunt in a dark forest. Track the Thornback, break its neck armor, defeat it, and claim the trophy. | Monster hunt | Track; break armor; claim trophy |
| 04 | Create a storm-weather Thornback hunt through a wet forest. Track the creature in low visibility, defeat it, and retrieve the trophy. | Monster hunt | Track; fight; retrieve trophy |
| 05 | Create a high-speed off-road rally through a desert oasis. Drive across uneven terrain, use nitro, pass eight checkpoints, and reach the finish. | Racing | Drive; boost; pass checkpoints |
| 06 | Create a desert-storm rally across layered dunes. Control the vehicle over changing slopes, pass eight rally gates, and complete the stage. | Racing | Steer; boost; pass gates |
| Dimension | Rating statement |
|---|---|
| Core mechanics ( ) | The central player action and its consequence are clear and functional. |
| Content depth ( ) | The world, objectives, and interactions provide meaningful progression. |
| Functional visuals ( ) | Visual assets, interface, and feedback support readable gameplay. |
| Art and presentation ( ) | The game appears coherent, complete, and engaging as a demonstration. |