Exemplo n.º 1
0
 def __init__(self, env_fns):
     self.envs = [fn() for fn in env_fns]
     env = self.envs[0]
     VecEnv.__init__(self, len(env_fns), env.observation_space,
                     env.action_space)
     self.actions = None
     self.reset_kwargs = dict()
Exemplo n.º 2
0
 def __init__(self, env_fns):
     self.envs = [fn() for fn in env_fns]
     env = self.envs[0]
     # self.env = env
     VecEnv.__init__(self, len(env_fns), env.observation_space,
                     env.action_space)
     self.actions = None
Exemplo n.º 3
0
    def __init__(self, env_fns, spaces=None):
        """
        Arguments:
        env_fns: iterable of callables -  functions that create environments to run in subprocesses.
        Need to be cloud-pickleable
        """
        self.waiting = False
        self.closed = False
        nenvs = len(env_fns)
        self.remotes, self.work_remotes = zip(*[Pipe() for _ in range(nenvs)])
        self.ps = [
            Process(target=worker,
                    args=(work_remote, remote, CloudpickleWrapper(env_fn)))
            for (work_remote, remote,
                 env_fn) in zip(self.work_remotes, self.remotes, env_fns)
        ]
        for p in self.ps:
            p.daemon = True  # if the main process crashes, we should not cause things to hang
            p.start()
        for remote in self.work_remotes:
            remote.close()

        self.remotes[0].send(('get_spaces', None))
        observation_space, action_space = self.remotes[0].recv()
        self.viewer = None
        self.specs = [f().spec for f in env_fns]
        VecEnv.__init__(self, len(env_fns), observation_space, action_space)
Exemplo n.º 4
0
 def __init__(self, env_fns, dis_level):
     self.envs = [fn() for fn in env_fns]
     env = self.envs[0]
     VecEnv.__init__(
         self, len(env_fns), env.observation_space, env.action_space
     )  # adding the key 'episodic_return' because of VecEnv from the module "baselins"
     self.actions = None
     if dis_level == -1:  # test mode, to test panda with only 2 dof
         action_range = np.linspace(-2.0, 2.0, 11)
         self.action_space = list(itertools.product(action_range, repeat=2))
     elif dis_level:
         # print("Action space: ", env.action_space.shape[0], type(env.action_space))
         action_range = np.linspace(-2.0, 2.0, dis_level)
         self.action_space = list(
             itertools.product(action_range,
                               repeat=env.action_space.shape[0]))