Explicit player agency
The scene should set up a meaningful decision. Perspective and agency checks guard against narrating an unchosen player action or treating the player as a separate character.
Engineering case study · AI & TypeScript · 2026
Book RPG turns a source book into a playable story. Choose a character, act and talk from their perspective, and follow the original story or take a different route. The engineering challenge is making those choices matter while keeping the world coherent.
A scene can read beautifully and still be wrong. A character might know something too early, act from the wrong perspective, or complete a decision before the player makes it.
The core problem is coordinating source material, player agency and persistent state. The engine needs to distinguish what has happened, what can happen now, and what still belongs to the future.
The original book provides a canonical route. It is a reference for progression, while the interactive timeline can diverge when the player makes a different choice.
Extract chapters from an EPUB, resolve character identities and organize source events into ordered story beats.
Use the selected character, current story progress and game history to create a scene with meaningful actions.
Validate generated output and review continuity, presence and choices before accepting the next game state.
The scene should set up a meaningful decision. Perspective and agency checks guard against narrating an unchosen player action or treating the player as a separate character.
Completed beats are tracked for the active event. The engine tracks which source actions are still in the future and checks whether they remain compatible with the interactive timeline.
Conversation choices open a separate dialogue state. The browser also supports free-text actions, turn history, undo and persistent world rules.
OpenAI and xAI adapters sit behind one engine layer. Structured responses are validated before acceptance, with bounded generation attempts and retries.
The current implementation uses Node.js and TypeScript, with a responsive browser client and a terminal client sharing an HTTP API.
Local development uses file-backed repositories. The Azure configuration uses Blob Storage for analyzed books and Cosmos DB for user-scoped game saves. A Docker image and Bicep infrastructure support deployment to Azure Container Apps.
KOReader remains a longer-term device-side target. The repository includes a Kindle-oriented data package; the Node web game is the main actively tested runtime.
The repository includes regression tests and a Playwright endurance flow that runs repeated choices across characters. Per-game logs record source progression, AI inputs and outputs, rejected generations and saved turns.
These tools help reproduce failures such as premature dialogue suggestions, perspective drift and scenes that do not make the next action possible.
This is an evolving implementation. AI-generated continuity still needs review, EPUB parsing has boundaries, and successful runs do not establish that every book or sequence of choices will work. No aggregate reliability or latency benchmark is claimed here.
Amsterdam 750 explores a different set of constraints: high-demand registration and personal data protection. Its case study includes a public implementation and published load-test evidence.