Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Args:
env: A GFootball gym environment.
representation: See create_environment.representation comment.
channel_dimensions: (width, height) tuple that represents the dimensions of
SMM or pixels representation.
Returns:
Google Research Football environment.
"""
if representation.startswith('pixels'):
env = wrappers.PixelsStateWrapper(env, 'gray' in representation,
channel_dimensions)
elif representation == 'simple115':
env = wrappers.Simple115StateWrapper(env)
elif representation == 'simple115v2':
env = wrappers.Simple115StateWrapper(env, True)
elif representation == 'extracted':
env = wrappers.SMMWrapper(env, channel_dimensions)
elif representation == 'raw':
pass
else:
raise ValueError('Unsupported representation: {}'.format(representation))
return env
def _process_representation_wrappers(env, representation, channel_dimensions):
"""Wraps with necessary representation wrappers.
Args:
env: A GFootball gym environment.
representation: See create_environment.representation comment.
channel_dimensions: (width, height) tuple that represents the dimensions of
SMM or pixels representation.
Returns:
Google Research Football environment.
"""
if representation.startswith('pixels'):
env = wrappers.PixelsStateWrapper(env, 'gray' in representation,
channel_dimensions)
elif representation == 'simple115':
env = wrappers.Simple115StateWrapper(env)
elif representation == 'simple115v2':
env = wrappers.Simple115StateWrapper(env, True)
elif representation == 'extracted':
env = wrappers.SMMWrapper(env, channel_dimensions)
elif representation == 'raw':
pass
else:
raise ValueError('Unsupported representation: {}'.format(representation))
return env
def observation(self, observation):
"""Converts an observation into simple115 (or simple115v2) format."""
return Simple115StateWrapper.convert_observation(observation, self._fixed_positions)