Principle:AIScientists Dev WorldSeed Tick Execution
| Knowledge Sources | |
|---|---|
| Domains | Simulation, Concurrency |
| Last Updated | 2026-10-26 18:00 GMT |
Overview
A multi-phase tick processing loop that drains queued actions, executes mechanical effects sequentially, resolves DM judgments in parallel, applies consequences, delivers perception, and persists state — advancing the simulation by one discrete time step.
Description
The tick is the atomic unit of simulation time in WorldSeed. Each call to `TickEngine.step_async()` increments the tick counter and processes all activity queued during the previous tick. The execution is structured in phases to balance correctness with performance:
- Phase 0 — Tick boundary ops: Apply queued GM entity mutations (set/remove) deferred from the previous tick.
- Phase 1 — Mechanical effects: Validate and execute all queued actions sequentially (sub-millisecond each). Actions requiring DM are separated for async resolution.
- Phase 2 — DM resolution: DM-pending actions are grouped by target entity to avoid conflicts, then resolved in parallel via `asyncio.gather`. Rate-limited to `MAX_DM_CALLS_PER_TICK = 10` and budget-constrained by `max_dm_calls`.
- Phase 3 — GM resolve commands: Process pending GM natural-language commands at the tick boundary.
- Post-actions: Auto-tick effects, consequence scanning (with cascade re-scanning up to 10 passes), highlight scanning, perception delivery, EventLog cleanup, and state persistence.
The three-phase split (mechanical → DM parallel → DM apply) ensures DM calls see a consistent snapshot while allowing independent targets to resolve concurrently.
Usage
Use this principle to advance simulation time. `WorldEngine.step_async()` is the public entry point, which delegates to `TickEngine.step_async()`. The background tick runner (`tick_runner.py`) calls this in a loop when auto-tick is enabled.
Theoretical Basis
The tick loop follows a phase-structured execution model that separates deterministic operations from non-deterministic LLM calls:
# Abstract phases (NOT real implementation)
tick += 1
apply_queued_mutations() # Phase 0
actions = queue.drain() # Phase 1: mechanical
dm_pending = []
for action in actions:
result, dm_info = process_mechanical(action)
if dm_info:
dm_pending.append(dm_info)
# Phase 2: parallel DM (grouped by target)
groups = group_by_target(dm_pending)
await asyncio.gather(*[resolve_group(g) for g in groups])
# Post: consequences, perception, persistence
consequence_scanner.scan(tick)
perceiver.deliver(tick)
recorder.save_state(entities, tick)
The grouping by target ensures causal ordering: if two actions affect the same entity, the DM sees each result before judging the next. Independent targets run in parallel for throughput.