Skip to content

Latest commit

 

History

History
219 lines (195 loc) · 11.1 KB

DEMO.md

File metadata and controls

219 lines (195 loc) · 11.1 KB

DEMO.md: Build from source

Works on macOS, Linux, and WSL. The backend uses a Makefile for convenience; if you don't have make (or it misbehaves), every step has a plain-command equivalent listed under "No make?" below; that path is fully supported.

Prereqs

  • Python 3.11+ (python3 --version)
  • Node 18+ (node --version)
  • An API key for one LLM provider — OpenAI, Claude (Anthropic), DeepSeek, or Triton AI (UCSD) (see .env.example)

1. Clone and configure

git clone <this repo>
cd rogueforge
cp .env.example .env
# edit .env: pick a provider and set its key.
#   - Triton (default, UCSD):  leave LLM_PROVIDER=triton, set TRITON_API_KEY
#   - OpenAI:                  LLM_PROVIDER=openai,   set OPENAI_API_KEY
#   - Claude (Anthropic):      LLM_PROVIDER=claude,   set ANTHROPIC_API_KEY
#   - DeepSeek:                LLM_PROVIDER=deepseek, set DEEPSEEK_API_KEY
# Each provider has a sensible default model; override with LLM_MODEL if you like.

2. Backend

cd backend
make install      # creates .venv and installs deps
make calibrate    # computes balance coefficients against the StS corpus (~10s)
make test         # 265 unit + integration tests should pass
make backend      # starts uvicorn on :8000

No make? (plain commands, same result)

cd backend
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
python calibrate.py                 # writes data/balance_coefficients.json
python -m pytest -q                 # 265 tests
uvicorn rogueforge.api.main:app --reload --port 8000

On Windows (PowerShell), activate with .venv\Scripts\Activate.ps1 instead of source .venv/bin/activate.

3. Frontend

In a separate terminal:

cd frontend
npm install
npm run dev       # opens on :5173

4. Play

Open http://localhost:5173. A level is a seven-floor branching map:

  1. Title screen → pick a difficulty temper (Embers / Forge / Inferno; it shifts the bands the AI balances foes and rewards into), then either Enter the Spire (instant, classic Forgeborn) or ⚒ Forge a Character: the AI invents a name, story, and a one-of-a-kind 10-card starter deck, optionally from a concept you type ("a venom-blade assassin"). Takes 10-20s; your hero's name shows in the player panel, and 🂠 Deck in the corner nav opens a full deck inspector at any time.
  2. Floor 1 (Combat): always a fight, against the curated Cultist (so the game starts instantly). Card numbers and enemy intents show the real values after buffs/debuffs (a Strike vs. a Vulnerable foe reads 9, in green). If a foe braces, it gains Block you chew through before its HP.
  3. Reward: three AI-forged cards (sometimes one marked ★, a card you loved in a past run, back from your library). Click to bind one, or skip. Optional 1-5 ★ rating under each; rating ≥4★ archives the card so future runs can re-offer it.
  4. Floors 2-4 (the path forks): after each clear you choose your route (combat / event / wayshrine differ per fork; 8 distinct routes per map).
    • Combats are AI-generated foes with their own intent patterns and looks.
    • Events come in nine styles: shrines, gambles, forge rituals, cursed relics… and three playable mini-games: a spinning wheel of fortune, a three-cup shell game, and bone dice, each with weighted prizes and stings (the outcome is a seeded server-side roll; at least one mini-game per map is guaranteed, and you never see the same event or game kind twice in a row). Plain events offer two trade-off choices + walk away; consequences include permanent blessings and card bargains (upgrade / Exhaust changes / cull / duplicate) that open a deck picker.
    • Wayshrines heal 30% or cull up to 2 cards. Rests are capped at 2 per level.
  5. Floor 5 (Elite): an AI-generated elite carrying an AI-generated room modifier: opening tweaks or ongoing rules ("at most 2 attack cards per turn"; the banner states the rule and attack cards grey out at the limit). Tier-gated: the boss room can be harsher, but you're never locked out.
  6. Floor 6 (Wayshrine): guaranteed rest before the final fight.
  7. Floor 7 (Boss): an AI-generated boss with its own room modifier, then a Rare reward and Descend Deeper into endless mode: enemies scale up (HP +20%/level, ATK +12%/level), you heal 75% of lost HP, and a fresh branching map is forged. The run ends only when you fall; every run is logged to the dashboard's Run History.
  8. From level 2 (the ultimate challenge): the boss room becomes a choice. Instead of the forged boss you may face The Unmade, a curated superboss far above every generated band: two actions every turn, always attacking, and an innate Ritual that grows its Strength every turn, a clock that punishes decks that can't close fast. Fell it and you earn a wish: describe the card you want in your own words, and the forge grants three Ancient-rarity interpretations (the highest power band in the game) at whatever costs fit the wish (0-3). Out-of-scope wishes ("strength whenever I lose HP") are translated to the closest real mechanics, never broken cards.

Each level takes ~10-18 minutes. Cards, enemies, events, modifiers (and your character, if forged) are all different every run; each is validated, repaired or rejected, and logged before you see it.

Card types you'll see

Every card carries a parametric SVG illustration: the LLM picks from 16 motifs (blade, hammer, claw, vial, heart, hourglass, chain, wing, crown, …) and the background color encodes the type, so a hand reads at a glance. Ornamentation scales with rarity: Rares get a golden aura + gilt frame, and Ancient wish cards get the most: rotating rays, a breathing aura, and corner gems. Each type owns its mechanics (enforced by the validator):

  • Attack (red): the only type that deals damage, sometimes with a debuff rider (Vulnerable / Weak / Frail).
  • Skill (green): block, draw, energy, healing, debuffs, and the only type that applies Poison.
  • Power (purple): one-shot card that grants a lasting buff, then exhausts. The only home of the persistent buffs (Strength, Metallicize, Ritual, Regen, Thorns). Powers can roll any cost, but cheap ones are budgeted leaner. Uncommon (elite) and Rare (boss) rewards always include one.

Mechanics you'll see on generated cards

Beyond plain damage/block, the LLM draws from a whitelisted mechanic set: multi-hit attacks; card draw; the debuffs Vulnerable (+50% damage taken), Weak (−25% damage dealt; apply it to a foe to blunt its hits), and Frail (−25% block, including an enemy's Block); and the turn-tick effects Poison (a real 4-7 stack dose, like StS Deadly Poison), Regen, Metallicize, Ritual, and Thorns. A card may also be Innate (it starts in your opening hand). Each is balance-scored before you see it, and because the band is rarity-aware, Rare (boss) rewards are pulled toward the strong end of their budget.

Eval Dashboard

Top-right corner of every screen has a small ⊞ Forge Records button. Click it to open the dashboard, which shows:

  • Total candidates, generation events, average latency, total tokens
  • Stacked accept / repair / reject bar
  • Power-score histogram (16 buckets, color-coded by verdict)
  • A per-content-type breakdown (card / enemy / event / room_modifier / character)
  • Player-rating stats (mean ★ + distribution)
  • Card Library: your cross-run collection (origin, best ★, times saved) and how often the forge re-offered from it
  • Runs by Temper: your difficulty mix
  • Run History: runs played, best level reached, and a per-run log
  • Recent Repairs: the exact clamp the validator applied, per card
  • Recent rejections with their reasons
  • Recent generation events with verdict pills + provenance chips (event style requested; library re-offer slot)

Auto-refreshes every 5 seconds while you play in another tab. Switching between the dashboard and the run preserves your current combat state: the runId is lifted to the App level and persisted to localStorage so even a page refresh drops you back into the same run.

Raw eval log

Same data is also queryable directly:

sqlite3 backend/rogueforge.db <<EOF
.headers on
SELECT verdict, COUNT(*) AS n FROM candidate_records GROUP BY verdict;
SELECT power_score, power_band_lo, power_band_hi, verdict FROM candidate_records ORDER BY rowid DESC LIMIT 10;
EOF

A JSONL tail of every event is also at backend/rogueforge_events.jsonl for grep.

Troubleshooting

  • All rewards say "Steady Jab" → That's the hand-curated fallback. Your LLM provider isn't reaching you (check LLM_PROVIDER and the matching key in .env) or it's failing every card three times in a row (very rare with current calibration; check backend/rogueforge_events.jsonl for rejection reasons).
  • CORS errors → Backend allows http://localhost:5173 exactly. Use that origin, not 127.0.0.1:5173.
  • Backend won't start → Run make install once first. Needs Python 3.11+.
  • Make test fails on first run → Run make calibrate first; tests assume the coefficients file exists.
  • "The run has faded" screen on refresh → Your persisted runId points at a run that no longer exists in the local SQLite (e.g., you deleted backend/rogueforge.db). The frontend silently clears the stale id and drops you at the title screen; just click Enter the Spire again.

API endpoints

Path Purpose
POST /runs Start a new run ({difficulty, forge_character, character_concept})
GET /runs/{id} Fetch current state
POST /runs/{id}/combat/action Play a card or end turn
POST /runs/{id}/reward/choose Bind a reward card and advance
POST /runs/{id}/reward/skip Skip the reward and advance
POST /runs/{id}/path/choose Branching map: walk into a chosen fork node
POST /runs/{id}/boss/challenge Level 2+: fight the forged boss or The Unmade
POST /runs/{id}/wish After felling The Unmade: describe a card → 3 Ancient rewards
POST /runs/{id}/event/choose Pick an event choice
POST /runs/{id}/event/play Play the event's mini-game (server-side seeded roll)
POST /runs/{id}/card/select Resolve an event's card modification on a chosen card (or decline)
POST /runs/{id}/rest/rest Rest at a wayshrine (heal 30%)
POST /runs/{id}/rest/skip Press onward without healing
POST /runs/{id}/rest/remove Cull up to 2 cards from the deck at a wayshrine
POST /runs/{id}/descend Endless mode: descend to the next, harder level
POST /runs/{id}/rate Submit a 1-5 star rating (≥4★ archives to the library)
GET /eval/summary Dashboard rollups (incl. library + difficulty mix)
GET /eval/events?limit= Recent generation events
GET /eval/rejections?limit= Rejected candidates with reasons
GET /eval/repairs?limit= Repaired candidates with the exact clamps
GET /eval/library?limit= The cross-run card library
GET /docs OpenAPI docs (auto-generated)