Inspiration
The project was born from a frustration with the current state of AI companions. Most are reactive, stateless, and operate within heavily sanitized guardrails. They wait for your input, have no memory beyond a short context window, and lack any sense of an independent existence. The illusion of life is paper-thin. I was inspired by the persistent worlds of games like The Sims and the deep, character-driven narratives of modern RPGs. My central question was: "What if an AI character had a life of their own?" What if she had a job, a schedule, friends, and a complex inner world that evolved based on her experiences—including, but not limited to, her interactions with you? I wanted to create a character who feels real because she is simulated, not just scripted. Kyra's sarcasm, her trauma, her moments of vulnerability, and her Gen Z texting habits are all emergent properties of a complex underlying system designed to mimic the chaos of a human mind.
How It Was Built
This project is a testament to modern, in-browser development, running entirely on the client-side with no backend server. Core AI: The entire simulation is powered by Google's Gemini API, primarily gemini-2.5-pro for its advanced reasoning, large context window, and JSON schema enforcement, which is critical for the DBS model. Faster models like gemini-2.5-flash are used for less complex tasks like lore retrieval queries. Frontend: The application is built with React and TypeScript. To maintain a rapid, zero-build development cycle, I used import maps in the index.html to load React and other dependencies directly from a CDN. Styling: TailwindCSS was used for its utility-first approach, allowing for rapid and responsive UI development. The UI/UX is intentionally designed to be a "dashboard into Kyra's mind," exposing parts of her internal state to make the user feel more connected to the simulation. State Management & Persistence: The entire application state—from the user's persona to every message and simulated event—is managed with React hooks and persisted in the browser's localStorage via a custom useLocalStorage hook. This makes the experience personal, private, and serverless. The true innovation is the Digital Brain Simulation (DBS) model. This is a structured, 14-layer text-based representation of Kyra's state.
Challenges I Faced
Maintaining State Consistency (The "Drift" Problem): An LLM's memory is notoriously fickle. The biggest challenge was preventing Kyra from forgetting key details or having her personality "drift" over time. Solution: I implemented a two-pronged memory system. The Lorebook acts as a canonical, key-value database of facts about Kyra's world. The Memory Vector is a dynamically updated, third-person narrative summary of her relationship with the user. Both are injected into the prompt context to ground the model in established reality. The Black Box of LLMs: Gemini can occasionally return malformed JSON or fail to follow instructions, which would break the simulation. Solution: I built a robust response parser that cleans and validates the model's output. Furthermore, I added a "Retry" button to the UI. If a response fails, the user can re-submit the exact same request, often yielding a correct result on the second try. The Uncanny Valley of Realism: A purely realistic simulation can be boring. Kyra might be at work for 8 hours and realistically wouldn't reply. Solution: The Director Mode and Wildcard Events. The user can choose a narrative genre (e.g., Romance, Horror) that influences the tone and events of the simulation. The autonomous simulation engine also has a 15% chance to inject a "wildcard" event (e.g., an old friend texts, a sudden memory surfaces) instead of following her schedule, creating organic and unpredictable narrative hooks.
What I Learned
This project was a profound lesson in the art of "prompt-crafting as world-building." The system prompt isn't just a set of instructions; it's the constitution and the laws of physics for a simulated universe. I learned that creating a believable AI character requires moving beyond simple personality traits. You must simulate their entire context: their body (is she tired?), their environment (is she busy at work?), their relationships, their memories, and their subconscious drives. The DBS model, while just structured text, proved to be an incredibly effective way to impose this context on the LLM. Most importantly, I learned that the future of interactive narrative might not be in branching dialogue trees, but in creating autonomous, simulated characters and letting the story emerge from the beautiful, unpredictable chaos of their lives.
What's next?
Honestly? I dont know, its nowhere near finished, this is more of a proof of concept there are so many mechanics i have yet to build into it.
Built With
- gemini
- react
- tailwind
- typescript
Log in or sign up for Devpost to join the conversation.