a web thing that lets you play flexible survival with an llm probably it's slop
  • TypeScript 74.6%
  • Vue 14.7%
  • CSS 10.3%
  • HTML 0.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-21 18:01:33 +02:00
.vite-hooks spike: LLM client for Flexible Survival 2026-11-21 16:53:50 +02:00
public spike: LLM client for Flexible Survival 2026-11-21 16:53:50 +02:00
scripts spike: LLM client for Flexible Survival 2026-11-21 16:53:50 +02:00
server journalling it up 2026-11-21 17:50:27 +02:00
shared spike: LLM client for Flexible Survival 2026-11-21 16:53:50 +02:00
src journalling it up 2026-11-21 17:50:27 +02:00
.gitignore spike: LLM client for Flexible Survival 2026-11-21 16:53:50 +02:00
AGENTS.md spike: LLM client for Flexible Survival 2026-11-21 16:53:50 +02:00
index.html spike: LLM client for Flexible Survival 2026-11-21 16:53:50 +02:00
package.json spike: LLM client for Flexible Survival 2026-11-21 16:53:50 +02:00
pnpm-lock.yaml spike: LLM client for Flexible Survival 2026-11-21 16:53:50 +02:00
pnpm-workspace.yaml spike: LLM client for Flexible Survival 2026-11-21 16:53:50 +02:00
README.md align art in readme 2026-11-21 18:01:33 +02:00
tsconfig.json spike: LLM client for Flexible Survival 2026-11-21 16:53:50 +02:00
vite.config.ts spike: LLM client for Flexible Survival 2026-11-21 16:53:50 +02:00

fetishbot

An LLM plays Flexible Survival — a 597 MB Glulx text adventure — and you get a window into what it is doing.

bwrap ── emglken (glulxe + RemGlk) ── GlkOte JSON ──┐
                                                    │
                       screen model ── status line ─┴─ agent loop ── /v1/chat/completions
                            │                                │
                         blorb art                        turn log
                            └──────── SSE ── Vue UI ─────────┘

Run it

ln -s ~/wherever/it/is/"Flexible Survival.gblorb" data/game.gblorb   # or set FS_GAME
vp install                   # yes we use viteplus because i'm a lazy slut
vp dev                       # UI + API on http://localhost:5173

Point the agent at any OpenAI-compatible endpoint in the config tab (or set FS_BASE_URL, FS_MODEL, FS_API_KEY). Nothing is required to explore the game by hand: the composer at the bottom of the feed drives the interpreter directly.

The agent tab runs the loop on its own (start/stop), or advances it one model call at a time with single turn. The same tab exposes the assembled prompt, the raw reply, and — when the endpoint returns reasoning_content or reasoning alongside the message — the model's chain-of-thought for the last call.

The journal panel is the model's own memory: it writes the fixed sections (where, who, have, goals, notes) through tools, the harness prints them back verbatim every turn, and nothing summarises them behind its back. When the journal has gone six turns without a change it gets a one-line nudge in the prompt and is otherwise left alone.

vpx scripts/play.ts --cmds "no,0,yes,0,50,look,score"   # headless, prints turn stats
vpx scripts/play.ts                                     # interactive REPL
vpx server/index.ts                                     # prod: built UI + API on :8787

Environment: FS_GAME, FS_DATA_DIR, FS_SANDBOX=0 (disable bwrap), PORT.

What the game needs before an LLM can play it

These were found by driving the real story file, and each one is a bug the naive "spawn interpreter, read stdout" loop would hit.

Talk GlkOte, not the terminal. emglken ships glulxe built against RemGlk, so --rem speaks newline-delimited JSON. The status window and graphics draws arrive as structured objects instead of ANSI soup. server/vm.ts spawns it, server/screen.ts reimplements the display model: buffer windows are append-only between clears, so a turn's text is just the delta.

One command is not one update. The game pauses for a keypress ("Waiting for Input", on by default) partway through a room description. server/game.ts answers those char prompts with a space and keeps collecting, so a turn stays a turn. Sending an empty string to a char prompt deadlocks the VM — a real thing that happened.

Run wide. The status line is laid out as right-aligned panels; below ~160 columns they overlap and it degrades to LocatiName: Pick one? | Pronouns: .... The default is 200 columns for exactly this reason.

The game does not start in the game. A fresh session opens on a numbered character-creation menu, and an agent handed that menu will answer it with prose. Every session runs a fixed prologue first (PROLOGUE in server/game.ts) so the first agent turn is already a real command. Toggle it in the config tab to drive the menu yourself.

Graphics are cheap. The blorb carries 1252 pictures, but the interpreter only ever names them by resource index. server/blorb.ts reads the resource index once and serves /api/art/:n straight out of the file — no 597 MB copy, no extraction step. The game draws an isometric map of the current area, which the UI shows in the Scene panel.

Turns are big. Measured over the opening: 1048 chars per turn on average, 2832 at the worst, ≈260 tokens of raw game text. That is the whole reason server/agent.ts has a character budget and re-sends only the tail of the transcript, and why the model gets a 1200-character journal it authors itself instead of an ever-growing transcript.

The parser is hostile. Rejections are the normal case, not an error. Every turn is flagged when the game complains, and the agent gets one cheap correction retry before it spends another full turn.

Some commands are off limits. save/restore/restart/quit/script/transcript would either clobber the session or write files, so they are blocked at the harness layer even though the game offers them as buttons.

Layout

Path Role
server/vm.ts spawns the interpreter (optionally under bwrap), JSON framing, exit detection
server/screen.ts GlkOte display model: buffers, status grid, last image
server/game.ts one session: command → pump pauses → turn record
server/blorb.ts resource index + on-demand image reads
server/agent.ts prompt assembly, tool loop, command extraction, transcript budgeting
server/journal.ts the agent's five-section memory: caps, rendering, event log, rewind
server/api.ts routes, SSE fan-out, JSONL turn log in data/sessions/
src/ Vue UI: feed, status, scene art, prompt inspector, config

Sandbox

The interpreter runs under bwrap by default:

--ro-bind / / --dev-bind /dev /dev --proc /proc --tmpfs /tmp
--unshare-net --unshare-pid --die-with-parent --new-session --chdir /tmp

Read-only filesystem, no network, private /tmp for whatever the game tries to write.

Not done yet

  • No undo/rollback discipline: death is detected only as "dead" or a bad ending, and saves are 44 MB apiece so the plan is the VM's undo stack plus a matching journal rewind. The journal half exists (journal.rewind(turn) replays the event log), the VM half does not.
  • No map builder. Room names and exits are in the transcript; nothing accumulates them.
  • No objective besides whatever you type in the goal box, and no scoring run-to-run.