Skip to the content.

Reflection Blog for Trimeter 2 CSA

Incorporate AI NPC History Professor with Dialogue System, Typewriter, Voice, and Full-Stack Gemini Integration

Analytics

Image

Summary

This issue documents the integration of a fully functional AI NPC, specialized as a History Professor, into the game. The implementation spans both frontend and backend, and includes:

  1. Dialogue System Integration
  2. Typewriter Text Effect
  3. Voice / Speech Synthesis
  4. Full-Stack Backend Integration with Gemini API for AI Responses

Work Completed

Frontend Enhancements

  • Integrated DialogueSystem for NPC interactions.
  • Added typewriter effect for AI response text.

Commits (Frontend):

AI NPC History Professor

  • Implemented an AI NPC system + an example sprite who is a History Professor.
  • Supports user prompts, chat history, and example knowledge topics.

Commits:

Notes:

  • The backend uses Flask to handle AI requests securely with environment-stored Gemini API keys.
  • This is a full-stack implementation, unlike previous local or mock AI NPC interactions.
  • A pull request was created for the backend to merge these changes.

Planning

Feedback


Video Demo

MCQ

Image

Image

What I Did Well

  • Object-Oriented Logic: My high scores in Units 1 and 3 show I understand how classes are structured, how to instantiate objects, and how to call methods.
  • Syntax: I’m not making basic Java writing mistakes — my errors are mostly in code tracing.
  • Pacing: I’m moving through MCQs at a good speed.

Image

ArrayList Methods

Error: I chose [2, 3, 2, 1] instead of [2, 0, 2, 1].

Key Idea:

  • set(index, value) → replaces
  • add(index, value) → shifts

I forgot that set(0, 2) replaces the value rather than moving it.

Image

Image

Image

Image

Loop Logic

Error: I confused i < m*n with nested loop behavior.

Key Idea: The inner loop ran n − 1 times, so total executions = [ m(n - 1) = mn - m ]

I also missed an infinite loop case: if i++ is inside an if that doesn’t run, i never changes and the loop runs forever.

Image

Image

Image

Indexing & Tracing

Error: I chose the first item instead of the second.

Key Idea: Java uses zero-based indexing:

  • get(0) = first item
  • get(1) = second item

I forgot that cList.get(1) refers to the second element.

FRQ