Context-Aware NPC Dialogue Dissertation
Overview
For my final year dissertation, I explored the integration of Large Language Models (LLMs) into video games to create context-aware dialogue for non-player characters. The project investigated whether game state information could be translated into prompts which would allow NPCs to generate responses relevant to the player's current situation, rather than relying entirely on predefined dialogue trees.
The practical component of the dissertation was implemented in Unreal Engine and focused on building a complete dialogue pipeline, from collecting contextual information within the game to displaying the generated response back to the player.
System Design
The system was split into multiple components responsible for collecting game state, constructing prompts, communicating with the LLM, parsing responses and displaying dialogue through subtitles and text-to-speech. Separating these responsibilities made the system easier to maintain while also allowing each part to be evaluated independently.
A large focus of the implementation was the prompt builder, which translated structured information about the current game state into a format that the language model could understand. This included information about the NPC, the player and the surrounding environment so that responses remained relevant to the current interaction.
To improve reliability, I also implemented fallback behaviour to handle failed requests or invalid responses, ensuring that conversations could continue gracefully even when the language model could not produce a suitable result.
Evaluation
Rather than simply demonstrating that the system worked, the dissertation evaluated it against a number of measurable requirements. These included response latency, contextual relevance, persona consistency and how well the system handled failures.
This approach allowed the project to assess not only whether LLM-generated dialogue was possible, but also whether it could be integrated into a game in a practical and maintainable way.
Results
The completed prototype demonstrated that context-aware NPC dialogue could be generated by combining live game state information with modern language models. While challenges such as latency and response reliability remain, the project showed that this approach can produce more dynamic interactions than traditional static dialogue systems while fitting into a modular game architecture.