(self, task, player)
Adds observables to a player for the given task.

    Args:
      task: A `soccer.Task` instance.
      player: A `Walker` instance to which observables will be added.
Adds observables to a player for the given task.
Adds observables to a player for the given task .
def __call__(self, task, player):
    """Adds observables to a player for the given task.

    Args:
      task: A `soccer.Task` instance.
      player: A `Walker` instance to which observables will be added.
    """

    def _stats_i_received_ball(unused_physics):
      if (task.ball.hit and task.ball.repossessed and
          task.ball.last_hit is player):
        return 1.
      return 0.

    player.walker.observables.add_observable(
        'stats_i_received_ball',
        base_observable.Generic(_stats_i_received_ball))

    def _stats_opponent_intercepted_ball(unused_physics):
      """Indicator on if an opponent intercepted the ball."""
      if (task.ball.hit and task.ball.intercepted and
          task.ball.last_hit.team != player.team):
        return 1.
      return 0.

    player.walker.observables.add_observable(
        'stats_opponent_intercepted_ball',
        base_observable.Generic(_stats_opponent_intercepted_ball))

    for dist in [5, 10, 15]:

      def _stats_i_received_ball_dist(physics, dist=dist):
        if (_stats_i_received_ball(physics) and
            task.ball.dist_between_last_hits is not None and
            task.ball.dist_between_last_hits > dist):
          return 1.
        return 0.

      player.walker.observables.add_observable(
          'stats_i_received_ball_%dm' % dist,
          base_observable.Generic(_stats_i_received_ball_dist))

      def _stats_opponent_intercepted_ball_dist(physics, dist=dist):
        if (_stats_opponent_intercepted_ball(physics) and
            task.ball.dist_between_last_hits is not None and
            task.ball.dist_between_last_hits > dist):
          return 1.
        return 0.

      player.walker.observables.add_observable(
          'stats_opponent_intercepted_ball_%dm' % dist,
          base_observable.Generic(_stats_opponent_intercepted_ball_dist))
def __call__ ( self , task , player ) : def _stats_i_received_ball ( unused_physics ) : if ( task . ball . hit and task . ball . repossessed and task . ball . last_hit is player ) : return 1. return 0. player . walker . observables . add_observable ( 'stats_i_received_ball' , base_observable . Generic ( _stats_i_received_ball ) ) def _stats_opponent_intercepted_ball ( unused_physics ) : """Indicator on if an opponent intercepted the ball.""" if ( task . ball . hit and task . ball . intercepted and task . ball . last_hit . team != player . team ) : return 1. return 0. player . walker . observables . add_observable ( 'stats_opponent_intercepted_ball' , base_observable . Generic ( _stats_opponent_intercepted_ball ) ) for dist in [ 5 , 10 , 15 ] : def _stats_i_received_ball_dist ( physics , dist = dist ) : if ( _stats_i_received_ball ( physics ) and task . ball . dist_between_last_hits is not None and task . ball . dist_between_last_hits > dist ) : return 1. return 0. player . walker . observables . add_observable ( 'stats_i_received_ball_%dm' % dist , base_observable . Generic ( _stats_i_received_ball_dist ) ) def _stats_opponent_intercepted_ball_dist ( physics , dist = dist ) : if ( _stats_opponent_intercepted_ball ( physics ) and task . ball . dist_between_last_hits is not None and task . ball . dist_between_last_hits > dist ) : return 1. return 0. player . walker . observables . add_observable ( 'stats_opponent_intercepted_ball_%dm' % dist , base_observable . Generic ( _stats_opponent_intercepted_ball_dist ) )