Memory-Driven NPC Behavior: Context-Aware and Emotion-Based Game Conversations
2025 (English)Independent thesis Basic level (degree of Bachelor), 10 credits / 15 HE credits
Student thesis
Abstract [en]
Background: Non-playable characters (NPCs) in digital games frequently sufferfrom shallow interaction design, lacking emotional nuance, contextual memory, andadaptive dialogue. Traditional rule-based systems and branching scripts restrict im-mersion due to their inability to model affective state or conversational history. Whilelarge language models (LLMs) enable fluent text generation, they inherently lackmechanisms for emotional alignment and memory persistence, leading to disjointedand impersonal responses.
Objectives: This thesis aims to design, implement, and evaluate a lightweight,modular framework that integrates sentiment analysis and episodic memory to enableemotion-aware, context-aware NPC dialogue. The primary objective is to assess theframework’s impact on players’ self-reported immersion, engagement, and perceivedNPC realism through standardized usability assessment (SUS) andpost-interactionquestionnaires.
Methods: The proposed system integrates: (1) a RoBERTa-based sentimentanalysis module for classifying emotional tone of player input; (2) a structuredJSON-based memory repository to store and retrieve contextually significant dia-logue history; and (3) a prompt engineering pipeline that fuses character biography,memory logs, and sentiment context into an input format suitable for large languagemodel inference using a locally-hosted Mistral GGUF model. The entire frameworkoperates via a Gradio-based user interface for real-time interaction and evaluation.
Results: System evaluation with 20 users yielded a mean System Usability Scale(SUS) score of 89.78, placing the framework in the 95th percentile for usability.Component-level validation confirmed the sentiment classifier’s high accuracy (0.90weighted F1-score) and the memory engine’s efficiency (0.41 ms retrieval latency),demonstrating the technical robustness of the underlying architecture.
Conclusions: The findings validate that a lightweight, modular framework cansignificantly enhance NPC believability and user satisfaction. This work provides apractical blueprint for creating memory-driven, emotionally responsive NPCs withoutrelying on resource-intensive, monolithic AI models, offering a scalable solution forgame developers and researchers.Keywords: Non-playable characters, affective computing, sentiment analysis, con-versational memory, prompt engineering, large language models, game artificial in-telligence, Gradio interface, RoBERTa, emotion-aware NPCs.
Place, publisher, year, edition, pages
2025. , p. 58
National Category
Computer Sciences
Identifiers
URN: urn:nbn:se:bth-28875OAI: oai:DiVA.org:bth-28875DiVA, id: diva2:2013165
Subject / course
DV1478 Bachelor Thesis in Computer Science
Educational program
DVGDT Bachelor Qualification Plan in Computer Science 60.0 hp
Presentation
2025-10-01, Campus Grasvik, BTH, Karlskrona, 19:48 (English)
Supervisors
Examiners
2025-11-132025-11-112025-11-13Bibliographically approved