Monty.Context (ExTbpMonty.Core v0.1.0)

Copy Markdown View Source

What a module needs to know about the run it is part of.

Mirrors tbp/monty/context.py::RuntimeContext. Python threads one mutable RandomState through every module; here rng is the handle of the episode's one stream (Monty.Random.Stream), and a module draws from it in the order it is stepped — so the draws are NumPy's, in Monty's order, and a run is still a function of its episode seed.

rng_for/2 is the older arrangement, kept for the sites that have not been moved onto the stream yet (the environment's noise transforms and the transform pipeline of Monty.SensorModules.SensorModule, which draw per module per step). It is a different set of numbers by construction, and docs/monty-differences.md §2.1 lists what is left. The camera's message noise draws from the stream, as Monty's does.

The step is advanced by the coordinator, never by a module.

Summary

Functions

A context for the first step of an episode.

The same context one step later.

A deterministic random stream for one module at this step.

Types

mode()

@type mode() :: :matching | :exploratory

t()

@type t() :: %Monty.Context{
  episode_seed: non_neg_integer(),
  mode: mode(),
  rng: GenServer.server() | nil,
  step: non_neg_integer(),
  suppress_runtime_errors: boolean()
}

Functions

new(episode_seed, opts \\ [])

@spec new(non_neg_integer(), keyword()) :: t()

A context for the first step of an episode.

next(ctx)

@spec next(t()) :: t()

The same context one step later.

rng_for(context, module_id)

@spec rng_for(t(), atom() | String.t()) :: :rand.state()

A deterministic random stream for one module at this step.

Same episode seed, module id and step always give the same numbers; the stream is independent of which other modules drew before it.