AI Generates Game Content by Evolving Program Code

Matthew Siper, Ahmed Khalifa, Julian Togelius· August 19, 2026 View original

Key takeaways

  • LLMs can evolve complete Python programs to generate procedural content for games.
  • Continual Abstraction Discovery (CAD) extracts reusable primitives from high-performing programs.
  • CAD significantly improves the efficiency and quality of evolutionary program search.
  • Learned libraries of abstractions are widely adopted and rediscover essential utilities.

Who benefits

GamingEntertainmentCreative ArtsSoftware DevelopmentVirtual Reality

Summary

This research explores procedural content metageneration using large language models to evolve complete Python generators for games like Sokoban and Zelda. It introduces Continual Abstraction Discovery (CAD), which extracts reusable primitives from high-fitness programs to improve evolutionary program search.

The advent of large language models (LLMs) has opened new avenues for content generation, particularly in the realm of executable programs. Instead of generating individual game levels or assets, this research investigates an approach where LLMs are used to search directly over procedural content generators themselves. This means the AI evolves entire Python programs that can then create game content. The study applied this method to classic games such as Sokoban, Zelda, Dangerous Dave, and Lode Runner. During each experimental run, complete Python generators were evolved through a process involving language-model mutation and crossover. A key innovation introduced is Continual Abstraction Discovery (CAD). CAD works by identifying and extracting reusable primitives—or fundamental building blocks—from programs that demonstrate high fitness (i.e., generate good content). These primitives are then incorporated into a run-specific helper module, making them available for subsequent program evolution. A comprehensive experiment demonstrated that CAD significantly improved the mean final best fitness across all tested domains and API comparisons. The learned libraries, containing these discovered abstractions, were widely adopted by later programs and consistently rediscovered essential utilities like validation, reachability, and structural components. These findings strongly suggest that the ability to discover and reuse primitives is crucial for enhancing evolutionary program search in the context of content generation.

Why it matters

Game developers, creative technologists, and AI engineers can leverage this technique to automate and scale the creation of diverse and complex content, reducing manual effort and fostering innovation in game design and other generative applications.

How to implement this in your domain

  1. 1Explore using LLMs for generating executable code snippets or full programs for content creation.
  2. 2Investigate integrating evolutionary algorithms with LLMs to refine generated code based on fitness criteria.
  3. 3Develop mechanisms for identifying and abstracting reusable code patterns from successful generative programs.
  4. 4Apply procedural content generation techniques to automate level design, asset creation, or narrative generation in games.
  5. 5Benchmark the efficiency and creativity of AI-generated content against human-designed alternatives.

Original post by Matthew Siper, Ahmed Khalifa, Julian Togelius

"arXiv:2608.17947v1 Announce Type: new Abstract: Large language models can generate executable programs, which makes it possible to search directly over procedural content generators rather than individual levels. We study this approach in Sokoban, Zelda, Dangerous Dave, and Lode…"

View on X

Originally posted by Matthew Siper, Ahmed Khalifa, Julian Togelius on X · view source

Want to go deeper?

Turn these trends into skills with Learnijoy's hands-on AI & tech courses.

Explore courses

More in AI Engineering & DevTools