AI Procedural Level Generation for Indie Games (2026 Guide)
How to use AI tools for procedural level generation in indie games — covering ML-agents, wave function collapse, and LLM-based dungeon design for Unity and Godot.
The real state of AI level generation in 2026
Procedural level generation isn't new — roguelikes have used it for decades. What's new is using AI models to make PCG smarter: levels that adapt to player behavior, that feel authored rather than random, and that can be generated from natural language descriptions.
This guide covers the practical options available to indie developers right now, from no-code tools to ML-agent setups.
Approach 1: LLM-based level description (easiest)
The simplest AI-assisted level generation uses a language model to produce structured level data from a description.
The workflow: 1. Define your level format as JSON (rooms, connections, enemy types, item placements). 2. Write a system prompt that teaches the LLM your format. 3. Pass a design brief and receive a level JSON. 4. Parse it in Unity/Godot and instantiate the prefabs.
Example system prompt for a dungeon RPG: ``` You are a dungeon level designer. Generate a dungeon level in JSON format. Format: {"rooms": [{"id": 1, "type": "start|combat|treasure|boss|corridor", "enemies": [], "items": [], "connections": [2,3]}]} Rules: 1 start room, 1 boss room, 4-8 combat rooms, 1-2 treasure rooms. The boss room must not be directly connected to start. Design brief: [USER INPUT] ```
What it's good at: Theming, narrative coherence, special event placement. What it's bad at: Precise spatial layouts — LLMs don't reason about 2D geometry well.
Tools to use: ChatGPT API (GPT-4o), Claude API, or a local Ollama model for free generation.
Approach 2: Wave Function Collapse (most reliable for tiles)
Wave Function Collapse (WFC) is an algorithmic approach that generates tile maps by learning constraints from example levels you provide. It's not "AI" in the neural network sense, but it's the gold standard for tile-based games.
Unity implementation: - [mxgmn/WaveFunctionCollapse](https://github.com/mxgmn/WaveFunctionCollapse) — original implementation - [Boris-the-animal/WFCUnity](https://github.com/Boris-the-animal/WFCUnity) — Unity port with inspector
Godot implementation: - Built-in WFC support is available in Godot 4.2+ via the `WFCSolver` addon.
AI enhancement: Generate new tile constraint sets using Stable Diffusion to create the example tiles, then let WFC handle the spatial logic.
Approach 3: ML-Agents for adaptive difficulty (most advanced)
Unity's ML-Agents toolkit lets you train agents to test your levels. You can use this to: - Automatically identify impossible sections - Balance enemy density based on player skill telemetry - Generate challenge curves that adapt to playtester behavior
Setup: 1. Install [Unity ML-Agents](https://github.com/Unity-Technologies/ml-agents). 2. Define an observation space (player health, kill rate, time per room). 3. Define a reward function (completing the level without dying = positive reward). 4. Train an agent to navigate your generated levels. 5. Use agent failure data to identify and fix broken level configurations.
This is overkill for small projects but invaluable for roguelikes where level quality is the product.
Approach 4: AI-assisted hand-crafted levels
The most practical approach for most indie developers: use AI to help design levels rather than generate them entirely.
Useful prompts: - "Here is my dungeon level JSON. Suggest 3 improvements to pacing and challenge curve." - "I want a tutorial level for a platformer game. List 10 mechanics I should introduce, in order." - "Generate 5 variations of this room layout with different enemy compositions: [JSON]"
Tools: ChatGPT, Claude, or Cursor's AI chat for real-time design feedback.
Free tools summary
| Tool | Platform | Approach | Cost | |------|----------|----------|------| | ML-Agents | Unity | Reinforcement learning | Free | | WFC (community ports) | Unity/Godot | Constraint-based PCG | Free | | ChatGPT API | Any | LLM level descriptions | Pay-per-use | | Ollama + Llama 3 | Any | Local LLM generation | Free | | Cursor AI | Code editor | Design iteration help | Free/paid |
Starting recommendation for solo devs
- Week 1: Implement WFC for tile map generation using community examples.
- Week 2: Add LLM-based event and enemy placement for narrative variety.
- Week 3: Play-test and use ML-Agents failure data to identify bottlenecks.
See [AI coding tools for game developers](/categories/ai-coding-tools-for-game-developers) for tools that can help automate the implementation.