Example #1
0
 def __init__(self, env_fns):
     DummyVecEnv.__init__(self, env_fns)
     num_agents = getattr_unwrapped(self.envs[0], "num_agents")
     VecMultiEnv.__init__(self, self.num_envs, num_agents,
                          self.observation_space, self.action_space)
     self.buf_rews = np.zeros((self.num_envs, self.num_agents),
                              dtype=np.float32)
Example #2
0
 def __init__(self, env_fns, start_method=None):
     if start_method is None:
         start_method = "forkserver"  # thread safe by default
     SubprocVecEnv.__init__(self, env_fns, start_method=start_method)
     env = env_fns[0]()
     num_agents = getattr_unwrapped(env, "num_agents")
     env.close()
     VecMultiEnv.__init__(self, self.num_envs, num_agents,
                          self.observation_space, self.action_space)
 def __init__(self, env):
     if hasattr(env, "_max_episode_steps"):
         # We step multiple times, then reset to a previous state.
         # Timestep limit doesn't make much sense at this level.
         # (Instead, apply it outside of the controller.)
         raise TypeError("Environment must not have a timestep limit.")
     self.env = env
     self.sim = getattr_unwrapped(env, "sim")
     state = MujocoState.from_mjdata(self.sim.data).flatten()
     self._state_size = len(state)
     self._action_size = reduce(lambda x, y: x * y, env.action_space.shape)
Example #4
0
 def __init__(
         self,
         env,
         filename,
         our_idx=None,
         allow_early_resets=False,
         reset_keywords=(),
         info_keywords=(),
 ):
     num_agents = getattr_unwrapped(env, "num_agents")
     extra_rks = tuple("r{:d}".format(i) for i in range(num_agents))
     super().__init__(
         env,
         filename,
         allow_early_resets=allow_early_resets,
         reset_keywords=reset_keywords,
         info_keywords=extra_rks + info_keywords,
     )
     self.our_idx = our_idx
     self.info_keywords = info_keywords
Example #5
0
 def __init__(self, env):
     Wrapper.__init__(self, env)
     MultiAgentEnv.__init__(self, getattr_unwrapped(env, "num_agents"))