
Hello Again everyone,
I'm am the creator of Narrative Engine. https://www.reddit.com/r/SillyTavernAI/comments/1spqqb2/release_narrative_engine_i_built_a_standalone_ai/
A Long form focused Text Adventure RPG App for Roleplay. I am posting here as i finished testing my campaign on mobile app and i think i can share it with the community.
I tested the campaign up to 2 million token content back and forth or around 1100 scenes of me back and forth with AI over 1 week. I think i burn NanoGPT 60m token for the testing using DS 4 V PRO Thinking Cheaper + Z.ai around 20 million tokens + DS4 API + Ollama CLoud.
My Token Usage for the week. Usually not this high but i'm testing my long form text RPG app
First thing first, English is not my first language, so I'm using AI to help me write this. But all the logic, design decisions, and opinions are mine , just cleaned up grammar-wise.
I'm not a developer but I do work as a project manager in IT, so I have some understanding of what's going on under the hood despite vibe-coding the app. This has been vibe-coded since 2025, it's not a "throw it into the grinder and output in a single night" thing. So many iterations for my personal use. I'm sharing it now because I want to hear what people think.
tl;dr Standalone app for long-form text RPG where the focus is adventure, not personal RP with NPCs. Think DnD without the status bars like HP/MP for narrative-based adventure. No cloud. No subscription. Your campaigns stay on your machine. Works with any OpenAI-compatible API or Ollama for fully local play. Setting up is simple, just plug and play with the bat file I included. Download link below
I posted about this a 2 weeks back and got some solid feedback. Since then, I've been heads-down building. Here's what's new.
Below are AI generated with my guidance
What's New
Divergence Register — Structured Fact Tracking
https://i.imgur.com/fhpgO3s.png
This replaces the old prose condenser. After every GM turn, the system automatically extracts story-relevant facts — NPC deaths, items acquired, locations discovered, relationships formed, world state changes, canon overrides, player obligations — and stores them as categorized, scored entries.
The register renders into the GM's system prompt as an AUTHORITATIVE OVERRIDES block, grouped by category: canon_override, world_change, entity_state, player_state, obligation. When a chapter is sealed, an LLM classifies each entry as KEEP/PRUNE/REVIEW.
Why this matters: instead of relying on compressed prose summaries that lose detail, the GM now has a structured ledger of every important thing that happened. If you killed the bridge guardian at scene 42, that fact is explicitly tracked - not buried in a paragraph of summary that the GM might misinterpret.
You can also manually tag divergences from GM messages via a bolt button, review them in a dedicated panel, and edit categories/subjects.
Of course this is a new thing i use to manage memory for 2 million token gameplay as i find even towards the end my system require a few regeneration and guided chapter to output proper
NPC Drives & Pressure System
No screenshot on this, its handled in back end.
Every NPC now has a prose-based psychological model with three layers of motivation:
- Core Want — deep character truth (almost never changes)
- Session Want — arc-level objective (updates on arc shifts)
- Scene Want — immediate scene goal (updates frequently)
Plus behavioral triggers (keyword-to-action mappings), hard boundaries (never-do list), and soft boundaries (dislike-but-tolerate list).
On top of that, there's a pressure tracker that detects when NPCs are being ignored or engaged. It scans every player turn for name mentions, pronoun resolution, directed actions ("ask Senna", "tell the guard"), trigger keyword matches, and boundary crossings. Pressure decays over turns (not wall-clock time, so it's consistent across session pauses).
Why this matters: NPCs who are being ignored accumulate "ignored pressure" and get boosted priority for context inclusion. The GM naturally brings them back into the story. There's even a debug inspector with sparkline visualizations of each NPC's pressure history.
[Human commentary: I wanted NPCs that feel alive without me having to manually manage them, i hate how NPC never push me back. waiting for me to say things or just adhering to my will. The pressure system means if I've been ignoring a companion for 10 scenes, the GM will naturally have them do something speak up, get upset, take action. It's emergent, not scripted.]
Lore Check Experimental (Mobile)
This is a mobile-first feature. You highlight any sentence in the GM's output and trigger a "Lore Check." The system:
- Searches your lore database and archived scene history for relevant evidence
- Asks a utility LLM to judge whether the text is Consistent, Unsupported (possible hallucination), or Contradicts established lore
- If a problem is found, generates a suggested rewrite that preserves the GM's tone while fixing the factual error
You can one-click accept the rewrite (replaces text in-place), edit it first, or reject it.
[Human commentary: This was born from frustration. The GM says "Kakashi Teach you rasengan" but in my campaign i learn rasengan from my meta memory. Instead of manually correcting it or letting it slide and polluting your canon, you highlight it, check it, and fix it in one click. Game changer for long campaigns where the AI starts drifting. Again experimental thing for making mobile convenience. Pardon me if it doesn't work its still being refined.]
Deep Archive Search
https://i.imgur.com/CYQmGzp.jpeg https://i.imgur.com/VvnQoA5.png
When enabled, the system runs a multi-round AI-driven archaeological dig through your entire sealed chapter history. Instead of just keyword-matching old scenes, it uses a utility LLM to intelligently identify which chapters and scenes are narratively relevant to the current moment — considering direct references, NPC involvement, unresolved threads, foreshadowing, location continuity, and thematic connections.
Selected scenes are fetched verbatim. If they exceed the token budget, they're partitioned into chunks, summarized individually, then merged into a single coherent brief.
This gives the GM access to long-forgotten campaign events that keyword search would completely miss.
Of course using this function will add delay since its a deep scan. i found direct chapter recommendation more reliable but thats from me doing manual work. this one is like when you want the AI to try with effort
Per-Endpoint LLM Queues with Adaptive Throttling
Each distinct LLM endpoint URL gets its own adaptive concurrency queue. Cloud endpoints start unbounded and self-throttle when they hit 429/503/529 rate limit errors, then gradually recover. Local endpoints (localhost, 192.168.x.x) start with maxConcurrent=1 since local LLM servers are typically single-threaded. Higher-priority tasks (GM responses) jump the queue ahead of lower-priority tasks (NPC generation, background extraction).
[Human commentary: If you're running multiple LLM calls per turn ,GM narration, NPC profile updates, divergence extraction, lore retrieval. this keeps everything orderly without manual tuning. also increases speed]
Reasoning Model Support
Properly handles "thinking" models (DeepSeek-R1, DeepSeek-V3/V4, Qwen QwQ, Kimi K2.5 Thinking) that use <think/> blocks for chain-of-thought. Strips reasoning from display, preserves it in stored messages for API compliance, injects guardrails to prevent the model from ending turns with only a thinking block, and provides sampling profiles tuned for each model's official recommendations.
Campaign Transfer (Desktop <-> Mobile)
Export a complete campaign as a portable .campaign file and import it on another device. The bundle contains everything — metadata, state, lore, NPCs, archive scenes, chapter data, semantic facts, timeline, entities. Cross-platform compatible.
[Human commentary: I play on desktop at home and on my phone when I'm out. Being able to transfer campaigns back and forth was nice for me.]
What Was Already There (Recap)
For those who missed the first post:
4-Tier Memory Architecture:
- Rule & World lore with RAG system
- Chapter system https://i.imgur.com/aUoQLIu.png / https://i.imgur.com/l74MuNC.png
- Full Archive access via recommender that is now optimized to skip chapter still in chat history
- Fact bullet point that also doubles up as quest module .
Dice System: Each turn, the engine sends dice results (not inserted into chat history to save context) across 7 skill categories with advantage/disadvantage/criticals/catastrophes. The AI GM picks which roll applies.
Emergent Storytelling Engines: Surprise Engine (ambient flavor), Encounter Engine (mid-stakes hooks), World Event Engine (seismic shifts). Each threshold decreases over time — the longer nothing happens, the more likely something will.
Auto Bookkeeping: Inventory and character profile tracked in the background. Scene notebook for volatile working memory.
Image Generation: NPC portraits in 5 art styles (Realistic, Anime Realistic, Anime, Western RPG, Chibi). Scene illustrations too. Any OpenAI-compatible image API. Only work for profile as my app focus on text form adventure. the profile is there to give player a sense of who they are talking to blob:https://imgur.com/17b4163f-a95e-4f94-a8df-3210a886ebca
Security: Encrypted API key vault (AES-256-GCM), machine-key or password mode, client-side encryption. All data local.
Rollback: Scene-level rollback with automatic world state cascade — timeline, chapters, NPCs all revert together. Pre-rollback safety backup so you don''t lose data.
Mobile App
There's also a mobile app version (Android, APK only — I don't have iOS). Feature parity with the desktop version mostly. Has some mobile-unique features like the Lore Check mentioned above. Full source code available so you can build it yourself.
I run it on a Samsung S25U daily, the 2 million token was actually fully run on mobile.
Getting Started
- Clone the repo
- Double-click
Start_Narrative_Engine.bat(Windows) ornpm install && npm run dev - Add your API key (OpenAI, Ollama, any OpenAI-compatible endpoint)
- Create a campaign, write your lore, start playing
- Ships with a ready-to-play example campaign: The Awakening — a gritty survival fantasy set 100 years after a meteor mutated all non-humanoid life. Three continents, nine factions, full world bible, rulebook, and starter prompt included.
GitHub:
https://github.com/Sagesheep/NarrativeEngine-P - Desktop
https://github.com/Sagesheep/NarrativeEngine-M/releases/tag/v1.0.40 - for APK mobile or you can build it your own if you want to check the code first
My campaign file world lore and starter prompt and agnostic GM rule https://drive.google.com/drive/folders/1WlEW2mP-MOBL-zKkLsPUDU0siqJDUQym?usp=sharing
MIT licensed. Feedback welcome. Still very much a work in progress, but it's a work in progress I use every day.
PS: i'm trying to make a map but its a bitch to code :( https://i.imgur.com/lgJaU4B.png so annoying to play with asset ahaha.. but i do want to make a map system with player location, travel calculation formula, resource requirement, campfire VN mode, and other system usually visible on BG3 or Tales series.