simulatecraft.core¶
simulatecraft.core
¶
Core simulation loop: agents, environments, events, and the runner.
Agent
¶
Bases: BaseModel
Wraps a Brain; the runner only ever talks to this interface.
on_human_message
¶
Hook for human-in-the-loop chat. Brains may override via attribute.
Environment
¶
Bases: ABC
Owns all mutable simulation state.
Contract
observemay return partial state (partial observability is supported).stepmutates state for one agent and returns a StepResult.agent_idsmust reflect dynamic membership (spawn/death/exit).tickadvances environment-owned state (weather, NPC timers, physics).
Source code in src/simulatecraft/core/environment.py
observe
abstractmethod
¶
observe(agent_id: str) -> Observation | Awaitable[Observation]
step
abstractmethod
¶
step(agent_id: str, action: Action) -> StepResult | Awaitable[StepResult]
tick
¶
reset
¶
Snapshot
¶
Bases: BaseModel
Domain-agnostic full-state snapshot served over REST / rendered by viewers.
EventBus
¶
Ordered pub/sub with isolated subscriber errors and an inbound queue.
Source code in src/simulatecraft/core/events.py
publish_inbound
¶
Queue an inbound event AND mirror it onto the outbound bus for viewers.
Source code in src/simulatecraft/core/events.py
HumanChat
¶
Bases: Event
Inbound: a human sent a message, optionally targeting one agent.
HumanControl
¶
Bases: Event
Inbound: viewer control commands (pause/resume/step/stop/reset).
Runner
dataclass
¶
Runner(environment: Environment, agents: list[Agent] = list(), bus: EventBus = EventBus(), config: RunnerConfig = RunnerConfig(), _running: bool = False, _paused: bool = False, _step_requests: int = 0, _stop_reason: str = '', _control_lock: Lock = Lock())
remove_agent
¶
Remove an agent from the runner (does not disconnect Minecraft).
Source code in src/simulatecraft/core/runner.py
start
async
¶
Run until max_ticks / empty env / stop(). Returns when finished.
Source code in src/simulatecraft/core/runner.py
set_tick_rate
¶
Ticks per second. None = run as fast as possible.
Source code in src/simulatecraft/core/runner.py
adjust_tick_rate
¶
Multiply current rate (e.g. 2.0 faster, 0.5 slower). Overspeed → unlimited.
Source code in src/simulatecraft/core/runner.py
step_once
async
¶
Execute exactly one tick regardless of pause state.
RunnerConfig
¶
Bases: BaseModel
tick_rate=None runs as fast as possible (batch mode); a number paces realtime.
Action
¶
Bases: StrictModel
Base class for domain-specific actions.
Subclass this in your environment package (e.g. MoveAction(kind="move"))
and pass the discriminated union to brains so LLM/RL outputs arrive validated.
AgentState
¶
Bases: StrictModel
Flexible per-agent state container (position, inventory, mood, ...).
Observation
¶
Bases: StrictModel
Structured state visible to one agent. Supports partial observability.
The data payload is domain-specific; define typed subclasses for richer
schemas (e.g. GridObservation) when you want validation at the edges.
StepResult
¶
Bases: StrictModel
Outcome of applying one action for one agent.