Skip to content

Commit

Permalink
Fix a few more things
Browse files Browse the repository at this point in the history
  • Loading branch information
ffelten committed Nov 28, 2023
1 parent ffc0b0b commit 1db594d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions supersuit/generic_wrappers/frame_skip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
class frame_skip_gym(gymnasium.Wrapper):
def __init__(self, env, num_frames):
super().__init__(env)
self.np_random = env.unwrapped.np_random
self.num_frames = check_transform_frameskip(num_frames)

def step(self, action):
low, high = self.num_frames
num_skips = int(self.np_random.integers(low, high + 1))
num_skips = int(self.env.unwrapped.np_random.integers(low, high + 1))
total_reward = 0.0

for x in range(num_skips):
Expand Down
4 changes: 2 additions & 2 deletions supersuit/lambda_wrappers/reward_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def reset(self, seed=None, options=None):
super().reset(seed=seed, options=options)
self.rewards = {
agent: self._change_reward_fn(reward)
for agent, reward in self.rewards.items()
for agent, reward in self.env.rewards.items() # you don't want to unwrap here, because another reward wrapper might have been applied
}
self.__cumulative_rewards = make_defaultdict({a: 0 for a in self.agents})
self._accumulate_rewards()
Expand All @@ -34,7 +34,7 @@ def step(self, action):
super().step(action)
self.rewards = {
agent: self._change_reward_fn(reward)
for agent, reward in self.rewards.items()
for agent, reward in self.env.rewards.items() # you don't want to unwrap here, because another reward wrapper might have been applied
}
self.__cumulative_rewards[agent] = 0
self._cumulative_rewards = self.__cumulative_rewards
Expand Down

0 comments on commit 1db594d

Please sign in to comment.