예제 #1
0
    def Start(self):
        str_gridSize = self.gridSize.get()
        gridSize = int(str_gridSize)

        str_algo = self.type_of_algo.get()

        str_startxy = self.txtStart.get("1.0", 'end-1c')
        str_goalxy = self.txtGoal.get("1.0", 'end-1c')
        if self.checkInput(str_goalxy, gridSize) and self.checkInput(
                str_startxy, gridSize):
            si, sj = list(map(int, str_startxy.split()))
            gi, gj = list(map(int, str_goalxy.split()))

            si, sj = sj, si
            gi, gj = gj, gi

            startNode = algo.Node(algo.Point(si, sj), 0, 0, 0)
            goalNode = algo.Node(algo.Point(gi, gj), 0, 0, 0)

            app = AppGUI(startNode, goalNode, gridSize, str_algo)
        else:
            messagebox.showinfo("Warning", "Invalid coordinate")
예제 #2
0
import map_2d
import AStar

if __name__ == '__main__':
    ##构建地图
    mapTest = map_2d.map2d()
    mapTest.showMap()
    ##构建A*
    aStar = AStar.AStar(mapTest, AStar.Node(AStar.Point(4, 4)), AStar.Node(AStar.Point(11, 23)))
    print("A* start:")
    ##开始寻路
    if aStar.start():
        aStar.setMap()
        mapTest.showMap()
    else:
        print("no way")
예제 #3
0
# coding=utf-8
import map2d
import AStar

if __name__ == '__main__':
    ##构建地图
    mapTest = map2d.map2d()
    mapTest.showMap()
    ##构建A*
    aStar = AStar.AStar(mapTest, AStar.Node(AStar.Point(1,1)), AStar.Node(AStar.Point(8,18)))
    print("A* start:")
    ##开始寻路
    if aStar.start():
        aStar.setMap()
        mapTest.showMap()
    else:
        print("no way")