rldurham.seed_everything

rldurham.seed_everything(seed=None, env=None, seed_env=True, seed_actions=True, other=(), workers=False)[source]

This uses the PyTorch Lightning seed_everything method to seed pseudo-random number generators in pytorch, numpy, and python.random. If env is provided, it optionally resets the environment and seeds its action space with the same seed.

Parameters:
  • seed (Optional[int]) – integer value, see seed_everything documentation for details

  • env (Optional[Env]) – gymnasium environment

  • seed_env (bool) – whether to reset/seed env (this is done by calling reset(seed=seed))

  • seed_actions (bool) – whether to seed the action space of env

  • other (Iterable) – other objects x to call x.seed(seed) on

  • workers (bool) – passed on to seed_everything

Return type:

Union[int, tuple]

Returns:

(seed, observation, info) if env was reset, otherwise, just seed