def _closest_front_opponent(self, o, target):
    """For an object and its movement direction returns the closest opponent.

    Args:
      o: Source object.
      target: Movement direction.

    Returns:
      Closest front opponent."""
    delta = target - o
    min_d = None
    closest = None
    for p in self._observation['right_team']:
      delta_opp = p - o
      if np.dot(delta, delta_opp) <= 0:
        continue
      d = self._object_distance(o, p)
      if min_d is None or d < min_d:
        min_d = d
        closest = p

    # May return None!
    return closest
For an object and its movement direction returns the closest opponent.

    Args:
      o: Source object.
      target: Movement direction.

    Returns:
      Closest front opponent.
gfootball/env/players/bot.py