def solve_4(initial, goal): ''' Solve a problem of type AssemblyProblem_4 The implementation has to - use an instance of the class AssemblyProblem_4 - make a call to an appropriate functions of the 'generic_search" library @return - the string 'no solution' if the problem is not solvable - otherwise return the sequence of actions to go from state 'initial' to state 'goal' ''' print('\n++ busy searching in solve_4() ... ++\n') assembly_problem = AssemblyProblem_4(initial, goal) #initiating assembly problem 1 with initial workbench and goal search_function = generic_search.astar_graph_search(assembly_problem,assembly_problem.h) #using A star search to solve the find a solution search_function2 = generic_search.breadth_first_graph_search(assembly_problem) search_function3 = generic_search.uniform_cost_search(assembly_problem) search_function4 = generic_search.iterative_deepening_search(assembly_problem) if search_function == None: #if search does not output anything string 'no solution' will be returned from this function return 'no solution' else: return search_function.solution()#,search_function2.solution(), search_function3.solution(), search_function4.solution() #otherwise the solution will be returned
def solve_2(initial, goal): ''' Solve a problem of type AssemblyProblem_2 The implementation has to - use an instance of the class AssemblyProblem_2 - make a call to an appropriate functions of the 'generic_search" library @return - the string 'no solution' if the problem is not solvable - otherwise return the sequence of actions to go from state 'initial' to state 'goal' ''' print('\n++ busy searching in solve_2() ... ++\n') #raise NotImplementedError assembly_problem = AssemblyProblem_2(initial, goal) # HINT # Implement Tree Search (BFS) # Return Actions based on best path node=breadth_first_graph_search(assembly_problem) if node is None: # no solution return 'no solution' else: return node.solution()
def solve_3(initial, goal): ''' Solve a problem of type AssemblyProblem_3 The implementation has to - use an instance of the class AssemblyProblem_3 - make a call to an appropriate functions of the 'generic_search" library @return - the string 'no solution' if the problem is not solvable - otherwise return the sequence of actions to go from state 'initial' to state 'goal' ''' print('\n++ busy searching in solve_3() ... ++\n') #raise NotImplementedError assembly_problem = AssemblyProblem_3(initial, goal) solution_node = generic_search.breadth_first_graph_search(assembly_problem) if solution_node == None: return "no solution" else: return solution_node.solution()