Calls the Gym environment reset. Can only be called if the environment is over, or if allow_early_resets is True :param kwargs: Extra keywords saved for the next episode. only if defined by reset_keywords :return: the first observation of the environment
(self, **kwargs)
| 64 | self.current_reset_info: dict[str, Any] = {} |
| 65 | |
| 66 | def reset(self, **kwargs) -> tuple[ObsType, dict[str, Any]]: |
| 67 | """ |
| 68 | Calls the Gym environment reset. Can only be called if the environment is over, or if allow_early_resets is True |
| 69 | |
| 70 | :param kwargs: Extra keywords saved for the next episode. only if defined by reset_keywords |
| 71 | :return: the first observation of the environment |
| 72 | """ |
| 73 | if not self.allow_early_resets and not self.needs_reset: |
| 74 | raise RuntimeError( |
| 75 | "Tried to reset an environment before done. If you want to allow early resets, " |
| 76 | "wrap your env with Monitor(env, path, allow_early_resets=True)" |
| 77 | ) |
| 78 | self.rewards = [] |
| 79 | self.needs_reset = False |
| 80 | for key in self.reset_keywords: |
| 81 | value = kwargs.get(key) |
| 82 | if value is None: |
| 83 | raise ValueError(f"Expected you to pass keyword argument {key} into reset") |
| 84 | self.current_reset_info[key] = value |
| 85 | return self.env.reset(**kwargs) |
| 86 | |
| 87 | def step(self, action: ActType) -> tuple[ObsType, SupportsFloat, bool, bool, dict[str, Any]]: |
| 88 | """ |