Exemple #1
0
        print("Error")
        exit()

    goal = make_goal(size)

    if not solvable(puzzle, goal, size):
        print("This puzzle is not solvable")
        exit()
    else:
        print("This puzzle is solvable\n")

    heuristic, algo = choice_algo()
    states = States()
    Node.size = size
    Node.heuristic_g = Heuristic(size, goal, heuristic)
    start_node = Node(puzzle)

    if start_node.grid == goal:
        solution = [puzzle]
        states.total_open = 1
        states.max_rep = 1
        print_states(solution, states)
        exit()

    if algo == Algo.IDASTAR:
        solution = ida_star(start_node, states, goal)
    else:
        solution = bfs(start_node, states, goal)

    print_states(solution, states)