# `Monty.Simulators.Port.Environment`
[🔗](https://github.com/d-led/ex.tbp.monty/blob/v0.1.0/packages/ex_tbp_monty_core/lib/monty/simulators/port/environment.ex#L1)

A simulator process on the other side of this port.

The world Monty needs is Python — MuJoCo or Habitat — and it cannot run in the
BEAM. This is the Elixir half of that boundary: it owns the operating-system
process, sends it one request at a time, and answers the payloads
`Monty.Runtime.Step` already expects (`observations`,
`proprioceptive_state`). What the two say to each other is
`Monty.Simulators.Port.Protocol`.

One request in flight at a time. A simulator advances its own state, so two
steps cannot be interleaved, and a step that does not answer in time is an
error rather than something to carry on past: a step that silently produced no
observation would be counted as a step the model took.

Nothing here is a ported module — Monty's simulators are not part of the core
— so it does not appear in the module map.

# `options`

```elixir
@type options() :: [
  command: [String.t()],
  sensor_ids: [String.t()],
  timeout: timeout(),
  name: GenServer.name() | nil
]
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `reset`

```elixir
@spec reset(GenServer.server()) :: {:ok, map()} | {:error, term()}
```

Starts the simulator afresh, for the first step of an episode.

Answers what the world said about that episode — the target it chose, when it
chooses one — because a world that samples an object is the only one that knows
which.

# `start_link`

```elixir
@spec start_link(options()) :: GenServer.on_start()
```

# `step`

```elixir
@spec step(GenServer.server(), [Monty.Frameworks.Actions.Action.t()]) ::
  {:ok, map(), map()} | {:error, term()}
```

One step of the world: the actions the model chose, the observation it gets.

# `stop`

```elixir
@spec stop(GenServer.server()) :: :ok
```

Closes the port: the simulator process is stopped with it.

---

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