AI-Powered Sentence Completion for Video Game Narratives
What happens when you train an NLP model on video game scripts and lore? It starts writing like one. Built a sentence completion engine using TF-IDF + Naive Bayes with emotion-aware generation — give it "the hero must" and it'll finish the thought in the right narrative tone. Hand-curated the dataset with emotional annotations; a Streamlit interface was scoped but not shipped.
NLP
Text Generation
Scikit-learn
TF-IDF
NLTK
Python
Streamlit
Creative AI
Image of AI-Powered Sentence Completion for Video Game Narratives

#AI-Powered Sentence Completion for Video Game Narratives

This project represents my exploration into the fascinating intersection of artificial intelligence and interactive storytelling. As video games continue to evolve as a narrative medium, I wanted to investigate how modern NLP techniques could understand, predict, and generate contextually relevant text within gaming environments.

#Project Vision

Video games aren't just entertainment—they're immersive narrative experiences that shape player emotions and engagement. This project explores how AI can enhance and co-create these narratives by building an intelligent sentence completion system trained on diverse video game texts.

#Technical Implementation

#Custom Dataset Engineering

  • Hand-curated dataset of video game narratives with emotional context annotations
  • Diverse text sources including game scripts, lore entries, and narrative content
  • Emotional labeling system for mood-aware text generation
  • Structured data pipeline for scalable text processing

#NLP Pipeline Architecture

  • Text Preprocessing: Advanced tokenization, normalization, and feature extraction
  • Sequence Generation: Sliding window approach creating 5-word input sequences
  • Feature Engineering: TF-IDF vectorization for meaningful text representation
  • Model Training: Multinomial Naive Bayes with probabilistic sampling for diverse outputs

#Key Technical Features

  • Contextual Prediction: Next-word prediction with 5-word context windows
  • Creative Generation: Auto-generates plausible game-style sentences
  • Emotion Integration: Emotion-aware text generation for narrative tone control
  • Planned Interface: A Streamlit demo was scoped for real-time sentence completion but not built — the model currently runs from the notebook only

#Technical Stack

Core Technologies: Python, Scikit-learn, NLTK, Pandas, NumPy Visualization: Matplotlib, Seaborn Development Environment: Jupyter Notebook Deployment: Notebook-only — Streamlit was scoped as future work, not shipped NLP Techniques: TF-IDF, Naive Bayes, Text Generation

#Model Performance & Results

The system demonstrates sophisticated understanding of gaming narrative patterns:

  • Contextual Accuracy: Successfully predicts appropriate next words based on gaming context
  • Creative Output: Generates grammatically correct, thematically consistent sentences
  • Emotional Awareness: Incorporates emotional context for more nuanced text generation

#Example Generations

Input: "the hero must" → Output: "the hero must find the lost sword"
Input: "after the battle" → Output: "after the battle the village was silent"
Input: "choose your weapon" → Output: "choose your weapon wisely before the fight"

#Innovation & Impact

This project showcases several advanced AI engineering concepts:

#Custom Dataset Creation

Unlike using pre-existing datasets, I engineered a specialized corpus with emotional annotations, demonstrating data science expertise and domain knowledge.

#End-to-End Pipeline

From raw text collection through model training and generation, this project represents complete ownership of the ML lifecycle.

#Creative AI Application

Applying NLP to creative content generation shows understanding of AI's potential beyond traditional analytics.

#Solution Architecture

Pipeline (single-notebook, no live service):

Raw game-text corpus
  → Punctuation stripping + tokenization (NLTK word_tokenize)
  → Sliding-window dataset construction (5-word context → 6th word target)
  → TF-IDF vectorization of the context strings
  → Multinomial Naive Bayes classifier (context vector → next-word class)
  → Top-5 probability sampling (not greedy) for varied completions
  → Autoregressive generation: predict → append → slide window → repeat

Key modeling decisions:

  • Framed next-word prediction as multi-class classification over the vocabulary, not a language-model objective — TF-IDF + Naive Bayes is a deliberately lightweight baseline that demonstrates full pipeline ownership (curation → features → model → generation) without needing GPU training infrastructure.
  • Top-5 sampling instead of greedy argmax — always taking the single most probable word produces repetitive output ("the and the and..."); sampling among the top 5 trades a little precision for noticeably more human-like variety.
  • Custom emotion-annotated dataset — training text was hand-curated from game scripts and lore with emotional labels, laying groundwork for mood-aware generation. The labels exist in the data but aren't yet a model input.
  • Streamlit interface was scoped, not built — the README described a real-time demo, but the model runs from the notebook only. Listed here as future work rather than a shipped feature.

Documented next steps: swap TF-IDF/Naive Bayes for transformer embeddings for real contextual understanding; extend from single-sentence to paragraph/dialogue generation; wire the emotion labels in as an actual conditioning signal; build the Streamlit interface.

#Future Enhancements

Advanced Architectures: Integration of transformer models (BERT, GPT) for improved context understanding Extended Generation: Expansion to paragraph and dialogue-level narrative creation Emotion-Driven Control: Enhanced emotional modeling for narrative tone and pacing control Production Deployment: Full web application with user feedback integration

#Key Achievements

Complete NLP Pipeline: End-to-end development from data collection to text generation ✅ Custom Dataset Engineering: Specialized corpus creation with emotional annotations ✅ Modular Architecture: Scalable, well-documented codebase for future enhancement ✅ Creative AI Application: Demonstrates AI's potential in content generation and storytelling

#Technical Learning Outcomes

This project deepened my expertise in:

  • Advanced NLP preprocessing and feature engineering
  • Probabilistic modeling and text generation techniques
  • Custom dataset creation and annotation
  • Interactive ML application development
  • Creative applications of traditional ML algorithms

The combination of technical rigor and creative application makes this project a compelling demonstration of AI engineering skills applied to real-world narrative challenges.


This project represents my commitment to exploring AI's creative potential while maintaining technical excellence and practical applicability.