def Trace_Rubiks_Cube_Breadth_First_Search( scrambled_cube_with_turns_executed=None): print("Breadth First Search:") start_time = time.time() cube_search_tree = Get_New_Rubiks_Cube_Search_Tree( scrambled_cube_with_turns_executed) while Get_If_Rubiks_Cubes_Equivalent( cube_search_tree["CURRENT_CUBE"], cube_search_tree["GOAL_CUBE"]) != True: cube_search_tree = Get_Updated_Cube_Breadth_First_Search_Tree( cube_search_tree.copy()) end_time = time.time() rubiks_cube.Print_Cube(cube_search_tree["ROOT_CUBE"]) print("\n") print("Turns Used to Scramble:\t" + str(cube_search_tree["ROOT_CUBE_TURNS_EXECUTED"])) print("\n") rubiks_cube.Print_Cube(cube_search_tree["CURRENT_CUBE"]) print("\n") print("------------------------------") path_cost = str(cube_search_tree["PATH_COST"]) print("Path Cost:\t" + path_cost) execution_time = str(end_time - start_time) print("Execution Time:\t" + execution_time) print("------------------------------") return path_cost, execution_time
def Trace_Rubiks_Cube_Bidirectional_Search( scrambled_cube_with_turns_executed=None): print("Bidirectional Search:") start_time = time.time() scrambled_cube_search_tree = Get_New_Rubiks_Cube_Search_Tree( scrambled_cube_with_turns_executed) default_cube_search_tree = Get_Default_Rubiks_Cube_Search_Tree() default_cube_search_tree["GOAL_STATE"] = scrambled_cube_search_tree[ "ROOT_CUBE"] while Get_If_Rubiks_Cube_Search_Trees_Intersect( scrambled_cube_search_tree, default_cube_search_tree) != True: scrambled_cube_search_tree, default_cube_search_tree = Get_Updated_Cube_Bidirectional_Search_Tree( scrambled_cube_search_tree.copy(), default_cube_search_tree.copy()) end_time = time.time() rubiks_cube.Print_Cube(scrambled_cube_search_tree["ROOT_CUBE"]) print("\n") print("Turns Used to Scramble:\t" + str(scrambled_cube_search_tree["ROOT_CUBE_TURNS_EXECUTED"])) print("\n") print("Search Convergence Cube:\n") rubiks_cube.Print_Cube(scrambled_cube_search_tree["CURRENT_CUBE"]) print("\n") print("------------------------------") path_cost = str(scrambled_cube_search_tree["PATH_COST"] + default_cube_search_tree["PATH_COST"]) print("Path Cost:\t" + path_cost) execution_time = str(end_time - start_time) print("Execution Time:\t" + execution_time) print("------------------------------") return path_cost, execution_time
def Trace_Rubiks_Cube_Genetic_Algorithm(): default_cube = rubiks_cube.Get_Default_Cube() scrambled_cube = rubiks_cube.Get_Scrambled_Cube(default_cube, num_turns=20)["CUBE"] rubiks_cube.Print_Cube(scrambled_cube)