Get the recent state (with stacked history) of the environment. Returns: a list of ``hist_len-1`` elements, each of shape ``self.state_shape``
(self)
| 181 | self._current_episode.clear() |
| 182 | |
| 183 | def recent_state(self): |
| 184 | """ |
| 185 | Get the recent state (with stacked history) of the environment. |
| 186 | |
| 187 | Returns: |
| 188 | a list of ``hist_len-1`` elements, each of shape ``self.state_shape`` |
| 189 | """ |
| 190 | expected_len = self.history_len - 1 |
| 191 | if len(self._current_episode) >= expected_len: |
| 192 | return [k.state for k in self._current_episode[-expected_len:]] |
| 193 | else: |
| 194 | states = [np.zeros(self.state_shape, dtype=self.dtype)] * (expected_len - len(self._current_episode)) |
| 195 | states.extend([k.state for k in self._current_episode]) |
| 196 | return states |
| 197 | |
| 198 | |
| 199 | class EnvRunnerManager(object): |