Games deserve better conversations
Traditional games rely on static dialogue trees — branching menus scripted by developers. LLM Valley replaces them with free-text input and real-time AI responses, making every NPC feel like a genuine inhabitant of the world.
Natural NPC Conversation
Players type freely — no dialogue trees, no fixed choices. Each NPC responds with context-aware, in-character dialogue powered by a real LLM.
Cozy Life-Sim Gameplay
Farm crops, fish at the lake, trade with merchants, and sleep to advance days. A complete simulation loop grounded in a charming pixel-art world.
Modular AI Integration
The LLM integration is cleanly separated from gameplay logic. Persona prompts, conversation history, and relationship evaluation run independently.
Traditional dialogue trees are expensive to write, can't scale to natural conversation, and break player immersion the moment a response doesn't fit the expected branch. Every variation must be handcrafted by a developer.
LLM Valley integrates the OpenRouter API inside a playable Unity demo. Players type anything — the NPC reads a rich persona prompt plus conversation history and responds contextually in real-time. Relationship stats evolve automatically.
Project documentation
Access comprehensive reports covering design, architecture, AI implementation, and user testing. All documents are available for download.
A full life-sim loop
Every day in LLM Valley is a repeating cycle of farming, social interaction, and economic progress. Traverse between Farm and Town using WASD, interact with objects and NPCs via E.
Farm
Till soil, plant seeds, water crops daily, harvest when grown. 12 crop types across 3 tiers, up to 4 farmable fields.
Fish
Head to the farm lake with a fishing rod. Engage a timing-based minigame to catch from 6 fish types by rarity.
Talk
Approach any NPC with E to open free-text dialogue. Each NPC has a unique AI persona and remembers your history.
Trade
Sell to Donald the Merchant, buy seeds from Helen, upgrade tools at Rudy's, unlock new farm areas with Ezekiel.
Sleep
Return home and sleep to end the day. Stamina resets, crops grow, NPC schedules refresh for a new cycle.
Progress
Build Trust, Friendship, and Love with NPCs to unlock higher shop tiers, new crops, and deeper conversation.
Two interconnected scenes
Farm Scene
Player's home, 4 farmable fields (1 unlocked initially), fishing lake, and the path to Town.
Town Scene
Town Square with the statue, all four NPC shops, and the path back to the farm.
LLM Valley - User Manual
Everything you need to know to play LLM Valley. From controls and gameplay mechanics to NPC interaction and progression systems.
Starting the Game
1. Launch the game 2. Click API Key on the Main Menu 3. Enter your OpenRouter API Key 4. Save the key 5. Click Play
Controls
W/A/S/D or Arrow Keys: Move E: Interact Left Mouse: Use Tool/Item I: Open Inventory 1-0: Select Hotbar Slot Hold Z: Drop Item Stack
Talking to NPCs
1. Approach an NPC 2. Press E to open dialogue 3. Type your message 4. Submit and wait for response NPCs respond based on: Personality, Previous conversations, Relationship status, Context
Farming
1. Equip a farming tool 2. Prepare the soil 3. Plant seeds 4. Water crops regularly 5. Wait for crops to grow 6. Harvest mature crops
Fishing
1. Equip the fishing rod 2. Move near a fishing area 3. Start fishing 4. Receive randomized catches and rewards based on your skill
Inventory
Store collected items, equip tools, manage resources, and organize farming materials. Use number keys (1-0) to quickly switch between hotbar slots.
Saving Progress
Game progress is automatically stored locally. Data includes: Inventory, Currency, Relationships, Calendar progress, and Conversation history.
Troubleshooting
NPC no response: Check API key and internet connection Game cannot save: Verify file write permissions LLM Valley is a prototype. Some features may be incomplete.
How the conversation pipeline works
Every NPC interaction is a live API call. There are no scripted branches — each response is generated fresh, shaped by a rich persona prompt and the player's full conversation history.
Player Approaches NPC
Player walks near an NPC in the village. An interaction prompt appears: "Press E to interact."
Free-Text Input
The dialogue UI opens. Player types any message freely — no fixed choices or branching menus.
Prompt Construction
NPCChatAgent builds the system prompt: NPC persona + roleplay rules + current Love/Friendship/Trust scores + conversation history.
OpenRouter API Request
NPCOpenRouterClient sends a POST request via UnityWebRequest to openrouter.ai/api/v1/chat/completions with JSON payload.
LLM Response
The selected free LLM returns a contextual, in-character response. Out-of-character AI disclosures are stripped by a regex filter before display.
Response Appears in UI
The NPC's reply is appended to the NPCChatUIManager dialogue view. The conversation is saved to NPCConversationStore (JSON files).
Relationship Evaluation
Every 5 player messages, a second LLM call evaluates the conversation window and returns Love/Friendship/Trust deltas (−2 to +2 each). Stats update and persist.
Asynchronous by design
All API calls use Unity Coroutines via UnityWebRequest. The game never blocks — UI shows "NPC is thinking…" while waiting for a response.
Fallback on failure
If the API key is missing, the model ID is invalid, or the network fails, the error is shown directly in the dialogue UI. No silent crashes.
Identity filtering
A regex pass removes out-of-character AI disclosures ("I am an AI", "dil modeli" etc.) before any text is displayed, preserving immersion.
Relationships that actually evolve
Every NPC tracks three independent relationship metrics. They update automatically after every fifth conversation exchange through a hidden LLM evaluation pass — not through button presses or arbitrary triggers.
Rises through romantic affection, sincere compliments, and emotional closeness. Influences tone and romantic tension in responses.
Grows with warmth, humor, kindness, and shared moments. Makes NPCs more relaxed and willing to share information.
Built through honesty, consistency, and respecting NPC boundaries. Unlocks higher shop tiers, new farm areas, and deeper dialogue.
Meet the four NPCs
"Ah… the new farmer. Let's see if you've brought anything worth my time today."
"Oh! You must be the one who inherited your grandfather's farm. Welcome to LLM Valley!"
"…Oh. You're the new farmer, right? Need a hoe or something sturdier?"
"Hey there! You must be the one fixin' up that old farm. Name's Ezekiel."
Every 5 player messages, a separate LLM call evaluates the conversation window and returns structured JSON deltas (−2 to +2) for each stat. The system accounts for flirting, vulnerability sharing, rudeness, manipulation, and more — following a detailed evaluation rulebook baked into the prompt.
Three clean layers
The AI module is intentionally decoupled from gameplay logic. Game systems talk to the AI module; the AI module never directly touches farming or inventory. This separation makes the system testable and extensible.
Save System
SaveManager.cs serializes player data — coins, inventory (10 slots), calendar state, scene position, gate states — to Unity's PlayerPrefs as JSON strings.
Conversation Persistence
NPCConversationStore.cs writes full message history per NPC to JSON files. On next interaction, history is loaded and prepended to the system prompt — giving NPCs persistent memory across sessions.
Built on proven, open tools
Every technology in LLM Valley was chosen for reliability, Unity ecosystem compatibility, and the ability to ship a working demo within an academic semester.
Latest long-term support release. Universal Render Pipeline, 2D Tilemap system, UI Toolkit, and the full C# scripting environment.
All gameplay logic, AI integration, save system, UI management, and NPC behavior are written in C# using Unity's MonoBehaviour component model.
Unified API gateway providing access to multiple LLM providers with a single key. Used for both dialogue generation and relationship evaluation calls.
The system is model-agnostic — any OpenRouter-compatible model works. Claude Haiku was the primary target; the client auto-filters for free available models.
Unity's built-in HTTP client, used for all API calls. Runs in Coroutines so the game never blocks while waiting for a response. Full async/await pattern.
JSON parsing and serialization for API payloads, conversation history files, and the save system. Industry-standard library via Unity Package Manager.
Crisp, high-resolution text rendering for all dialogue, HUD elements, and NPC names. Supports rich text markup for name coloring in chat.
Player state (coins, inventory, calendar, position, gates) serialized to JSON and stored in Unity's cross-platform PlayerPrefs key-value store.
Full source version control for the Unity project, with .gitignore for Library/Temp folders. Collaborative development by the 4-person team.
16 of 16 test cases passed
All functional, interface, and validation tests passed at final submission. Tests covered the full game loop — from NPC dialogue to farming, trading, save/load, and UI consistency.
Built by four students
LLM Valley was created as the SENG/CMPE 491/492 Senior Graduation Project at TED University, Spring 2026. A 4-person team, one semester, one playable demo.
Designed the core gameplay loop, world structure, NPC systems, and economic balancing, while defining the overall game design direction and progression mechanics.
Implemented the movement, farming, item, and tool systems using scalable object-oriented architecture and design patterns, while integrating the projects visual assets and UI elements.
Developed the LLM-powered NPC interaction system, including OpenRouter API integration, relationship evaluation mechanics, dialogue persistence, and AI-driven economy interactions.
Implemented the inventory, calendar, sleep, save/load, and scene transition systems while coordinating development tasks, milestone planning, and subsystem integration.


