Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 3
0
 def __init__(self, population_size, training_type, runner_class, env):
     self.population_size = int(population_size)
     self.num_agents = getattr_unwrapped(env, 'num_agents')
     if training_type not in self.TRAINING_TYPES:
         raise NotImplementedError
     self.training_type = training_type
     self.runner_class = runner_class
     self.env = env
     self.nenv = env.num_envs
     self.models = [None for _ in range(population_size)]
Exemplo n.º 4
0
 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)
 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
Exemplo n.º 6
0
 def __init__(self, env):
     Wrapper.__init__(self, env)
     MultiAgentEnv.__init__(self, getattr_unwrapped(env, 'num_agents'))