Implementation:AIScientists Dev WorldSeed list ops
| 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"