in support/gym_remote/bridge.py [0:0]
def wrap(self, name, space):
channel = None
if isinstance(space, gym.spaces.MultiBinary):
if space.n < 64:
channel = IntFoldChannel([2] * space.n, np.uint8)
else:
channel = NpChannel((space.n,), np.uint8)
channel.annotate('n', space.n)
channel.annotate('type', 'MultiBinary')
elif isinstance(space, gym.spaces.Discrete):
channel = IntChannel()
channel.annotate('n', space.n)
channel.annotate('type', 'Discrete')
elif isinstance(space, gym.spaces.MultiDiscrete):
if gym_version >= (0, 9, 6):
channel = NpChannel(space.shape, np.int64)
channel.annotate('shape', space.shape[0])
else:
channel = NpChannel((space.shape,), np.int64)
channel.annotate('shape', space.shape)
channel.annotate('type', 'MultiDiscrete')
elif isinstance(space, gym.spaces.Box):
channel = NpChannel(space.shape, space.high.dtype)
channel.annotate('type', 'Box')
channel.annotate('shape', space.shape)
if not channel:
raise NotImplementedError('Unsupported space')
return self.add_channel(name, channel)