# `Monty.Context`
[🔗](https://github.com/d-led/ex.tbp.monty/blob/v0.1.0/packages/ex_tbp_monty_core/lib/monty/context.ex#L1)

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.

# `mode`

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

# `t`

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

# `new`

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

A context for the first step of an episode.

# `next`

```elixir
@spec next(t()) :: t()
```

The same context one step later.

# `rng_for`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
