Dreaming in Code for Curriculum Learning in Open-Ended Worlds

Konstantinos Mitsides, Maxence Faldor, Antoine Cully

Introduction

Open-ended learning frames intelligence as an emergent property of continual interaction with an ever-expanding space of environments. While recent advances have utilized foundation models to programmatically generate diverse environments, these approaches often focus on discovering isolated behaviors rather than orchestrating sustained progression. In complex open-ended worlds, the massive combinatorial space of possible challenges makes it difficult for agents to discover sequences of experiences that remain consistently learnable.

To address this, researchers have introduced Dreaming in Code (DiCode), a novel framework that uses Large Language Models (LLMs) to synthesize executable Python code for training environments. By generating structural variations of a world rather than merely tuning simple parameters, DiCode creates a "ladder" of increasingly difficult challenges. This enables Reinforcement Learning (RL) agents to master complex, long-horizon tasks in open-ended environments where traditional methods fail.

The Competence Gap in Open-Ended Learning

In the quest for "open-ended intelligence," the goal is to train agents capable of learning indefinitely in vast, complex worlds. However, agents frequently hit a performance plateau. They master basic survival skills but fail to discover the complex sequences required for late-game goals, such as advanced combat or deep exploration. The "competence gap" between easy and hard tasks is simply too wide for standard exploration strategies to bridge.

Existing solutions typically rely on Unsupervised Environment Design (UED), where a "teacher" algorithm generates levels to keep a "student" agent in a "Goldilocks zone" of difficulty. The limitation of most UED methods is their reliance on tuning a few low-dimensional parameters (e.g., the number of enemies or grid layouts). In truly open-ended worlds, bridging the gap to complex behaviors requires structural changes—such as modifying game logic, providing specific starting equipment, or creating intermediate milestones.

The DiCode Framework

DiCode positions a Foundation Model (FM) as an environment architect, shifting the paradigm from parameter tuning to programmatic scaffolding.

  1. Programmatic Environment Design: Instead of merely rearranging assets, the FM writes executable Python code that interacts with a fixed world engine. This code can algorithmically specify world topology, redefine interaction rules (like combat damage), and set specific success criteria.
  2. The Generation Cycle:
  3. Archive & Selection: Levels are stored in a directed graph. The system selects a "parent" level based on learnability—prioritizing tasks the agent can solve intermittently but has not yet mastered.
  4. Dreaming: The FM receives the parent level's description and the agent's current performance profile. It "dreams" a new level by writing a natural language description, then translating it into executable code.
  5. Compilation Check: To ensure stability, the code is automatically checked for errors before being added to the training batch.
  6. Closed-Loop Curriculum: The agent trains on a mixture of the target environment, newly generated "stepping stone" levels, and replayed levels from the archive.
  7. Adaptive Bonus: To prevent the agent from ignoring the FM's designed goals in favor of easy "early-game" rewards (like eating food), the system provides an adaptive reward bonus for completing the level-specific task.

Experimental Setup

The primary benchmark for DiCode is Craftax, a challenging, JAX-accelerated open-ended world inspired by games like NetHack and Minecraft. Craftax features rich mechanics, a deep technology tree, and multiple dungeon floors.

The researchers compared DiCode against state-of-the-art UED methods, including Prioritized Level Replay (PLR), Sampling for Learnability (SFL), and standard Domain Randomization (DR). Notably, the framework utilized the open-weights Qwen3-235B model for the FM generator, demonstrating that DiCode does not rely on proprietary APIs.

Key Insights

  • Code as Scaffolding: Code-level design allows the FM to provide targeted "scaffolding." For example, to teach an agent to fight a late-game boss, the FM might "dream" a level where the agent starts with iron armor and a sword right outside the boss room, bypassing hours of resource gathering to focus purely on the combat skill gap.
  • Spontaneous "Teacher" Strategies: The FM developed sophisticated, emergent teaching strategies. Once an agent mastered a scaffolded task, the FM would generate a version of that level with the scaffolding removed (e.g., removing a pre-built workstation), forcing the agent to generalize.
  • Reasoning Scales Curriculum: Ablation studies revealed that curriculum quality scales directly with the FM's reasoning capability. Larger models (235B vs. 30B) produced significantly more effective learning trajectories.
  • Physical Grounding: By using a fixed engine to execute the FM's code rather than letting the FM "hallucinate" a world model, all generated experiences remain physically consistent and valid.

Results

DiCode demonstrated substantial improvements over existing methods:

  • 17% Overall Improvement: DiCode achieved a mean return of 48.55, significantly outperforming the strongest baseline (41.59).
  • Breaking the 0% Barrier: On late-game combat tasks like "Defeat Gnome Warrior," all prior methods achieved a 0% success rate. DiCode achieved a 15% success rate, proving it can bridge previously intractable gaps.
  • Deeper Exploration: DiCode agents reached the second floor of the dungeon (Gnomish Mines) in 32% of episodes, compared to just 9% for the best baseline.
  • Zone of Proximal Development: The system successfully maintained the agent at a ~0.5 success rate across active training levels, confirming it consistently provided "just right" challenges.

Limitations and Future Directions

While powerful, DiCode has limitations. The FM is bounded by the "vocabulary" of the programmatic API; it can configure the world but cannot invent entirely new physical laws unsupported by the underlying engine. Additionally, like many UED methods, the learnability score can be "tricked" by inherently random or noisy levels, leading to the oversampling of uninformative tasks. Finally, implementing DiCode in a new domain requires a one-time engineering effort to create a wrapper API for the FM.

Future work may move toward measuring "learning progress" (the rate of change in success) rather than absolute success rates, helping the system better distinguish between useful stepping stones and distracting noise. Ultimately, DiCode proves that code-level environment design provides a highly practical mechanism for curriculum control in open-ended worlds.

Summary updated

BibTeX
@inproceedings{mitsides2026dreaming,
  author = {Konstantinos Mitsides and Maxence Faldor and Antoine Cully},
  title = {{Dreaming in Code for Curriculum Learning in Open-Ended Worlds}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=dctdzmYeej},
}
Figure