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 World Population

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

Overview

A process that converts declarative entity definitions from a validated scene configuration into live runtime `Entity` objects stored in a `StateStore`, establishing the initial physical world state before agents are registered or ticks begin.

Description

World population is the bridge between configuration and simulation. A scene config declares entities (spaces, resources, objects, concepts) as `EntityConfig` Pydantic models with flat properties. The populator transforms these into `Entity` dataclass instances — extracting constraints from properties, deep-copying initial state, and adding each entity to the in-memory `StateStore`.

Critically, population handles world entities only. Agents are registered separately via `WorldEngine.register_agent()`, which creates both the entity and the agent profile. This separation ensures the same registration path is used for preset agents (from YAML) and external agents (from HTTP `/register`).

Usage

Use this principle when initializing a new world from a scene config. It runs automatically inside `WorldEngine.__init__()` after the config is loaded and validated. Never call `populate()` directly in production code — always go through `WorldEngine`.

Theoretical Basis

The population step follows a declarative-to-runtime transformation pattern:

# Abstract transformation (NOT real implementation)
for entity_cfg in config.entities:
    props = copy.deepcopy(entity_cfg.properties)
    constraints = props.pop("constraints", {})
    entity = Entity(id=entity_cfg.id, type=entity_cfg.type,
                    _data=props, _constraints=constraints)
    store.add(entity)

The deep copy ensures that the runtime state is isolated from the config schema — mutations during simulation never leak back into the config. Constraints are separated from data properties so the engine can enforce them without polluting the entity's observable state.

Related Pages

Implemented By

Page Connections

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