Story Engine

An offline interactive book

A book the reader moves through

Most “choose your own adventure” apps forget what you chose. This one does not: every choice changes what you carry, what you carry decides which doors are still open, and the trail shows every passage you have been through — in order. One page, on your device. No account, no server, no network.

Works from a USB stick, a file:// path, or GitHub Pages. 141 assertions prove the engine.

The state is the story

A book is data: passages, choices, and what those choices change. Nothing is evaluated as code, so a book is readable, reviewable and safe to ship.

01

A choice leads somewhere else

Two choices at one passage lead to two different passages. The engine refuses a choice that does not exist, and shows you the passage you are actually in.

02

The same choices, the same ending

No dice, no clock, no randomness in the engine. Replay the same choices and you get the same ending, the same state and the same trail — every time.

03

The trail is every passage, in order

A return visit is recorded again, not collapsed. The map is a history of your reading, not a list of places that exist.

04

Closed doors are shown closed

When your state closes a choice, the app shows it greyed with the reason — “nerve >= 1 (you have 0)”. You see the book remembering.

05

Your place is kept, or you are told why not

Saved on the device. If storage is full or unavailable the reading continues and the app says the place will not be kept — it does not fail quietly.

06

A broken book is refused, not half-read

The book is compiled before a word is shown: a choice pointing at a missing passage, an unreachable page, a dead end — each is an error, named.

What it does when things go wrong

Every app in this fleet names its failure paths, and tests them. These are this one's, as they are written in the spec.

Bad input

A choice that does not exist in the current passage is refused with the passage shown, rather than advancing into an undefined state. A fractional index, a string, a negative number — all refused, all leave you where you were.

No network

Nothing changes. The book is on the device. The page calls no fetch, opens no socket, and loads no script from another host — asserted in the test suite, not just promised.

Storage full or unavailable

The reading continues. The app says the place will not be kept, offers an export, and does not silently return you to the start on reload.

Corrupt saved state

An unreadable save is reported with the passage it claims and an export of the raw file. The app never resumes at the beginning and presents it as your place.

What it is built on

Two shared kits, copied in so the app runs from file:// with no build step: web-kit for the namespaced device storage, and export-kit for getting a reading off the device as a file.

Support the work

One person's work: no company, no ads, no tracking, no paid tier. If this saved you an afternoon, a contribution keeps the next one coming — any amount, or none.

UPI drsohilboi@ybl  ·  Ko-fi  ·  PayPal  ·  Books  ·  All projects  ·  Email