How to use the gfootball.env.football_action_set.action_idle 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 / script_helpers.py View on Github external
def __modify_trace(self, replay, fps):
    """Adopt replay to the new framerate and add additional steps at the end."""
    trace = []
    min_fps = replay[0]['debug']['config']['physics_steps_per_frame']
    assert fps % min_fps == 0, (
        'Trace has to be rendered in framerate being multiple of {}'.format(
            min_fps))
    assert fps <= 100, ('Framerate of up to 100 is supported')
    empty_steps = int(fps / min_fps) - 1
    for f in replay:
      trace.append(f)
      idle_step = copy.deepcopy(f)
      idle_step['debug']['action'] = [football_action_set.action_idle
                                     ] * len(f['debug']['action'])
      for _ in range(empty_steps):
        trace.append(idle_step)
    # Add some empty steps at the end, so that we can record videos.
    for _ in range(10):
      trace.append(idle_step)
    return trace
github google-research / football / gfootball / env / controller_base.py View on Github external
def __init__(self, player_config, env_config):
    player_base.PlayerBase.__init__(self, player_config)
    self._active_actions = {}
    self._env_config = env_config
    self._last_action = football_action_set.action_idle
    self._last_direction = football_action_set.action_idle
    self._current_direction = football_action_set.action_idle
github google-research / football / gfootball / env / controller_base.py View on Github external
def _check_action(self, action, active_actions):
    """Compare (and update) controller's state with the set of active actions.

    Args:
      action: Action to check
      active_actions: Set of all active actions
    """
    assert isinstance(action, football_action_set.CoreAction)
    if not action.is_in_actionset(self._env_config):
      return
    state = active_actions.get(action, 0)
    if (self._last_action == football_action_set.action_idle and
        self._active_actions.get(action, 0) != state):
      self._active_actions[action] = state
      if state:
        self._last_action = action
      else:
        self._last_action = football_action_set.disable_action(action)
        assert self._last_action
github google-research / football / gfootball / env / players / bot.py View on Github external
def __init__(self, player_config, env_config):
    assert env_config["action_set"] == 'full'
    player_base.PlayerBase.__init__(self, player_config)
    self._observation = None
    self._last_action = football_action_set.action_idle
    self._shoot_distance = 0.15
    self._pressure_enabled = False
github google-research / football / gfootball / env / controller_base.py View on Github external
self._check_direction(football_action_set.action_bottom_left,
                          bottom and left)
    self._check_direction(football_action_set.action_bottom_right,
                          bottom and right)
    if self._current_direction == football_action_set.action_idle:
      self._check_direction(football_action_set.action_right, right)
      self._check_direction(football_action_set.action_left, left)
      self._check_direction(football_action_set.action_top, top)
      self._check_direction(football_action_set.action_bottom, bottom)
    if self._current_direction != self._last_direction:
      self._last_direction = self._current_direction
      if self._current_direction == football_action_set.action_idle:
        return football_action_set.action_release_direction
      else:
        return self._current_direction
    self._last_action = football_action_set.action_idle
    self._check_action(football_action_set.action_long_pass,
                       active_actions)
    self._check_action(football_action_set.action_high_pass,
                       active_actions)
    self._check_action(football_action_set.action_short_pass,
                       active_actions)
    self._check_action(football_action_set.action_shot, active_actions)
    self._check_action(football_action_set.action_keeper_rush,
                       active_actions)
    self._check_action(football_action_set.action_sliding, active_actions)
    self._check_action(football_action_set.action_pressure,
                       active_actions)
    self._check_action(football_action_set.action_team_pressure,
                       active_actions)
    self._check_action(football_action_set.action_sprint, active_actions)
    self._check_action(football_action_set.action_dribble, active_actions)
github google-research / football / gfootball / env / controller_base.py View on Github external
def __init__(self, player_config, env_config):
    player_base.PlayerBase.__init__(self, player_config)
    self._active_actions = {}
    self._env_config = env_config
    self._last_action = football_action_set.action_idle
    self._last_direction = football_action_set.action_idle
    self._current_direction = football_action_set.action_idle
github google-research / football / gfootball / env / controller_base.py View on Github external
def __init__(self, player_config, env_config):
    player_base.PlayerBase.__init__(self, player_config)
    self._active_actions = {}
    self._env_config = env_config
    self._last_action = football_action_set.action_idle
    self._last_direction = football_action_set.action_idle
    self._current_direction = football_action_set.action_idle
github google-research / football / gfootball / env / players / lazy.py View on Github external
def take_action(self, observations):
    return [football_action_set.action_idle] * len(observations)