'Sets up the task field for doing navigation on the grid world.'

def _preprocess_for_task(self, seed):

    if ((self.task is None) or (self.task.seed != seed)):
        rng = np.random.RandomState(seed)
        origin_loc = get_graph_origin_loc(rng, self.traversible)
        self.task = utils.Foo(seed=seed, origin_loc=origin_loc, n_ori=self.task_params.n_ori)
        G = generate_graph(self.valid_fn_vec, self.task_params.step_size, self.task.n_ori, (0, 0, 0))
        (gtG, nodes, nodes_to_id) = convert_to_graph_tool(G)
        self.task.gtG = gtG
        self.task.nodes = nodes
        self.task.delta_theta = ((2.0 * np.pi) / (self.task.n_ori * 1.0))
        self.task.nodes_to_id = nodes_to_id
        logging.info('Building    %s,    #V=%d,    #E=%d', self.building_name, self.task.nodes.shape[0], self.task.gtG.num_edges())
        type = self.task_params.type
        if (type == 'general'):
            _ = None
        elif ((type == 'room_to_room_many') or (type == 'room_to_room_back')):
            if (type == 'room_to_room_back'):
                assert (self.task_params.num_goals == 2), 'num_goals    must    be    2.'
            self.room_dims = _filter_rooms(self.room_dims, self.task_params.room_regex)
            xyt = self.to_actual_xyt_vec(self.task.nodes)
            self.task.node_room_ids = _label_nodes_with_room_id(xyt, self.room_dims)
            self.task.reset_kwargs = {'node_room_ids': self.task.node_room_ids}
        elif (type == 'rng_rejection_sampling_many'):
            n_bins = 20
            rejection_sampling_M = self.task_params.rejection_sampling_M
            min_dist = self.task_params.min_dist
            bins = (np.arange((n_bins + 1)) / (n_bins * 1.0))
            target_d = np.zeros(n_bins)
            target_d[...] = (1.0 / n_bins)
            sampling_d = get_hardness_distribution(self.task.gtG, self.task_params.max_dist, self.task_params.min_dist, np.random.RandomState(0), 4000, bins, self.task.nodes, self.task_params.n_ori, self.task_params.step_size)
            self.task.reset_kwargs = {'distribution_bins': bins, 'target_distribution': target_d, 'sampling_distribution': sampling_d, 'rejection_sampling_M': rejection_sampling_M, 'n_bins': n_bins, 'n_ori': self.task_params.n_ori, 'step_size': self.task_params.step_size, 'min_dist': self.task_params.min_dist}
            self.task.n_bins = n_bins
            self.task.distribution_bins = bins
            self.task.target_distribution = target_d
            self.task.sampling_distribution = sampling_d
            self.task.rejection_sampling_M = rejection_sampling_M
            if (self.logdir is not None):
                self._debug_save_hardness(seed)
        elif (type[:14] == 'to_nearest_obj'):
            self.room_dims = _filter_rooms(self.room_dims, self.task_params.room_regex)
            xyt = self.to_actual_xyt_vec(self.task.nodes)
            self.class_maps = (_select_classes(self.class_maps, self.class_map_names, self.task_params.semantic_task.class_map_names) * 1)
            self.class_map_names = self.task_params.semantic_task.class_map_names
            nodes_xyt = self.to_actual_xyt_vec(np.array(self.task.nodes))
            tt = utils.Timer()
            tt.tic()
            if (self.task_params.type == 'to_nearest_obj_acc'):
                (self.task.class_maps_dilated, self.task.node_class_label) = label_nodes_with_class_geodesic(nodes_xyt, self.class_maps, (self.task_params.semantic_task.pix_distance + 8), self.map.traversible, ff_cost=1.0, fo_cost=1.0, oo_cost=4.0, connectivity=8.0)
            dists = []
            for i in range(len(self.class_map_names)):
                class_nodes_ = np.where(self.task.node_class_label[:, i])[0]
                dists.append(get_distance_node_list(gtG, source_nodes=class_nodes_, direction='to'))
            self.task.dist_to_class = dists
            (a_, b_) = np.where(self.task.node_class_label)
            self.task.class_nodes = np.concatenate((a_[:, np.newaxis], b_[:, np.newaxis]), axis=1)
            if (self.logdir is not None):
                self._debug_semantic_maps(seed)
            self.task.reset_kwargs = {'sampling': self.task_params.semantic_task.sampling, 'class_nodes': self.task.class_nodes, 'dist_to_class': self.task.dist_to_class}
        if (self.logdir is not None):
            self._debug_save_map_nodes(seed)
