Pattern Library Index
This directory contains extracted architectural patterns, implementation examples, and design templates from the LLM World Engine Discord discussions.
Pattern Categories
Architectural Patterns
High-level system structure and design decisions for LLM-powered game engines.
- Program-First Architecture ✅ - Backend makes decisions, LLM narrates
- LLM Processing Pipeline ✅ - Pre/Gen/Post processing phases
- Separation of Concerns ✅ - Logic/Narrative/Data layer split
- Event-Driven Design ✅ - Trigger-based game events
Integration Patterns
How components communicate and interact.
- NDL Bridge Pattern ✅ - Converting game events to natural language
- State-to-LLM Injection ✅ - Feeding game state into prompts
- API Abstraction Layer ✅ - JSON APIs for LLM-state interaction
- Multi-Model Routing ✅ - Different models for different tasks
State Patterns
How game state is managed and persisted.
- Three-Tier Persistence ✅ - World/Playthrough/Session state
- Scene-Based State Boundaries ✅ - Scenes as save/load points
- Conditional Persistence ✅ - When to save vs discard
- Universal Data Structure - Single entity schema for all types (placeholder)
Generation Patterns
How content is procedurally created.
- Just-In-Time Generation ✅ - Generate content on-demand
- Hierarchical Cascade ✅ - Top-down vs bottom-up world generation
- Template Meta-Generation ✅ - Using LLMs to create templates
- Context Inheritance - Child elements inherit parent properties (placeholder)
Control Patterns
How LLM behavior is constrained and directed.
- Constraint-Based Prompting ✅ - Tell LLM what it can’t do
- Chain of Thought ✅ - Force reasoning before output with function keywords
- Dynamic Temperature Switching ✅ - Adjust creativity per task
- Few-Shot Formatting ✅ - Guide output structure with examples
Usage
Each pattern file contains:
- Context: When to use this pattern
- Forces: Trade-offs and competing concerns
- Solution: Structure and implementation
- Consequences: Benefits and liabilities
- Source: Original discussions and contributors
Pattern Relationships
graph TD A[Program-First Architecture] --> B[LLM Processing Pipeline] B --> C[NDL Bridge Pattern] C --> D[State-to-LLM Injection] E[Three-Tier Persistence] --> F[Scene-Based Boundaries] F --> G[Universal Data Structure] H[JIT Generation] --> I[Hierarchical Cascade] I --> J[Context Inheritance] A --> E B --> H
Key Insights
- LLMs are terrible at decision-making - Keep logic programmatic
- State and story are interleaved in LLM games (unlike traditional games)
- Templates solve the content problem - Structured generation beats free-form
- Small models work fine when decisions are pre-made (8B-9B sufficient)
- Scenes are natural boundaries for state management
- Visual programming is achievable with proper UI patterns