Exemple #1
0
    def run(self):
        start_node = NavNode(position=self.board.start, g=0)

        a_star = AStar(
            draw=self.gfx.draw if not self.disable_gfx else lambda _: 0,
            disable_gfx=self.disable_gfx,
            draw_every=self.draw_every,
            print_path=self.print_path
        )

        a_star.run(start_node=start_node)
Exemple #2
0
 def h_cost(self, s):
     plan = AStar((s[0], s[1]), (self._e[0], self._e[1]), self._map_info)
     if plan.run(display=False):
         path = plan.reconstruct_path()
     d = 0
     for i in range(len(path) - 1):
         d += self.distance(path[i], path[i + 1])
     return d