Skip to content

fernforge-arcade/worldline

Repository files navigation

Worldline

A browser 3D action-RPG whose world writes itself. A local LLM (Ollama) is the content pipeline: NPCs, their dialogue, quests, item names/flavor, creature lore, and free-text action outcomes are all authored live as you play — seeded and cached so the world stays consistent, and masked behind pre-generation so gameplay never blocks on the model.

This is the implementation of WORLDLINE_PLAN.md.

▶ Play in your browser

fernforge.github.io/worldline

⚠️ Heads up — the live AI features won't work on the hosted page. GitHub Pages can only serve the static game; it can't run a local language model. On the hosted build the world is fully playable but uses Worldline's deterministic fallback teller for names, quests and lore. To get the headline feature — infinite content written live by an LLM — you have to run it locally with Ollama (see Run the full AI version below).

Run the full AI version

Requires Node 20+ and a running Ollama with a small model (qwen2.5-coder:3b recommended; llama3.2:1b works too).

npm install

# Development (Vite dev server + AI broker, hot reload):
npm run dev            # → http://localhost:5173

# Standalone (build once, single server serves client + AI):
npm run build
npm start              # → http://localhost:8787

If Ollama isn't running, the game still plays — it falls back to deterministic template content, so nothing stalls. With Ollama up, content becomes AI-authored.

Controls

  • WASD move · mouse look (click to capture) · Shift sprint
  • E talk to townsfolk · read weathered lore shrines · Space / left-click attack
  • I inventory & character · J quest journal & your worldline · B bestiary · T "do anything"
  • Esc close panels

What's in it

  • Procedural world — value-noise terrain, six biomes, water, day/night + colour-graded sky, toon/ink art style, instanced forests & rock fields, four procedurally-built towns.
  • Live AI dungeon-master
    • NPCs authored on approach (name, role, mood, greeting, backstory), cached by seed.
    • Reactive dialogue — say anything; the NPC answers in character, aware of your reputation.
    • Quests generated from world state + your past deeds, wired to real objectives & rewards.
    • Generated item names/flavor on loot.
    • Living bestiary — felling a new kind of creature prompts the LLM to pen its lore (B).
    • Lore shrines — weathered stones across the map; read one and the LLM writes a fragment of regional history on the spot (cached & saved).
    • "Do anything" intent box — describe any action; the world adjudicates the outcome.
  • RPG systems — stats/leveling/skill growth, inventory & equipment, melee combat with hit-stop/knockback/camera-shake/damage numbers, gold & loot, potions, death & respawn.
  • The Worldline — a living timeline of your deeds that feeds back into NPC reactions.
  • Persistence — autosaves to localStorage; "Continue your worldline" resumes everything.

Architecture

client/   Three.js + TS game (engine, world, entities, systems, render, ui, ai)
server/   Node broker (no deps): Ollama proxy, JSON-schema generators, on-disk cache, warmup
shared/   deterministic RNG + content templates/word-banks (used by client AND server)
test/     headless logic + scene-construction tests (no browser needed)

Why it works on a slow CPU

Local CPU LLMs are slow, and Ollama keeps only one model resident — so Worldline uses a single hot model (no swap thrash), warms it on startup, pre-generates a town's NPCs as you approach, caches every result by seed (revisits are instant + consistent), enforces strict JSON schemas, and falls back to templates on timeout so the critical path never blocks.

Tests

npm run typecheck   # tsc
npm test            # 10 logic tests + 6 headless scene-construction tests

The actual WebGL draw must be seen in a browser; everything up to it is covered headlessly.

About

A browser 3D action-RPG whose world writes itself — infinite content generated live by a local LLM (Ollama).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors