Abstract
Autotelic learning is the training setup where agents learn by setting their own goals and trying to achieve them. However, creatively generating freeform goals is challenging for autotelic agents. We present Codeplay, an algorithm casting autotelic learning as a game between a Setter agent and a Solver agent, where the Setter generates programming puzzles of appropriate difficulty and novelty for the solver and the Solver learns to achieve them. Early experiments with the Setter demonstrates one can effectively control the tradeoff between difficulty of a puzzle and its novelty by tuning the reward of the Setter, a code language model finetuned with deep reinforcement learning.
Introduction
Large Language Models (LLMs) are incredibly capable, but they are fundamentally "lazy" students—they are limited by the data they were trained on. They struggle to discover new concepts, invent novel solutions, or master skills that weren't well-represented in their training sets. To break this ceiling, researchers look toward autotelic learning: a setup where agents set their own goals. However, getting an AI to "invent" meaningful goals in a complex space like programming is hard. Most previous attempts were limited to simple, toy environments. The authors tackle this by grounding the learning process in the Python Programming Puzzles (P3) domain, where the "truth" of a goal is easily verified by a code interpreter rather than a subjective human or another fallible AI.
Methodology
The authors frame autotelic learning as a collaborative game between two agents:
- The Setter: An LLM (GPT-Neo-125M) fine-tuned via Reinforcement Learning (PPO) to generate Python puzzles. A puzzle is a function
fthat returnsTrueonly if a specific input or solution functiongis provided. - The Solver: An LLM that attempts to write the solution code
gfor the Setter's puzzles.
The "secret sauce" is the Setter's reward function, which balances two intrinsic motivations:
- Difficulty ($R_d$): The Setter is rewarded for finding the "Zone of Proximal Development"—puzzles that are too hard for the Solver to solve instantly, but not so hard that they are impossible.
- Novelty ($R_n$): To prevent the Setter from just repeating the same "hard" puzzle over and over (mode collapse), it is rewarded for generating code that is mathematically distant from previously generated puzzles in an embedding space.
Datasets
The system utilizes the Python Programming Puzzles (P3) benchmark, where puzzles are defined as short Python programs spanning a range from trivial string manipulations to complex algorithmic challenges. The models were initialized with weights from a GPT-Neo-125M model previously trained on a large-scale dataset of Python code (Codex-generated data).
Key Insights
- The Difficulty-Novelty Trade-off: There is a fundamental tension between difficulty and novelty. If you only reward difficulty, the AI finds one "perfect" hard puzzle and stops exploring. If you only reward novelty, the AI generates "weird" but often broken or nonsensical code. Success requires a carefully weighted balance.
- Grounding in Execution: Unlike many LLM training methods that rely on "vibes" (RLHF or LLM-as-a-judge), Codeplay uses a Python interpreter. If the code doesn't run or the logic doesn't check out, the reward is zero. This provides a "hard" objective reality for the AI to learn against.
- Automated Curriculum: As the Setter learns what the Solver finds difficult, it naturally starts generating more complex logical structures, effectively building a custom training syllabus for the Solver without human intervention.
Key Results
The researchers tested different weightings for the rewards ($w_d$ and $w_n$). Without optimization, the system produced trivial, repetitive puzzles. When focusing solely on difficulty ($w_d=1, w_n=0$), the Setter quickly learned to generate "unsolvable" puzzles (like checking if a number equals a massive constant), which provided no learning signal for the Solver.
A balanced reward scheme ($w_d=1, w_n=1$) proved to be the "Sweet Spot," producing a diverse stream of valid, increasingly complex puzzles. Under these conditions, the generated puzzles evolved from simple identity checks to more complex logical constraints involving loops, list comprehensions, and mathematical properties.
Limitations and Future Work
In this preliminary study, the Solver was kept static. The true "holy grail" is co-evolution, where the Solver also learns from the Setter's puzzles, pushing the Setter to invent even harder ones in a perpetual arms race of intelligence. Furthermore, scaling to larger models is expected to lead to the discovery of much more sophisticated programming concepts. Finally, future work aims to find ways to "steer" this open-ended discovery toward problems that have real-world utility, as AI-discovered puzzles aren't always useful or interesting to humans.
Summary updated