Core loop
An event opens, players choose, and a tick resolves all choices at once. The engine rolls the outcome. The LLM only writes the story and picks effects from a menu that the engine allows. Then the engine saves everything in one step.
Use Previous and Next to step through the loop. The diagram marks the current step. The steps wrap around: after step 10 comes step 1 again.
Text version: the 10 steps
- Spawn. The spawner opens events at 00:00. Due follow-up seeds go first. Then a random roll can add a new event (25% per day for world events).
- Choice window. The event card shows 2–4 options and a countdown. Each player picks one option and can change it. The last pick counts.
- Tick. The window closes. The engine collects all choices: counts, weight (influence) and the sect breakdown.
- Engine roll. The engine computes the success chance p and rolls a seeded random number. The same seed always gives the same roll. The roll gives one of five outcome tiers.
- LLM picks from menu. The LLM gets the tier, the counts and a menu of allowed effects. It writes the narration. It picks menu items with a size word: nhẹ (light), vừa (medium) or nặng (heavy). It never sees p or the roll.
- Validate. The engine checks each pick. It rejects off-menu picks and forbidden deaths. It turns size words into numbers and clamps them to the limits. If the LLM output stays invalid, a template replaces it.
- Atomic save. One database transaction saves the state change, the ledger and the receipt (the record of scores, p, roll and changes). A guard on the event state makes a second run do nothing.
- Chronicle. The engine adds one line to the Thiên Hạ Ký (world chronicle). Players see the narration and their own result.
- Follow-ups. A picked follow-up goes into the pending seeds with an absolute date. Threshold rules (for example, prosperity ≤ 20) can also make a seed eligible.
- Reversion. Each day, region values drift back toward their baseline. Changes within ±5 stay. Beyond that, a value moves back by max(1, 10% of the excess) per day. Then the loop starts again.
Under the event loop, the cultivation loop runs all the time. Idle tu vi (cultivation progress) builds up, and players try breakthroughs. A region's spirit density changes how fast everyone there cultivates. So world changes matter to each player.