def __init__(self, name): worker_id = int(f'{os.getpid()}{int(ps.unique_id())}'[-4:]) super().__init__(get_env_path(name), worker_id, no_graphics=not util.to_render(), multiagent=True) self.num_envs = self.number_agents
def __init__(self, spec): super().__init__(spec) util.set_attr(self, self.env_spec, ['unity']) worker_id = int(f'{os.getpid()}{self.e+int(ps.unique_id())}'[-4:]) seed = ps.get(spec, 'meta.random_seed') # TODO update Unity ml-agents to use seed=seed below self.u_env = UnityEnvironment(file_name=get_env_path(self.name), worker_id=worker_id) self.patch_gym_spaces(self.u_env) self._set_attr_from_u_env(self.u_env) assert self.max_t is not None logger.info(util.self_desc(self))
def __init__(self, spec, e=None, env_space=None): super(UnityEnv, self).__init__(spec, e, env_space) util.set_attr(self, self.env_spec, ['unity']) worker_id = int(f'{os.getpid()}{self.e+int(ps.unique_id())}'[-4:]) self.u_env = UnityEnvironment(file_name=get_env_path(self.name), worker_id=worker_id) self.patch_gym_spaces(self.u_env) self._set_attr_from_u_env(self.u_env) if env_space is None: # singleton mode pass else: self.space_init(env_space) logger.info(util.self_desc(self))
def test_get_env_path(): assert 'node_modules/slm-env-3dball/build/3dball' in get_env_path( '3dball')