src.environment.parallelenv.worker.base

Module Contents

Classes

EnvWorker

An abstract worker for an environment.

API

class src.environment.parallelenv.worker.base.EnvWorker(env_fn: Callable[[], gym.Env])[source]

Bases: abc.ABC

An abstract worker for an environment.

Initialization

abstractmethod get_env_attr(key: str) Any[source]
abstractmethod set_env_attr(key: str, value: Any) None[source]
send(action: Optional[numpy.ndarray]) None[source]

Send action signal to low-level worker.

When action is None, it indicates sending “reset” signal; otherwise it indicates “step” signal. The paired return value from “recv” function is determined by such kind of different signal.

send_reset() None[source]
recv() Union[Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray], numpy.ndarray][source]

Receive result from low-level worker.

If the last “send” function sends a NULL action, it only returns a single observation; otherwise it returns a tuple of (obs, rew, done, info).

reset() numpy.ndarray[source]
step(action: numpy.ndarray) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray][source]

Perform one timestep of the environment’s dynamic.

“send” and “recv” are coupled in sync simulation, so users only call “step” function. But they can be called separately in async simulation, i.e. someone calls “send” first, and calls “recv” later.

abstractmethod static wait(workers: List[src.environment.parallelenv.worker.base.EnvWorker], wait_num: int, timeout: Optional[float] = None) List[src.environment.parallelenv.worker.base.EnvWorker][source]

Given a list of workers, return those ready ones.

abstractmethod render(**kwargs: Any) Any[source]

Render the environment.

abstractmethod close_env() None[source]
close() None[source]