Beispiel #1
0
def load(team_size, time_limit=45., random_state=None):
  """Construct `team_size`-vs-`team_size` soccer environment.

  Args:
    team_size: Integer, the number of players per team. Must be between 1 and
      11.
    time_limit: Float, the maximum duration of each episode in seconds.
    random_state: (optional) an int seed or `np.random.RandomState` instance.

  Returns:
    A `composer.Environment` instance.

  Raises:
    ValueError: If `team_size` is not between 1 and 11.
  """
  if team_size < 0 or team_size > 11:
    raise ValueError(
        "Team size must be between 1 and 11 (received %d)." % team_size)

  return composer.Environment(
      task=Task(
          players=_make_players(team_size),
          arena=RandomizedPitch(
              min_size=(32, 24), max_size=(48, 36), keep_aspect_ratio=True),
      ),
      time_limit=time_limit,
      random_state=random_state)
Beispiel #2
0
def load(team_size,
         time_limit=45.,
         random_state=None,
         disable_walker_contacts=False,
         walker_type=WalkerType.BOXHEAD):
    """Construct `team_size`-vs-`team_size` soccer environment.

  Args:
    team_size: Integer, the number of players per team. Must be between 1 and
      11.
    time_limit: Float, the maximum duration of each episode in seconds.
    random_state: (optional) an int seed or `np.random.RandomState` instance.
    disable_walker_contacts: (optional) if `True`, disable physical contacts
      between walkers.
    walker_type: the type of walker to instantiate in the environment.

  Returns:
    A `composer.Environment` instance.

  Raises:
    ValueError: If `team_size` is not between 1 and 11.
    ValueError: If `walker_type` is not recognized.
  """

    return composer.Environment(task=Task(
        players=_make_players(team_size, walker_type),
        arena=RandomizedPitch(min_size=(32, 24),
                              max_size=(48, 36),
                              keep_aspect_ratio=True),
        disable_walker_contacts=disable_walker_contacts),
                                time_limit=time_limit,
                                random_state=random_state)
Beispiel #3
0
def load(team_size, time_limit=45.):
    """Construct `team_size`-vs-`team_size` soccer environment."""
    if team_size < 0 or team_size > 11:
        raise ValueError("Team size must be between 1 and 11 (received %d)." %
                         team_size)

    return composer.Environment(task=Task(
        players=_make_players(team_size),
        arena=RandomizedPitch(min_size=(32, 24),
                              max_size=(48, 36),
                              keep_aspect_ratio=True),
    ),
                                time_limit=time_limit)
Beispiel #4
0
def load(team_size,
         time_limit=45.,
         random_state=None,
         disable_walker_contacts=False,
         enable_field_box=False,
         keep_aspect_ratio=False,
         terminate_on_goal=True,
         walker_type=WalkerType.BOXHEAD):
  """Construct `team_size`-vs-`team_size` soccer environment.

  Args:
    team_size: Integer, the number of players per team. Must be between 1 and
      11.
    time_limit: Float, the maximum duration of each episode in seconds.
    random_state: (optional) an int seed or `np.random.RandomState` instance.
    disable_walker_contacts: (optional) if `True`, disable physical contacts
      between walkers.
    enable_field_box: (optional) if `True`, enable physical bounding box for
      the soccer ball (but not the players).
    keep_aspect_ratio: (optional) if `True`, maintain constant pitch aspect
      ratio.
    terminate_on_goal: (optional) if `False`, continuous game play across
      scoring events.
    walker_type: the type of walker to instantiate in the environment.

  Returns:
    A `composer.Environment` instance.

  Raises:
    ValueError: If `team_size` is not between 1 and 11.
    ValueError: If `walker_type` is not recognized.
  """
  goal_size = None
  min_size = (32, 24)
  max_size = (48, 36)
  ball = SoccerBall()

  if walker_type == WalkerType.HUMANOID:
    goal_size = MINI_FOOTBALL_GOAL_SIZE
    num_walkers = team_size * 2
    min_size = _area_to_size(MINI_FOOTBALL_MIN_AREA_PER_HUMANOID * num_walkers)
    max_size = _area_to_size(MINI_FOOTBALL_MAX_AREA_PER_HUMANOID * num_walkers)
    ball = regulation_soccer_ball()

  task_factory = Task
  if not terminate_on_goal:
    task_factory = MultiturnTask

  return composer.Environment(
      task=task_factory(
          players=_make_players(team_size, walker_type),
          arena=RandomizedPitch(
              min_size=min_size,
              max_size=max_size,
              keep_aspect_ratio=keep_aspect_ratio,
              field_box=enable_field_box,
              goal_size=goal_size),
          ball=ball,
          disable_walker_contacts=disable_walker_contacts),
      time_limit=time_limit,
      random_state=random_state)