(space)
Creates a Distribution for the given Gym space.
Creates a Distribution for the given Gym space.
Creates a Distribution for the given Gym space .
def create_distribution(space):
  """Creates a Distribution for the given Gym space."""
  if isinstance(space, gym.spaces.Discrete):
    return Categorical(shape=(), n_categories=space.n)
  elif isinstance(space, gym.spaces.MultiDiscrete):
    assert space.nvec.size
    assert min(space.nvec) == max(space.nvec), (
        'Every dimension must have the same number of categories, got '
        '{}.'.format(space.nvec)
    )
    return Categorical(shape=(len(space.nvec),), n_categories=space.nvec[0])
  elif isinstance(space, gym.spaces.Box):
    return Gaussian(shape=space.shape)
  else:
    raise TypeError('Space {} unavailable as a distribution support.')
def create_distribution ( space ) : if isinstance ( space , gym . spaces . Discrete ) : return Categorical ( shape = ( ) , n_categories = space . n ) elif isinstance ( space , gym . spaces . MultiDiscrete ) : assert space . nvec . size assert min ( space . nvec ) == max ( space . nvec ) , ( 'Every dimension must have the same number of categories, got ' '{}.' . format ( space . nvec ) ) return Categorical ( shape = ( len ( space . nvec ) , ) , n_categories = space . nvec [ 0 ] ) elif isinstance ( space , gym . spaces . Box ) : return Gaussian ( shape = space . shape ) else : raise TypeError ( 'Space {} unavailable as a distribution support.' )