RogueLLM: AI-Augmented Procedural Game Content
RogueLLM is an innovative experiment that explores the intersection of Large Language Models (LLMs) and game design.
At its core, it's a minimalistic text-based RPG that demonstrates how AI can dynamically create rich, personalized gaming experiences, in the spoken language of the user, as long as the LLM being used is sufficiently knowledgeable.
For the sake of simplicity, we decided to go for fixed and very simple game mechanics, and focus on dynamic generation of game setting and narrative. Whether the user fancies exploring a cyberpunk metropolis or venturing through a medieval fantasy realm, the possibilities are only limited by the imagination of the user combined with the capabilities of the LLM.
Game Interface
The game uses a simple web interface built with HTML, CSS, and JavaScript. Players use four directional buttons to move across the map. When encountering enemies, the player can choose to attack or flee.
The visual elements are represented by Font Awesome icons, with the LLM selecting appropriate icons and colors for map locations, characters, and items. This approach keeps the interface lightweight while providing some visual feedback for gameplay.
Operation
The game begins with the player entering a theme - this can be as simple as "fantasy" or "cyberpunk", or as specific as a movie title or detailed description. The input is optionally enhanced with web search results to provide additional context for the LLM.
Theme generation phase
We found relatively lightweight models such as GPT-4o-mini and Gemini 1.5 Flash to be sufficient for this task.
Using GPT-4o-mini, the game takes about 30 seconds to:
- Create a reference document from the theme and context
- Generate game elements (player definition, items, enemies, location types)
flowchart TB
%% Main flow
A["User Input Theme"] --> C["Context Enhancement<br/>(optional Web Search)"]
C --> D["LLM"]
D --> E["Reference Document"]
E --> F["LLM"]
F --> G["Game Elements<br/>Generation"]
%% Game Elements with forced horizontal positioning
subgraph elements ["Game Elements"]
direction LR
H["Player Definition"] ~~~ I["Items"] ~~~ J["Enemies"] ~~~ K["Location Types"]
end
G --> elements
Playing phase
During gameplay, the LLM serves two functions:
- Creating the game map and placing elements (about 20 seconds)
- Generating narrative text that matches the theme
The map generation uses minimal prompting, with a simple instruction to place items near enemies to avoid excessive wandering.
flowchart TB
A[Location Types] --> B[LLM]
B --> C[Game Map Generation]
C --> D[LLM]
D --> E[Game Elements Placement]
Current issues
Latency issues
The major drawback of our approach is that there's constant reliance on an LLM which is currently online with a variable amount of latency, although with time, as both hardware and models improve, it will be possible to run the LLM locally on the same server as the game.
Reliability issues
Another issue is that the LLM will occasionally fail to generate data in the expected format. Although this is rare with the current prompts, different LLMs are bound to behave differently and new problems may arise.
For example, when using smaller models such as Llama 3.1 8B, the LLM often failed to generate a game map with the required width and height.
One key feature that helps with reliability is structured outputs, which forces the LLM to generate valid JSON objects in output, which is what the Python code expects to work with when it comes to definition of game items.
However, there may still be cases where the LLM, while generating a valid JSON object, gets creative with adding, removing or changing the names of the fields/keys of the JSON objects. To counter this, as usual, trial and error with prompting is required.
Possible improvements
While the current implementation demonstrates the core concept, several areas could be enhanced:
Visual improvements
- Replace Font Awesome icons with custom graphics, either through LLM-generated SVG/ASCII art or dedicated image generation models
- Expand the map visualization with more detailed terrain features
Gameplay enhancements
- Create larger, more varied maps with different biomes or zones
- Add more complex fixed mechanics like crafting or character progression
- Implement dynamic game mechanics where the LLM generates new rules and supporting code (Python/Lua)
Optimizations
- Move to local LLM deployment to reduce latency
- Implement caching strategies for commonly generated content
- Improve response time for narrative generation
Conclusions
RogueLLM demonstrates how LLMs can be integrated into game development, particularly for narrative generation. By combining traditional game mechanics with AI-driven content creation, we've created an experience that balances structure with creative freedom.
While current limitations require a hybrid approach of fixed game logic and dynamic content, the project has revealed two key insights: first, that LLMs can effectively handle procedural content generation within well-defined constraints, even when using small and affordable models such as GPT-4o-mini; and second, that players are genuinely intrigued by the ability to shape their gaming experience through natural language interaction.
These initial findings point to promising directions for AI-powered game development, though further improvements would be necessary to maintain engagement beyond the novelty phase. As we continue to explore the balance between technological capability and practical implementation, RogueLLM serves as a stepping stone toward more sophisticated AI-driven gaming experiences.