Skip to content

simulatecraft.brains.base

simulatecraft.brains.base

Brain interface: the swappable decision-making core of an Agent.

Contract: decide(observation) -> Action and update(step_result). Both may be sync or async; the Agent wrapper handles either.

Brain

Bases: ABC, Generic[ObsT]

A policy. Scripted rules, RL policies, and LLM reasoning all implement this.

decide abstractmethod

decide(observation: ObsT) -> Action | Any

Choose an action for this observation. May be a coroutine function.

Source code in src/simulatecraft/brains/base.py
@abstractmethod
def decide(self, observation: ObsT) -> Action | Any:
    """Choose an action for this observation. May be a coroutine function."""

update

update(step_result: StepResult) -> None | Any

Learn / log / no-op after the action is applied. May be a coroutine.

Source code in src/simulatecraft/brains/base.py
def update(self, step_result: StepResult) -> None | Any:
    """Learn / log / no-op after the action is applied. May be a coroutine."""

on_human_message

on_human_message(sender: str, text: str) -> None

Optional sync hook for human-in-the-loop chat (queue it for next decide).

Source code in src/simulatecraft/brains/base.py
def on_human_message(self, sender: str, text: str) -> None:
    """Optional sync hook for human-in-the-loop chat (queue it for next decide)."""