From 6d0506f44656694b1d94f547dc9ba5555ef7c463 Mon Sep 17 00:00:00 2001 From: Jet Date: Thu, 2 Jun 2022 17:06:47 +0100 Subject: [PATCH 1/4] partially fix supersuit breaking because of gym --- supersuit/vector/concat_vec_env.py | 14 +++++++++++--- supersuit/vector/single_vec_env.py | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/supersuit/vector/concat_vec_env.py b/supersuit/vector/concat_vec_env.py index 3f1f89a8..7a8b0948 100644 --- a/supersuit/vector/concat_vec_env.py +++ b/supersuit/vector/concat_vec_env.py @@ -62,7 +62,11 @@ def reset(self, seed=None, return_info=False, options=None): _res_obs.append(_obs) _res_info.append(_info) - return self.concat_obs(_res_obs), sum(_res_info, []) + info_array = {} + for i, info in enumerate(_res_info): + info_array = self._add_info(info_array, info, i) + + return self.concat_obs(_res_obs), info_array def concat_obs(self, observations): return concatenate( @@ -105,8 +109,12 @@ def step(self, actions): observations = self.concat_obs(observations) rewards = np.concatenate(rewards, axis=0) dones = np.concatenate(dones, axis=0) - infos = sum(infos, []) - return observations, rewards, dones, infos + + info_array = {} + for i, info in enumerate(infos): + info_array = self._add_info(info_array, info[0], i) + + return observations, rewards, dones, info_array def render(self, mode="human"): return self.vec_envs[0].render(mode) diff --git a/supersuit/vector/single_vec_env.py b/supersuit/vector/single_vec_env.py index a71fb1c3..96d792b9 100644 --- a/supersuit/vector/single_vec_env.py +++ b/supersuit/vector/single_vec_env.py @@ -1,3 +1,4 @@ +from gym.utils.seeding import np_random import numpy as np import gym @@ -6,6 +7,7 @@ class SingleVecEnv: def __init__(self, gym_env_fns, *args): assert len(gym_env_fns) == 1 self.gym_env = gym_env_fns[0]() + self.gym_env.unwrapped.np_random, _ = np_random() self.observation_space = self.gym_env.observation_space self.action_space = self.gym_env.action_space self.num_envs = 1 From 1bfc3660fee077148b0fbce57f68cb8e6382c059 Mon Sep 17 00:00:00 2001 From: Jet <38184875+jjshoots@users.noreply.github.com> Date: Thu, 23 Jun 2022 09:21:54 +0100 Subject: [PATCH 2/4] Remove fix for np random --- supersuit/vector/single_vec_env.py | 1 - 1 file changed, 1 deletion(-) diff --git a/supersuit/vector/single_vec_env.py b/supersuit/vector/single_vec_env.py index 96d792b9..fad6b4ed 100644 --- a/supersuit/vector/single_vec_env.py +++ b/supersuit/vector/single_vec_env.py @@ -7,7 +7,6 @@ class SingleVecEnv: def __init__(self, gym_env_fns, *args): assert len(gym_env_fns) == 1 self.gym_env = gym_env_fns[0]() - self.gym_env.unwrapped.np_random, _ = np_random() self.observation_space = self.gym_env.observation_space self.action_space = self.gym_env.action_space self.num_envs = 1 From 717aca2df0e4f0d8c6f86ade7c801dda504b3fdd Mon Sep 17 00:00:00 2001 From: Jet <38184875+jjshoots@users.noreply.github.com> Date: Thu, 23 Jun 2022 09:22:15 +0100 Subject: [PATCH 3/4] Remove import --- supersuit/vector/single_vec_env.py | 1 - 1 file changed, 1 deletion(-) diff --git a/supersuit/vector/single_vec_env.py b/supersuit/vector/single_vec_env.py index fad6b4ed..a71fb1c3 100644 --- a/supersuit/vector/single_vec_env.py +++ b/supersuit/vector/single_vec_env.py @@ -1,4 +1,3 @@ -from gym.utils.seeding import np_random import numpy as np import gym From 05124f59014933342ff6e82420460f2d0c837c44 Mon Sep 17 00:00:00 2001 From: snow-fox Date: Mon, 15 Aug 2022 14:47:16 +0100 Subject: [PATCH 4/4] update assertation_message --- supersuit/vector/markov_vector_wrapper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/supersuit/vector/markov_vector_wrapper.py b/supersuit/vector/markov_vector_wrapper.py index e347b5a4..9f0d0b6c 100644 --- a/supersuit/vector/markov_vector_wrapper.py +++ b/supersuit/vector/markov_vector_wrapper.py @@ -22,11 +22,11 @@ def __init__(self, par_env, black_death=False): assert all( self.observation_space == par_env.observation_space(agent) for agent in par_env.possible_agents - ), "observation spaces not consistent. Perhaps you should wrap with `supersuit.aec_wrappers.pad_observations`?" + ), "observation spaces not consistent. Perhaps you should wrap with `supersuit.multiagent_wrappers.pad_observations_v0`?" assert all( self.action_space == par_env.action_space(agent) for agent in par_env.possible_agents - ), "action spaces not consistent. Perhaps you should wrap with `supersuit.aec_wrappers.pad_actions`?" + ), "action spaces not consistent. Perhaps you should wrap with `supersuit.multiagent_wrappers.pad_observations_v0`?" self.num_envs = len(par_env.possible_agents) self.black_death = black_death