def Get_If_Rubiks_Cubes_Equivalent(first_cube, second_cube): rubiks_cubes_equivalent = False first_cube_string_format = rubiks_cube.Get_String_From_Cube(first_cube) second_cube_string_format = rubiks_cube.Get_String_From_Cube(second_cube) if first_cube_string_format == second_cube_string_format: rubiks_cubes_equivalent = True return rubiks_cubes_equivalent
def Get_If_Rubiks_Cube_Search_Trees_Intersect(first_search_tree, second_search_tree): trees_intersect = False first_search_tree_current_state = rubiks_cube.Get_String_From_Cube( first_search_tree["CURRENT_CUBE"]) second_search_tree_visited_states = second_search_tree[ "OPEN_STATES"] + second_search_tree["CLOSED_STATES"] + [ rubiks_cube.Get_String_From_Cube( second_search_tree["CURRENT_CUBE"]) ] if first_search_tree_current_state in second_search_tree_visited_states: trees_intersect = True return trees_intersect
def Get_Cube_Array_As_String_Array(cube_array): string_array = [] for cube in cube_array: cube_string = rubiks_cube.Get_String_From_Cube(cube) string_array.append(cube_string) return string_array
def Get_Children_Of_Current_Cube(cube_search_tree): children = [] parent = cube_search_tree["CURRENT_CUBE"].copy() turn_options = cube_search_tree["TURN_OPTIONS"] for turn_option in turn_options: child = rubiks_cube.Get_String_From_Cube( rubiks_cube.Get_Rotated_Cube_Using_Notation( parent.copy(), turn_option)) if child not in cube_search_tree[ "CLOSED_STATES"] and child not in cube_search_tree[ "OPEN_STATES"]: children.append(child) return children
def Get_Updated_Cube_Breadth_First_Search_Tree(cube_search_tree): updated_cube_search_tree = cube_search_tree updated_cube_search_tree["OPEN_STATES"] = updated_cube_search_tree[ "OPEN_STATES"] + Get_Children_Of_Current_Cube(updated_cube_search_tree) updated_cube_search_tree["CLOSED_STATES"].append( rubiks_cube.Get_String_From_Cube( updated_cube_search_tree["CURRENT_CUBE"])) updated_cube_search_tree[ "CURRENT_CUBE"] = rubiks_cube.Get_Cube_From_String( updated_cube_search_tree["OPEN_STATES"].pop(0)) updated_cube_search_tree[ "PATH_COST"] = updated_cube_search_tree["PATH_COST"] + 1 return updated_cube_search_tree