Beispiel #1
0
if __name__ == '__main__':
    # Start and goal positions of the robot
    start_position = MapPoint(6, 1)  # Column (x) 6 and row (y) 1
    goal_position = MapPoint(1, 6)  # Column (x) 1 and row (y) 6

    # Create graph with associated grid map
    map_graph = Graph('map.png', goal_position)

    # Create root node at the given position
    # map_graph - graph this node belongs to
    # None - no parent
    # 0 - no cost
    # heuristic function
    # start_position
    # None - no action needed to reach this node
    root = Node(map_graph, None, 0, heuristic, start_position, None)
    map_graph.addNode(root, True)

    # Perform the map search and, if successful, show the resulting path in the
    # terminal output as text
    if(doSearch(map_graph, root, goal_position, SearchMethods.A_STAR)):
        map_graph.showGraph()
        map_graph.showPath(goal_position)
    else:
        eprint('There is no solution for the specified problem!')

    # We're done, lets leave successfully, after pressing any key
    # Keep figures open until the user presses 'q' to quit. This is a blocking
    #  statement
    plt.show()