def UCS_analysis(number_of_puzzles, puzzles): global time_list, cost_list analysis = analysing(number_of_puzzles) # Apply UCS algorithm on puzzles for i in puzzles: time, cost, solution_file_data, search_file_data = UCS.apply_algorithm( i) time_list[0][puzzles.index(i)] = time cost_list[0][puzzles.index(i)] = cost solution_length = generate_solution_file(solution_file_data, puzzles.index(i), "ucs", "") search_length = generate_search_file(search_file_data, puzzles.index(i), "ucs", "") if (time != -1) and (cost != -1): analysis.add_search_length(search_length) analysis.add_time(time) analysis.add_cost(cost) analysis.add_solution_length(solution_length) else: analysis.add_no_solution() generate_analysis_file(analysis, "ucs", "")
def GBFS_h1_analysis(number_of_puzzles, puzzles): global time_list, cost_list heuristic = 1 analysis = analysing(number_of_puzzles) for i in puzzles: time, cost, solution_file_data, search_file_data = GBFS.apply_algorithm( i, heuristic) time_list[1][puzzles.index(i)] = time cost_list[1][puzzles.index(i)] = cost solution_length = generate_solution_file(solution_file_data, puzzles.index(i), "GBFS", f"-h{heuristic}") search_length = generate_search_file(search_file_data, puzzles.index(i), "GBFS", f"-h{heuristic}") if (time != -1) and (cost != -1): analysis.add_search_length(search_length) analysis.add_time(time) analysis.add_cost(cost) analysis.add_solution_length(solution_length) else: analysis.add_no_solution() generate_analysis_file(analysis, "GBFS", f"-h{heuristic}")