Key Engineering Takeaways
- ✓ Real-world case study: 70–80% reduction in level creation turnaround time
- ✓ Constraining LLM creativity with strict JSON Schema tools to guarantee valid graph topology
- ✓ Custom Unity EditorWindow integration with Undo/Redo history and ScriptableObject serialization
- ✓ Algorithmic solvability validation: verifying jump distances, hazards, and pacing heuristics
Creating puzzle, adventure, and platformer levels is traditionally one of game development's most labor-intensive bottlenecks. Level designers manually place hundreds of tiles, configure spawn logic, tune difficulty curves, and balance collectibles—often spending 5 to 15 business days per level.
During development on *Fruit Ninja Adventure*, we built an AI-assisted level creation pipeline powered by Anthropic's Claude API that reduced production time by 70–80% , bringing turnaround down to 1–5 days while keeping creative directors in complete control.
The Problem with Free-Form Generative AI
Standard LLM text generation is inherently probabilistic. If an AI generates level layout code or raw text descriptions directly, minor syntax errors or structural hallucinations break game engine deserializers immediately.
Our solution relied on three core engineering rules:
- Never ask the LLM for Unity code: Ask for structured data graphs adhering to a strict schema.
- Deterministic Object Instantiation: The Unity editor handles all prefab binding, physics components, and collision layers.
- Automated Solvability Checks: A deterministic heuristic solver simulates player physics before the designer ever opens the level.
Defining the Level Graph Schema
Using Claude's tool-calling / structured outputs interface, we define the exact grammar of our level layout:
{
"name": "generate_level_layout",
"description": "Generates a balanced platformer level layout",
"parameters": {
"type": "object",
"properties": {
"difficulty": { "type": "integer", "minimum": 1, "maximum": 5 },
"pacingProfile": { "type": "string", "enum": ["Steady", "Burst", "Climactic"] },
"segments": {
"type": "array",
"items": {
"type": "object",
"properties": {
"segmentId": { "type": "string" },
"theme": { "type": "string", "enum": ["Jungle", "Temple", "Waterfall"] },
"platforms": {
"type": "array",
"items": {
"type": "object",
"properties": {
"x": { "type": "number" },
"y": { "type": "number" },
"width": { "type": "number" },
"hazardType": { "type": "string", "enum": ["None", "Spikes", "RollingBoulder"] }
},
"required": ["x", "y", "width", "hazardType"]
}
}
},
"required": ["segmentId", "theme", "platforms"]
}
}
},
"required": ["difficulty", "pacingProfile", "segments"]
}
}
Building the Unity EditorWindow
Inside Unity, a custom EditorWindow lets designers enter high-level goals (e.g., *"A temple stage with an escalating spike trap sequence and 3 hidden collectibles"*), transmits the payload to Claude, and hydrates the scene:
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
public class LevelGeneratorWindow : EditorWindow
{
private string _prompt = "Create a medium-difficulty temple segment";
[MenuItem("Tools/AI Level Generator")]
public static void ShowWindow() => GetWindow<LevelGeneratorWindow>("AI Level Gen");
private async void OnGUI()
{
_prompt = EditorGUILayout.TextField("Designer Prompt", _prompt);
if (GUILayout.Button("Synthesize Level"))
{
var layout = await ClaudeLevelClient.GenerateAsync(_prompt);
InstantiateLevelInScene(layout);
}
}
private void InstantiateLevelInScene(LevelLayout layout)
{
Undo.IncrementCurrentGroup();
var root = new GameObject($"Level_{layout.Difficulty}");
Undo.RegisterCreatedObjectUndo(root, "Generate AI Level");
foreach (var seg in layout.Segments)
{
foreach (var plat in seg.Platforms)
{
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>($"Assets/Prefabs/{plat.HazardType}.prefab");
var obj = (GameObject)PrefabUtility.InstantiatePrefab(prefab, root.transform);
obj.transform.position = new Vector3(plat.X, plat.Y, 0);
Undo.RegisterCreatedObjectUndo(obj, "Instantiate Platform");
}
}
Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
}
}
#endif
Heuristic Solvability Simulation
Before saving a generated level as a ScriptableObject , our C# validator tests:
- Max Jump Distance: Can a character with jump velocity
Vy = 12and horizontal speedVx = 8clear every consecutive gap? - Pacing Metrics: Are there at least 3 seconds of low-hazard traversal between intense obstacle clusters?
- Collectible Reachability: Are all bonus rewards physically accessible without taking mandatory damage?
If the simulation fails, the error is fed back into Claude as a conversational refinement prompt: *"Jump gap between platform 4 and 5 exceeds max clearance by 1.8 units. Shorten gap."*
The Business Result
By removing the mechanical friction of manual tile placement, designers focus on playtesting, narrative pacing, and aesthetic polish. Level iterations dropped from weeks to hours, transforming team velocity.
Explore the overarching architecture this fits into: Enterprise .NET 9 Desktop Architecture & AI Agent Tooling .
Topic Cluster Navigation
Enterprise .NET 9 Desktop Architecture & AI Agent Tooling
A comprehensive architectural blueprint for building high-performance, modular Windows desktop applications in .NET 9: multi-process isolation, sub-millisecond Named Pipe IPC, embedded React WebViews, and native Claude GenAI pipeline orchestration.