Inspiration

This was my first time building an interactive programming project, and as a complete beginner in Python and Google Cloud, getting it to work felt like a miracle.

As a big fan of RPGs, I’ve always wanted to create my own text-based adventure. But instead of using traditional branching logic, I wanted to bring in generative AI and let the story react to the player's emotions.

At first, I intended to use a text-to-music AI to generate original soundtracks in real time. However, due to time and technical limitations, I dropped that idea and instead had the AI analyze emotional cues in the player's input to select the most fitting background music from a predefined list. For example, if a player in their prompt says, “When I face the enemy, I feel horror and panic,” the AI recognizes the emotion and plays tense, fear-based music.

With this project, I wanted to create something that could:

  • Understand player emotions through natural language
  • Adapt storylines based on emotional context
  • Boost immersion through responsive background music
  • Offer meaningful choices that reflect the player’s emotional state

The world of Attack on Titans inspired the tone and setting—a cruel world where emotions like fear, courage, and sacrifice directly shape outcomes. I wanted to recreate that emotional intensity in an interactive, personalized way and paid tribute to Survey Corps. 心臓を捧げよ!!

What it does

Adventure Game Master is an emotion-driven text adventure game that creates personalized storytelling experiences. The game:

  • Analyzes player emotions and actions through natural language processing of their text input
  • Dynamically adjusts the narrative based on detected emotions (battle, heroic, sad, victory, defeat)
  • Plays contextual background music that matches the emotional tone of the story
  • Creates branching storylines where player choices and emotions determine multiple possible endings
  • Provides immersive gameplay through a fixed 3-turn structure with escalating drama

Players embark on a dramatic adventure where Titans have broken through humanity's protective walls, and they must make choices that reflect their emotional state. The game responds with appropriate music and story developments, creating a truly personalized narrative experience.

How we built it

The project was built using Google's ADK Agent Management Kit with a modular Python architecture:

Core Components:

  1. Agent Controller (agent.py): Main game master using Gemini 2.0 Flash model
  2. Emotion Analyzer (emotion_analyzer.py): NLP-based emotion classification with weighted keyword matching
  3. Music Player (music_player.py): Pygame-based audio system with emotion-to-music mapping
  4. Game State Manager (game_state.py): Turn-based progression and story tracking

Technical Implementation:

  1. Emotion Detection: Built comprehensive Chinese keyword dictionaries mapping to 5 core emotions
  2. Audio System: Created emotional music mapping (intro, battle, sad, heroic death, victory/defeat themes)
  3. Narrative Engine: Designed branching story logic with multiple endings based on emotional analysis Real-time Processing: User input → Emotion analysis → Music selection → Story generation → Response

Game Flow:

Turn 0: Game intro + atmospheric music Turn 1-2: Player actions → Emotion analysis → Dynamic story + music Turn 3: Final choices → Multiple endings based on cumulative emotions

Challenges we ran into

  1. Emotion Detection in Natural Language Understanding emotions from player input, especially in Traditional Chinese, was tricky. I built a keyword-based system with confidence scoring and multi-label emotion mapping to improve accuracy.

  2. Keeping the Story Coherent Balancing emotional freedom with story structure was tough. I designed a turn-based system with fixed story beats, while allowing emotional variations within each scene.

  3. Smooth Audio Transitions Switching background music based on emotion without making it feel abrupt was harder than expected. I used pygame to manage looping, fading, and clean transitions.

  4. Cultural Language Nuance Recognizing emotions in Traditional Chinese required building a custom keyword dictionary that takes cultural context and phrasing into account.

Accomplishments that we're proud of

Of course is Finishied my own adventure game!!

As a complete beginner in programming, building a functional game like this felt nearly impossible at first. But with the help of ChatGPT, Gemini, and Claude, I was able to start small and gradually grow the project. These AI models became my loyal teammates and patient mentors. I would share an idea, and they would help me figure out what was wrong, offer alternative solutions (even if not all of them worked), and explain code I didn't understand.

I spent many sleepless nights bouncing ideas between each model (partly because I was using free accounts for all of them). With their support, I kept refining my ideas, fixing bugs, resetting expectations, and expanding the codebase. Eventually, I got most of the features working.

What we learned

  1. Advanced NLP techniques for emotion recognition in multilingual contexts
  2. Agent-based system design using modern AI frameworks like Google ADK
  3. Real-time audio integration and state management in conversational AI
  4. Designing and implementing complex branching narratives

What's next for Adventure Game Master

Short-term Enhancements

  1. Bug, bug, bugs...
  2. Improving emotion analysis The current system is not nuanced or accurate enough. Some emotional categories are overweighted, leading to incorrect classifications by the AI. As a result, certain music tracks are triggered too frequently, while others are rarely or never played.

Long-term Vision

  1. AI-Generated Music

Implement a true text-to-music model to dynamically create original soundtracks based on the player's real-time emotion or actions.

  1. Multiplayer Collaborative Stories

Integrate a second large language model to act as a key companion or teammate character. This would allow for more interactive, dynamic storytelling and richer character-to-character relationships.

Built With

Share this project:

Updates

Submission history