Exemplo n.º 1
0
    elif nombre == 2:
        filename = "kept_map/newmap2.txt"
        FIN = 32
    else:
        sys.exit()

    ###
    t0 = time.time()
    #translation file to list[list]
    maze = file2map(open(filename, 'r'))
    create_edges(maze)  #create the file to create the graph after
    g = Graph()
    g.read(
        "graph.txt")  #read the file created just before to complete the graph
    try:
        pi = g.dijkstra()  #apply dijsktra
    except:
        print("No way found to solve the maze")
        sys.exit(1)
    Path = backtrack_pred(pi, g._vertices[FIN])  #path from start to end
    print("temps ==> ", time.time() - t0)
    ###

    #Object representing the Robot
    #Firstly just the display
    #Then a real continue model
    Rob = RobotSimple(0, 0, 'S')
    Rob.create_orders(Path)

    #Pygame init
    pygame.init()