Tu Chân Giới · docs

LLM narrator

The LLM writes the story. It never decides numbers or outcomes. If it fails, a template takes over, and the game never waits for it.

The LLM may

  • Write the Vietnamese narration (about 250 words for a world event).
  • Pick effects from the engine's menu, by id.
  • Give each pick a size word: nhẹ (light), vừa (medium) or nặng (heavy).
  • Choose one follow-up from the follow-up menu.
  • In combat, describe one log entry in 1–3 sentences.

The LLM may not

  • See p or the roll, or change the tier.
  • Add effects or targets that are not on the menu.
  • Create currency or items, change a realm or kill a player.
  • Kill an NPC unless the tier is bại or thảm bại and the NPC is not protected.
  • Write digits in combat narration (prototype).
  • State a combat outcome except through fixed phrases that the engine fills in (C7, proposed).

Fallbacks

FailureWhat the engine does
Invalid JSON or wrong shapeOne repair retry with the errors fed back (prototype), then the tier template. The spec allows up to 2 repairs.
Network or provider errorTemplate at once. The prototype does not resend the request.
Pick not on the menu, or picked twiceRejected and logged.
Summed change over the limitClamped to the limit and logged.
Forbidden NPC deathRejected.
Combat line with a digitTemplate, marked 〔bản mẫu · numbers〕.
Daily budget at 80% / 100%Personal events switch to templates / everything switches to templates.

The engine state commits either way. The LLM call log stores the failure kind and the number of attempts.

Cost

Spec estimate for 1,000 daily players: about 160 calls a day, about 0.95 M input tokens and 0.4 M output tokens. On cheap models that is about $1–15 a day. The default cap is $150 a month (unconfirmed). World and daily events cost about the same at any scale, because only aggregated data reaches the LLM.

Cost levers, in order of use:

  1. Use batch or off-peak APIs for daily and world ticks (about 50% cheaper).
  2. Cache the static system prompt and world bible.
  3. Batch more personal events per call (25 → 50).
  4. Use the cheapest model for personal events.
  5. Cap text length; share epilogues per option.
  6. Trip the daily budget breaker (see Fallbacks).
  7. Lower the personal spawn rate.

In combat, C7 (proposed) cuts narrator calls from one per log entry (about 15–20 a fight) to about 5.