'visual': self.number_observations > 0, } return observable def get_observable_dim(self): '''Get observable dimensions''' observable_dim = { 'state': self.state_space_size, 'visual': 'some np array shape, as opposed to what Arthur called size', } return observable_dim # Extend Unity BrainParameters class at runtime to add BrainExt methods util.monkey_patch(BrainParameters, BrainExt) class OpenAIEnv: def __init__(self, spec, env_space, e=0): self.spec = spec util.set_attr(self, self.spec) self.name = self.spec['name'] self.env_space = env_space self.e = e self.body_e = None self.nanflat_body_e = None # nanflatten version of bodies self.body_num = None self.u_env = gym.make(self.name) self.max_timestep = self.max_timestep or self.u_env.spec.tags.get(
'state': self.state_space_size > 0, 'image': self.number_observations > 0, } return observable def get_observable_dim(self): '''Get observable dimensions''' observable_dim = { 'state': self.state_space_size, 'image': 'some np array shape, as opposed to what Arthur called size', } return observable_dim # Extend Unity BrainParameters class at runtime to add BrainExt methods util.monkey_patch(brain.BrainParameters, BrainExt) def set_gym_space_attr(gym_space): '''Set missing gym space attributes for standardization''' if isinstance(gym_space, gym.spaces.Box): pass elif isinstance(gym_space, gym.spaces.Discrete): setattr(gym_space, 'low', 0) setattr(gym_space, 'high', gym_space.n) elif isinstance(gym_space, gym.spaces.MultiBinary): setattr(gym_space, 'low', np.full(gym_space.n, 0)) setattr(gym_space, 'high', np.full(gym_space.n, 2)) elif isinstance(gym_space, gym.spaces.MultiDiscrete): setattr(gym_space, 'low', np.zeros_like(nvec)) setattr(gym_space, 'high', np.array(gym_space.nvec))