How to use the gfootball.env.wrappers function in gfootball

To help you get started, we’ve selected a few gfootball examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google-research / football / gfootball / env / __init__.py View on Github external
def _process_reward_wrappers(env, rewards):
  assert 'scoring' in rewards.split(',')
  if 'checkpoints' in rewards.split(','):
    env = wrappers.CheckpointRewardWrapper(env)
  return env
github google-research / football / gfootball / env / __init__.py View on Github external
rewards: What rewards to apply.
    representation: See create_environment.representation comment.
    channel_dimensions: (width, height) tuple that represents the dimensions of
       SMM or pixels representation.
    apply_single_agent_wrappers: Whether to reduce output to single agent case.
    stacked: Should observations be stacked.
  Returns:
    Google Research Football environment.
  """
  env = _process_reward_wrappers(env, rewards)
  env = _process_representation_wrappers(env, representation,
                                         channel_dimensions)
  if apply_single_agent_wrappers:
    if representation != 'raw':
      env = wrappers.SingleAgentObservationWrapper(env)
    env = wrappers.SingleAgentRewardWrapper(env)
  if stacked:
    env = wrappers.FrameStack(env, 4)
  env = wrappers.GetStateWrapper(env)
  return env
github google-research / football / gfootball / env / __init__.py View on Github external
channel_dimensions: (width, height) tuple that represents the dimensions of
       SMM or pixels representation.
    apply_single_agent_wrappers: Whether to reduce output to single agent case.
    stacked: Should observations be stacked.
  Returns:
    Google Research Football environment.
  """
  env = _process_reward_wrappers(env, rewards)
  env = _process_representation_wrappers(env, representation,
                                         channel_dimensions)
  if apply_single_agent_wrappers:
    if representation != 'raw':
      env = wrappers.SingleAgentObservationWrapper(env)
    env = wrappers.SingleAgentRewardWrapper(env)
  if stacked:
    env = wrappers.FrameStack(env, 4)
  env = wrappers.GetStateWrapper(env)
  return env
github google-research / football / gfootball / env / __init__.py View on Github external
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
github google-research / football / gfootball / env / __init__.py View on Github external
SMM or pixels representation.
    apply_single_agent_wrappers: Whether to reduce output to single agent case.
    stacked: Should observations be stacked.
  Returns:
    Google Research Football environment.
  """
  env = _process_reward_wrappers(env, rewards)
  env = _process_representation_wrappers(env, representation,
                                         channel_dimensions)
  if apply_single_agent_wrappers:
    if representation != 'raw':
      env = wrappers.SingleAgentObservationWrapper(env)
    env = wrappers.SingleAgentRewardWrapper(env)
  if stacked:
    env = wrappers.FrameStack(env, 4)
  env = wrappers.GetStateWrapper(env)
  return env
github google-research / football / gfootball / env / __init__.py View on Github external
env: A GFootball gym environment.
    rewards: What rewards to apply.
    representation: See create_environment.representation comment.
    channel_dimensions: (width, height) tuple that represents the dimensions of
       SMM or pixels representation.
    apply_single_agent_wrappers: Whether to reduce output to single agent case.
    stacked: Should observations be stacked.
  Returns:
    Google Research Football environment.
  """
  env = _process_reward_wrappers(env, rewards)
  env = _process_representation_wrappers(env, representation,
                                         channel_dimensions)
  if apply_single_agent_wrappers:
    if representation != 'raw':
      env = wrappers.SingleAgentObservationWrapper(env)
    env = wrappers.SingleAgentRewardWrapper(env)
  if stacked:
    env = wrappers.FrameStack(env, 4)
  env = wrappers.GetStateWrapper(env)
  return env
github google-research / football / gfootball / env / __init__.py View on Github external
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