| 150 | |
| 151 | |
| 152 | class SkipFrame(gym.Wrapper): |
| 153 | def __init__(self, env, skip): |
| 154 | """Return only every `skip`-th frame""" |
| 155 | super().__init__(env) |
| 156 | self._skip = skip |
| 157 | |
| 158 | def step(self, action): |
| 159 | """Repeat action, and sum reward""" |
| 160 | total_reward = 0.0 |
| 161 | for i in range(self._skip): |
| 162 | # Accumulate reward and repeat the same action |
| 163 | obs, reward, done, trunk, info = self.env.step(action) |
| 164 | total_reward += reward |
| 165 | if done: |
| 166 | break |
| 167 | return obs, total_reward, done, trunk, info |
| 168 | |
| 169 | |
| 170 | class GrayScaleObservation(gym.ObservationWrapper): |