Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:AIScientists Dev WorldSeed DM Context Assembly

From Leeroopedia
Knowledge Sources
Domains LLM, Game_AI
Last Updated 2026-10-26 18:00 GMT

Overview

A context-assembly process that gathers omniscient world state — all entities, recent events, target entity history, scene description, and domain knowledge — into a structured `DMContext` dataclass for LLM-based Dungeon Master judgment.

Description

The DM in WorldSeed is omniscient: it sees every entity, every recent event, and all domain knowledge. The `DMContextBuilder` assembles this information into a `DMContext` dataclass with plain-text formatting optimized for LLM comprehension.

Key design decisions:

  • No filtering: The DM sees everything, unlike agents who are limited by perception rules. This ensures the DM can make physically consistent judgments.
  • Plain text formatting: Entities are formatted as `entity_id (type): key: value` blocks, grouped by agents vs. others. Events are one-line summaries with tick numbers.
  • Target history: Recent events involving the action's target entity are included separately, helping the DM understand context (e.g., "air_filter has been maintained 5 times already").
  • Language support: The builder carries a language code that controls narrative language output.

The builder also supports a GM resolve mode for natural-language commands from the Game Master, using a synthetic action and broader allowed operators.

Usage

Use this principle to understand what information the LLM DM receives. The `DMContextBuilder` is constructed once in `TickEngine.__init__()` and used for all DM calls within a tick.

Theoretical Basis

Context assembly follows an omniscient observer pattern:

# Abstract assembly (NOT real implementation)
def build(action, dm_config, tick):
    return DMContext(
        action=action,
        world_state=format_all_entities(),  # plain text, grouped
        recent_events=format_events(since=tick-5),
        target_history=format_target_events(action.params["target"]),
        scene_description=config.scene.description,
        dm_knowledge=config.scene.dm_knowledge,
        hint=dm_config.hint,
        allowed_ops=dm_config.allowed_ops,
        max_effects=dm_config.max_effects,
    )

The recent-events lookback is 5 ticks (`_RECENT_EVENTS_LOOKBACK = 5`). Target history includes the last 10 relevant events for the target entity.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment