Exemplo n.º 1
0
def call_AStar(output_file):
    """
    AStar
    ~ Deschid fisierul
    ~ Verific datele de intrare
    ~ Creez obiectul de tip AStar
    ~ Apelez functia Solve
    ~ Afisez solutia

    """
    g = open((output_folder + '/' + output_file), 'w')

    if not isInRange(matrix, robinet_x, robinet_y) or not isInRange(
            matrix, canal_x, canal_y):
        g.write('Datele de input sunt gresite. Problema nu are solutii')
    else:
        g.write('AStar\n')

        for heuristic in heuristics:
            g.write('\n\n\n' + heuristic + '\n\n')

            a = AStar(heuristic, deepcopy(matrix), robinet_x, robinet_y,
                      canal_x, canal_y, timeout)
            paths = a.Solve(solutions_number)

            print_paths(paths, g)

            g.write(
                '\n\n\n\n ______________________________________________________ \n\n\n\n'
            )

    g.close()