Base Python interfaces for samplers and environments.
| Alias | Type | Description |
|---|---|---|
Context |
dict[str, Any] |
Generic payload used to initialize an environment. |
StepResult |
tuple[Any, float, bool, bool, dict[str, Any]] |
Step output (observation, reward, done, truncated, info). |
Interface for context generation.
Samples one context payload for a requested difficulty level.
Parameters
Name Type Description levelintDifficulty or depth requested by the caller.
Optional feedback hook for adaptive samplers.
Parameters
Name Type Description metricsdict[str, Any]Metrics from training or evaluation.
Interface for interactive environments.
Resets environment state from a context payload.
Applies one action and returns
(obs, reward, done, truncated, info).
from framework import ContextSampler, Environment
class MySampler(ContextSampler):
def sample(self, level: int):
return {"level": level}
class MyEnv(Environment):
def reset(self, context):
return context
def step(self, action):
return action, 0.0, False, False, {}
sampler = MySampler()
env = MyEnv()
print(sampler.sample(2))
print(env.step({"a": 1}))Expected output:
{'level': 2}
({'a': 1}, 0.0, False, False, {})