parameters: (self, streetlearn)
return_statement: return self._pano_id_to_color
docstring: Gets called after StreetLearn:reset().
  
      Selects a random trajectory, extracts the instructions and panos at goal and
      waypoints, computes the shortest paths between each start, each waypoint and
      the goal.
  
      Args:
        streetlearn: a streetlearn instance.
      Returns:
        A newly populated pano_id_to_color dictionary.
docstring_summary: Gets called after StreetLearn:reset().
docstring_tokens: Gets called after StreetLearn : reset () .
function: def on_reset(self, streetlearn):
      """Gets called after StreetLearn:reset().
  
      Selects a random trajectory, extracts the instructions and panos at goal and
      waypoints, computes the shortest paths between each start, each waypoint and
      the goal.
  
      Args:
        streetlearn: a streetlearn instance.
      Returns:
        A newly populated pano_id_to_color dictionary.
      """
      # Initialise graph of rewards and colors with coins
      super(InstructionsBase, self).on_reset(streetlearn)
  
      self._current_step = 0
      self._step_counter = 1
      self._step_by_pano = {}
      self._pano_by_step = {}
  
      self._reward_pano_id_list = {}
      self._reward_pano_id_to_family = {}
      self._reward_family = {}
      self._pano_id_to_color = {}
      self._num_steps_this_goal = 0
  
      # Randomly sample a trajectory.
      if self._loaded_trajectories == False:
        self._load_trajectories()
      trajectory = self._sample_trajectory(streetlearn)
  
      start = max(len(trajectory.steps) - self._num_instructions, 0)
      logging.info('Trajectory of length %d (max %d), starting at %d',
                   len(trajectory.steps), self._num_instructions, start)
      num_steps = 0
      start_pano_id = None
      self._instructions = []
      self._thumbnails[:] = 0
      pano_list = []
  
      for step in trajectory.steps[start:]:
        pano_id = step.pano
        pano_list.append(pano_id)
  
        # Even if we do not take rewards for waypoints, we store them to keep
        # track of the agent's position along the trajectory.
        if num_steps == 0:
          start_pano_id = pano_id
        if num_steps > 0:
          self._add_reward_to_pano(pano_id, self._reward_at_waypoint,
                                   self._colors['waypoint'], streetlearn)
        self._instructions.append(step.instruction)
  
        # Fetch the thumbnail for the current step of the trajectory.
        step_thumbnail = self._thumbnail_helper.get_thumbnail(
            streetlearn, pano_id, step.heading_deg)
        if step_thumbnail is not None:
          self._thumbnails[num_steps] = step_thumbnail
  
        if self._reward_at_waypoint:
          logging.info('Waypoint %d at pano %s, yields reward of %f',
                       num_steps, pano_id, self._reward_at_waypoint)
        else:
          logging.info('Waypoint %d at pano %s', num_steps, pano_id)
        num_steps += 1
  
      # Set the goal.
      self._goal_pano_id = trajectory.goal.pano
      self._add_reward_to_pano(self._goal_pano_id, self._reward_at_goal,
                               self._colors['goal'], streetlearn)
      pano_list.append(self._goal_pano_id)
  
      # Store the previously defined coin rewards and colours
      for pano_id in self._coin_pano_id_set:
        self._add_coin_reward_to_pano(pano_id)
  
      # Add goal pano thumbnail at the end.
      goal_thumbnail = self._thumbnail_helper.get_thumbnail(
          streetlearn, self._goal_pano_id, trajectory.goal.heading_deg)
      if goal_thumbnail is not None:
        self._thumbnails[num_steps] = goal_thumbnail
  
      # Move and rotate player into start position.
      streetlearn.engine.SetPosition(start_pano_id)
      streetlearn.currentpano_id = start_pano_id
      streetlearn.engine.RotateObserver(trajectory.steps[start].heading_deg, 0)
  
      logging.info('From: %s (%f, %f), To: %s', start_pano_id,
                   trajectory.steps[start].lat,
                   trajectory.steps[start].lng, self._goal_pano_id)
      logging.info('Trajectory with %d waypoints (goal included)', num_steps)
  
      if self._calculate_ground_truth or self._show_shortest_path:
        # Update the shortest path to the goal or first waypoint.
        self._update_shortest_path(streetlearn, start_pano_id)
      if self._show_shortest_path:
        # Use the computed shortest path to color the panos.
        self._color_shortest_path(streetlearn)
      # By default, direction is forward.
      self._gt_direction = 0
  
      return self._pano_id_to_color
function_tokens: def on_reset ( self , streetlearn ) : # Initialise graph of rewards and colors with coins super ( InstructionsBase , self ) . on_reset ( streetlearn ) self . _current_step = 0 self . _step_counter = 1 self . _step_by_pano = { } self . _pano_by_step = { } self . _reward_pano_id_list = { } self . _reward_pano_id_to_family = { } self . _reward_family = { } self . _pano_id_to_color = { } self . _num_steps_this_goal = 0 # Randomly sample a trajectory. if self . _loaded_trajectories == False : self . _load_trajectories ( ) trajectory = self . _sample_trajectory ( streetlearn ) start = max ( len ( trajectory . steps ) - self . _num_instructions , 0 ) logging . info ( 'Trajectory of length %d (max %d), starting at %d' , len ( trajectory . steps ) , self . _num_instructions , start ) num_steps = 0 start_pano_id = None self . _instructions = [ ] self . _thumbnails [ : ] = 0 pano_list = [ ] for step in trajectory . steps [ start : ] : pano_id = step . pano pano_list . append ( pano_id ) # Even if we do not take rewards for waypoints, we store them to keep # track of the agent's position along the trajectory. if num_steps == 0 : start_pano_id = pano_id if num_steps > 0 : self . _add_reward_to_pano ( pano_id , self . _reward_at_waypoint , self . _colors [ 'waypoint' ] , streetlearn ) self . _instructions . append ( step . instruction ) # Fetch the thumbnail for the current step of the trajectory. step_thumbnail = self . _thumbnail_helper . get_thumbnail ( streetlearn , pano_id , step . heading_deg ) if step_thumbnail is not None : self . _thumbnails [ num_steps ] = step_thumbnail if self . _reward_at_waypoint : logging . info ( 'Waypoint %d at pano %s, yields reward of %f' , num_steps , pano_id , self . _reward_at_waypoint ) else : logging . info ( 'Waypoint %d at pano %s' , num_steps , pano_id ) num_steps += 1 # Set the goal. self . _goal_pano_id = trajectory . goal . pano self . _add_reward_to_pano ( self . _goal_pano_id , self . _reward_at_goal , self . _colors [ 'goal' ] , streetlearn ) pano_list . append ( self . _goal_pano_id ) # Store the previously defined coin rewards and colours for pano_id in self . _coin_pano_id_set : self . _add_coin_reward_to_pano ( pano_id ) # Add goal pano thumbnail at the end. goal_thumbnail = self . _thumbnail_helper . get_thumbnail ( streetlearn , self . _goal_pano_id , trajectory . goal . heading_deg ) if goal_thumbnail is not None : self . _thumbnails [ num_steps ] = goal_thumbnail # Move and rotate player into start position. streetlearn . engine . SetPosition ( start_pano_id ) streetlearn . currentpano_id = start_pano_id streetlearn . engine . RotateObserver ( trajectory . steps [ start ] . heading_deg , 0 ) logging . info ( 'From: %s (%f, %f), To: %s' , start_pano_id , trajectory . steps [ start ] . lat , trajectory . steps [ start ] . lng , self . _goal_pano_id ) logging . info ( 'Trajectory with %d waypoints (goal included)' , num_steps ) if self . _calculate_ground_truth or self . _show_shortest_path : # Update the shortest path to the goal or first waypoint. self . _update_shortest_path ( streetlearn , start_pano_id ) if self . _show_shortest_path : # Use the computed shortest path to color the panos. self . _color_shortest_path ( streetlearn ) # By default, direction is forward. self . _gt_direction = 0 return self . _pano_id_to_color