Skip to content

Commit 500f687

Browse files
authored
Merge pull request #2 from jsrimr/patch-2
Update wrappers.py
2 parents 72262bd + 032ef7d commit 500f687

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

6_Uncertainty_in_RL/wrappers.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def __init__(self, env=None):
124124
super(ProcessFrame84, self).__init__(env)
125125
self.observation_space = spaces.Box(low=0, high=255, shape=(84, 84, 1))
126126

127-
def _observation(self, obs):
127+
def observation(self, obs):
128128
return ProcessFrame84.process(obs)
129129

130130
@staticmethod
@@ -150,12 +150,12 @@ def __init__(self, env):
150150
old_shape = self.observation_space.shape
151151
self.observation_space = gym.spaces.Box(low=0.0, high=1.0, shape=(old_shape[-1], old_shape[0], old_shape[1]))
152152

153-
def _observation(self, observation):
153+
def observation(self, observation):
154154
return np.swapaxes(observation, 2, 0)
155155

156156

157157
class ClippedRewardsWrapper(gym.RewardWrapper):
158-
def _reward(self, reward):
158+
def reward(self, reward):
159159
"""Change all the positive rewards to 1, negative to -1 and keep zero."""
160160
return np.sign(reward)
161161

@@ -190,13 +190,13 @@ def __init__(self, env, k):
190190
shp = env.observation_space.shape
191191
self.observation_space = spaces.Box(low=0, high=255, shape=(shp[0]*k, shp[1], shp[2]))
192192

193-
def _reset(self):
193+
def reset(self):
194194
ob = self.env.reset()
195195
for _ in range(self.k):
196196
self.frames.append(ob)
197197
return self._get_ob()
198198

199-
def _step(self, action):
199+
def step(self, action):
200200
ob, reward, done, info = self.env.step(action)
201201
self.frames.append(ob)
202202
return self._get_ob(), reward, done, info
@@ -383,4 +383,4 @@ def wrap_():
383383
env = FrameStack(env, 4)
384384
env = ClippedRewardsWrapper(env)
385385
return env
386-
return wrap_
386+
return wrap_

0 commit comments

Comments
 (0)