def _get_action(self):
    """Returns action to perform for the current observations."""
    active = self._observation['left_team'][self._observation['active']]
    # Corner etc. - just pass the ball
    if self._observation['game_mode'] != 0:
      return football_action_set.action_long_pass

    if self._observation['ball_owned_team'] == 1:
      if self._last_action == football_action_set.action_pressure:
        return football_action_set.action_sprint
      self._pressure_enabled = True
      return football_action_set.action_pressure

    if self._pressure_enabled:
      self._pressure_enabled = False
      return football_action_set.action_release_pressure
    target_x = 0.85

    if (self._shoot_distance >
        np.linalg.norm(self._observation['ball'][:2] - [target_x, 0])):
      return football_action_set.action_shot

    move_target = [target_x, 0]
    # Compute run direction.
    move_action = self._direction_action(move_target - active)

    closest_front_opponent = self._closest_front_opponent(active, move_target)
    if closest_front_opponent is not None:
      dist_front_opp = self._object_distance(active, closest_front_opponent)
    else:
      dist_front_opp = 2.0

    # Maybe avoid opponent on your way?
    if dist_front_opp < 0.08:
      best_pass_target = self._best_pass_target(active)
      if np.array_equal(best_pass_target, active):
        move_action = self._avoid_opponent(active, closest_front_opponent,
                                          move_target)
      else:
        delta = best_pass_target - active
        direction_action = self._direction_action(delta)
        if self._last_action == direction_action:
          return football_action_set.action_short_pass
        else:
          return direction_action
    return move_action
Returns action to perform for the current observations.
gfootball/env/players/bot.py