Ejemplo n.º 1
0
    def return_home(self, ant):
        new_best = 0
        task = ant.get_goal()
        if task in self.best_path:
            if len(self.best_path[task]) > ant.get_path_length():
                new_best = 1
        else:
            new_best = 1

        if new_best:
            self.best_path[task] = ant.get_path()
            self.set_max_pheromones(task, calc_max_pheromones(self.evaporation_rate, ant.get_path_length()))
            self.set_task_min_pheromones(task)