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

Implementation:AIScientists Dev WorldSeed list ops

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

Overview

Concrete DSL effect operators for list manipulation — append, remove, and random pop — provided by the WorldSeed library.

Description

The list_ops module registers three effect operators: `list_append` adds a value to a list property (creating the list if it is `None`); `list_remove` removes the first occurrence of a value from a list; `list_pop_random` picks a random element from a source list, removes it, and appends it to a target list. All three use `parse_target` to resolve entity/property paths and `nested_get` to traverse nested dict structures.

Usage

Use these operators in scene YAML when game logic requires list mutations — e.g., drawing cards from a deck (`list_pop_random`), adding items to inventory (`list_append`), or removing spent resources (`list_remove`).

Code Reference

Source Location

  • Repository: WorldSeed
  • File: src/worldseed/dsl/effects/list_ops.py

Signature

def _exec_list_append(effect: EffectConfig, store: StateStore, event_log: EventLog, ctx: dict[str, Any], tick: int) -> None:
    """Append a value to a list property. Creates list if property is None."""

def _exec_list_remove(effect: EffectConfig, store: StateStore, event_log: EventLog, ctx: dict[str, Any], tick: int) -> None:
    """Remove first occurrence of a value from a list property."""

def _exec_list_pop_random(effect: EffectConfig, store: StateStore, event_log: EventLog, ctx: dict[str, Any], tick: int) -> None:
    """Randomly remove an element from source list and append to target list."""

Import

# Auto-registered on import of the effects package:
# import worldseed.dsl.effects  # registers "list_append", "list_remove", "list_pop_random"

I/O Contract

Inputs

Name Type Required Description
effect.target str Yes Dot-path to the list property (e.g. `$agent.hand`)
effect.value Any Yes (append/remove) Value to add or remove
effect.source str Yes (pop_random) Dot-path to source list (e.g. `deck.cards`)

Outputs

Name Type Description
side effect None Mutates list properties in the state store

Usage Examples

# Draw a card: random pop from deck, append to agent's hand
- operator: list_pop_random
  source: "deck.cards"
  target: "$agent.hand"

# Add an item to inventory
- operator: list_append
  target: "$agent.inventory"
  value: "sword"

# Remove a spent resource
- operator: list_remove
  target: "potions.available"
  value: "healing"

Related Pages

Implements Principle

Requires Environment

Page Connections

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