Skip to content
proto

Environment

extendsProtocol
Environment()

What a rollout needs an environment to do.

Implement this on your own simulator; nothing here touches an outside package, and no base class has to be inherited — a plain object with these two methods satisfies it.

Notes

Actions are expected in (-1, 1), which is what a tanh-squashed policy emits. Rescale inside your environment rather than outside it, so the policy never has to know the units.

Examples

>>> import lucid
>>> from lucid.utils.rollout import Environment, StepResult
>>> class Trivial:
...     def reset(self):
...         self.t = 0
...         return lucid.zeros((3, 64, 64))
...     def step(self, action):
...         self.t += 1
...         return StepResult(lucid.zeros((3, 64, 64)), 0.0, False, self.t >= 5)
>>> isinstance(Trivial(), Environment)
True

Used by 2

Instance methods

2
fn

step

→StepResult
step(action: Tensor)

Advance one step.

Parameters

actionTensor
(action_dim,), expected in (-1, 1).

Returns

StepResult

Observation, reward, and the two end-of-episode flags.