Inspiration

Every "AI game" we tried turned out to be a chatbot in a costume: infinite text, zero stakes. Meanwhile the fantasy we actually wanted — what if I woke up as a real historical figure, already knowing everything that was supposed to happen next? — had never been built as a game with real mechanics. So we made foreknowledge a resource, history a pressure, and death a real ending. Your own knowledge that Napoleon shouldn't march on Moscow becomes a skill you can spend.

What it does

EPITAPH (千秋) is an AI-driven historical narrative roguelite. You die, wake in The Archive, and choose to be reborn as a documented historical figure — Beethoven in 1802, Wu Zetian in 684, Marie Curie, Napoleon, Harriet Tubman — at a pivotal moment of their life. You arrive with two things: your modern memory, and that person's already-written future, dealt to you as a deck of decaying prophecy cards.

  • Follow the record and history rewards you; tear it up and the future becomes unreliable.
  • Survive along two axes — HP and SAN (心神). Let SAN hit zero and the body's "fate" assimilates you, and you lose yourself.
  • When a life ends, EPITAPH renders an Epitaph Diff: the real encyclopedia entry side by side with the life you actually played, every changed sentence highlighted and traced back to a source. That diff is your score, your story, and your shareable screenshot.
  • Points flow back to The Archive to buy soul talents, then you reincarnate into the next life. Every life is finite; reincarnation is endless.

Play at three fidelities on the same world and the same truth: Chronicle (8–15 min offline auto-biography), Fate Cards (Reigns-style, controller-first, offline), and Immersive (90–180 min full RPG driven by a live model).

How we built it

A TypeScript pnpm monorepo (React 19 + Vite, Electron shell, Fastify API) with one hard rule: commit-then-narrate. Mechanical truth lives in a deterministic, event-sourced engine backed by SQLite with a SHA-256 hash chain; the LLM only ever narrates results that are already committed. Replays reproduce exact scores without re-calling any model — so runs can be verified and ranked (Ed25519-signed receipts; Official / Open / Unranked tiers).

On top of that sits an OpenAI-first model layer:

  • provider-kit speaks OpenAI Chat Completions and the native Responses API (store:false, JSON-Schema mapped to text.format), plus Anthropic, Gemini, and a bring-your-own-agent CLI path.
  • Codex runs as an in-game agent (model gpt-5.6-sol); Codex Imagegen authors the historical portraits and scene art.
  • An MCP server exposes the whole game as tools — start_life, play_fate_card, end_life, reincarnate, and more — so Codex or Claude Code can literally play EPITAPH as an agent, while the deterministic engine stays authoritative and the agent can never grant itself rewards or rewrite its own death.
  • NPCs are A2A character agents with an A2UI surface; with no API key they fall back to a zero-cost deterministic director.

Challenges we ran into

The hardest problem was making an AI game that is verifiable. If a model can touch state, you can't rank it and you can't trust it. Enforcing "provider proposes, engine decides" — compare-and-swap on an expected world version, idempotency keys, hash-chained events, and full replay — took most of our engineering. Security was the second front: server-only providers, secrets brokered through the native macOS Keychain (never in args, env, or logs), shell:false, Electron fuses, and ASAR integrity.

Accomplishments that we're proud of

An architecture where AI has narration authority but zero mechanical authority — including AI-generated "endless chapters" that extend the game past the authored script while every mechanical consequence is compiled deterministically server-side (with a prepared-chapter fallback if the model fails). One plugin package runs in both Codex and Claude Code. Full English / 简体中文 switching mid-life, without a restart.

What we learned

That the fun has to survive without the AI. Designing Chronicle and Fate Cards to be fully playable offline forced the core mechanics to be genuinely good on their own — and turned frontier-model cost into a lever we control rather than a tax paid on every action.

What's next for EPITAPH

More lives and entry points, a live hosted "Official" ranked tier, Workshop UGC world packs with fail-closed moderation, and a Steam launch. The Archive has a mystery of its own — we're just getting started.

Built With

Share this project:

Updates