Esempio n. 1
0
def mazeTesting(itr, x, y, showOutput, showMaze):

    showMaze = not showMaze

    ast_timeTakenList = []
    bfs_timeTakenList = []

    for i in range(itr):

        a = mc.main(x, y, True, [], [])

        start = 0, 1
        ending = mc.endPoint(a)

        start1 = time.time()
        ast.main(a, start, ending, showMaze)
        end1 = time.time()

        start2 = time.time()
        bfs.main(a, start, ending, showMaze)
        end2 = time.time()

        ast_timeTakenList.append(end1 - start1)
        bfs_timeTakenList.append(end2 - start2)

        if showOutput:
            print('ASTAR Iteration: ', i, ' Time Taken:  ', end1 - start1)
            print('BFS Iteration: ', i, ' Time Taken:  ', end2 - start2)

    return ast_timeTakenList, bfs_timeTakenList
def findpath(grid):
    print("\nCrime rates in each area")
    print()
    global maze1
    maze1 = []
    for i in range(size):
        row = []
        for j in range(size):
            gb = grid[i][j]
            row.append(gb.getcrime())
        maze1.append(row)
    crimemap.disp(np.array(maze1), grid_size, median)
    maze = []
    for i in range(size):
        row = []
        for j in range(size):
            gb = grid[i][j]
            row.append(gb.getrisk())
        maze.append(row)
    print("Calculating path...")
    global path

    print("Enter start cordinate:([0 to", size - 1, "])")
    x1 = int(input("x:"))
    y1 = int(input("y:"))
    print("Enter destination cordinate:([0 to", size - 1, "])")
    x2 = int(input("x:"))
    y2 = int(input("y:"))

    start = (x1, y1)
    end = (x2, y2)

    path = astar.main(maze, grid_size, start, end)
    print("Path found!!!:", path)

    for i in path:
        maze1[i[0]][i[1]] = -3 * thresh - 1
    showpath.disp(np.array(maze1), size, median)
Esempio n. 3
0
import astar
import pygame

WIDTH = 600
WIN = pygame.display.set_mode((WIDTH, WIDTH))
astar.main(WIN, WIDTH)
Esempio n. 4
0
 def h_astar(self, inicio, objetivo):
     rota = astar.main(self.edgesV, self.nodes, inicio, objetivo, self.map)
     return rota
Esempio n. 5
0
          ('147', '099')]

code = 1

for i in points:

    inicio = i[0]
    print("Iniciando de:", inicio)
    objetivo = i[1]
    print("Objetivo é", objetivo)

    h_bfs = bfs.Graph()
    bfss = h_bfs.run(inicio, objetivo, nodes, edges)
    print("BFS", bfss)

    h_astar = astar.main(edgesV, nodes, inicio, objetivo, net)
    print("A-star", h_astar)

    # Rotas para o sumo
    edgesBFS = net.getListEdges(bfss)
    print("Route BFS:", edgesBFS)
    edgesASTAR = net.getListEdges(h_astar)
    print("Route A*:", edgesASTAR)

    print("Executando a BFS")
    consumption1 = mainSumo.main(edgesBFS, 'BFS', code)
    print("Executando a A-star")
    consumption3 = mainSumo.main(edgesASTAR, 'Astar', code)

    geneticA = GA.GA(csvName, nodes, edges, inicio, objetivo, nIndividuals,
                     limitGen, net, code)  #,inicio,objetivo)