def change_corners(cube): cube = rotations.rotate_R(cube) cube = rotations.rotate_U_counter(cube) cube = rotations.rotate_R_counter(cube) cube = rotations.rotate_U_counter(cube) cube = rotations.rotate_R(cube) cube = rotations.rotate_U(cube) cube = rotations.rotate_R_counter(cube) cube = rotations.rotate_F_counter(cube) cube = rotations.rotate_R(cube) cube = rotations.rotate_U(cube) cube = rotations.rotate_R_counter(cube) cube = rotations.rotate_U_counter(cube) cube = rotations.rotate_R_counter(cube) cube = rotations.rotate_F(cube) cube = rotations.rotate_R(cube) return cube
def scramble(cube, f): print("Scramble: ", end='') prev = -1 streak = 0 for i in range(f): r = randint(0, 12) # If the next equalt the previous, then add 1 to the streak if r == prev: streak += 1 # If at least 3 in a row, delete last if streak >= 2: streak = 1 r = -1 i -= 1 # If not equals the prev else: streak = 0 # If the next is the counter part of the prev, then delete it if int(r / 2) == int(prev / 2): r = -1 i -= 1 if r == 0: cube = rotations.rotate_U(cube) elif r == 1: cube = rotations.rotate_U_counter(cube) elif r == 2: cube = rotations.rotate_L(cube) elif r == 3: cube = rotations.rotate_L_counter(cube) elif r == 4: cube = rotations.rotate_F(cube) elif r == 5: cube = rotations.rotate_F_counter(cube) elif r == 6: cube = rotations.rotate_R(cube) elif r == 7: cube = rotations.rotate_R_counter(cube) elif r == 8: cube = rotations.rotate_B(cube) elif r == 9: cube = rotations.rotate_B_counter(cube) elif r == 10: cube = rotations.rotate_D(cube) elif r == 11: cube = rotations.rotate_D_counter(cube) prev = r print("\n") return cube
def get_edge_moves(cube, a, b): print("get edge moves") prevcube = copy_cube(cube) t = 0 while t < 4: for r in range(12): if r == 0: cube = rotations.rotate_U(cube) elif r == 1: cube = rotations.rotate_U_counter(cube) elif r == 2: cube = rotations.rotate_L(cube) elif r == 3: cube = rotations.rotate_L_counter(cube) elif r == 4: cube = rotations.rotate_F(cube) elif r == 5: cube = rotations.rotate_F_counter(cube) elif r == 6: cube = rotations.rotate_R(cube) elif r == 7: cube = rotations.rotate_R_counter(cube) elif r == 8: cube = rotations.rotate_B(cube) elif r == 9: cube = rotations.rotate_B_counter(cube) elif r == 10: cube = rotations.rotate_D(cube) elif r == 11: cube = rotations.rotate_D_counter(cube) if edge_all_good(cube, a, b): print("\n" + str(r)) return cube = copy_cube(prevcube) print() t += 1 if t == 2: break
def bring_edge_to_change(cube, a, b): if a == 'w': if b == 'b': cube = rotations.rotate_R(cube) cube = rotations.rotate_R(cube) cube = rotations.rotate_U_counter(cube) cube = rotations.rotate_R(cube) cube = rotations.rotate_R(cube) elif b == 'o': return cube elif b == 'g': cube = rotations.rotate_R_counter(cube) cube = rotations.rotate_R_counter(cube) cube = rotations.rotate_U(cube) cube = rotations.rotate_R(cube) cube = rotations.rotate_R(cube) elif a == 'o': if b == 'w': cube = rotations.rotate_L_counter(cube) cube = rotations.rotate_U(cube) cube = rotations.rotate_B_counter(cube) cube = rotations.rotate_U_counter(cube) elif b == 'g': cube = rotations.rotate_U_counter(cube) cube = rotations.rotate_F(cube) cube = rotations.rotate_U(cube) elif b == 'y': cube = rotations.rotate_L(cube) cube = rotations.rotate_U(cube) cube = rotations.rotate_B_counter(cube) cube = rotations.rotate_U_counter(cube) elif b == 'b': cube = rotations.rotate_U(cube) cube = rotations.rotate_B_counter(cube) cube = rotations.rotate_U_counter(cube) elif a == 'g': if b == 'w': cube = rotations.rotate_R(cube) cube = rotations.rotate_F_counter(cube) cube = rotations.rotate_L_counter(cube) cube = rotations.rotate_R_counter(cube) elif b == 'r': cube = rotations.rotate_U(cube) cube = rotations.rotate_U(cube) cube = rotations.rotate_R(cube) cube = rotations.rotate_U(cube) cube = rotations.rotate_U(cube) elif b == 'y': cube = rotations.rotate_R(cube) cube = rotations.rotate_F(cube) cube = rotations.rotate_L_counter(cube) cube = rotations.rotate_R_counter(cube) elif b == 'o': cube = rotations.rotate_L_counter(cube) elif a == 'r': if b == 'b': cube = rotations.rotate_U(cube) cube = rotations.rotate_B(cube) cube = rotations.rotate_U_counter(cube) elif b == 'y': cube = rotations.rotate_D_counter(cube) cube = rotations.rotate_R(cube) cube = rotations.rotate_F(cube) cube = rotations.rotate_L_counter(cube) cube = rotations.rotate_R_counter(cube) elif b == 'g': cube = rotations.rotate_U_counter(cube) cube = rotations.rotate_F_counter(cube) cube = rotations.rotate_U(cube) elif a == 'b': if b == 'w': cube = rotations.rotate_R_counter(cube) cube = rotations.rotate_B(cube) cube = rotations.rotate_R(cube) cube = rotations.rotate_L(cube) elif b == 'o': cube = rotations.rotate_L(cube) elif b == 'y': cube = rotations.rotate_R_counter(cube) cube = rotations.rotate_B_counter(cube) cube = rotations.rotate_R(cube) cube = rotations.rotate_L(cube) elif b == 'r': cube = rotations.rotate_U(cube) cube = rotations.rotate_U(cube) cube = rotations.rotate_R_counter(cube) cube = rotations.rotate_U(cube) cube = rotations.rotate_U(cube) elif a == 'y': if b == 'g': cube = rotations.rotate_D_counter(cube) cube = rotations.rotate_L(cube) cube = rotations.rotate_L(cube) elif b == 'r': cube = rotations.rotate_D(cube) cube = rotations.rotate_D(cube) cube = rotations.rotate_L(cube) cube = rotations.rotate_L(cube) elif b == 'b': cube = rotations.rotate_D(cube) cube = rotations.rotate_L(cube) cube = rotations.rotate_L(cube) elif b == 'o': cube = rotations.rotate_L(cube) cube = rotations.rotate_L(cube) return cube
def bring_corner_back(cube, a, b, c): abc = a + b + c if abc == 'owb' or abc == 'bow' or abc == 'wbo': return cube elif abc == 'wrb': cube = rotations.rotate_R(cube) cube = rotations.rotate_R(cube) elif abc == 'wog': cube = rotations.rotate_F(cube) cube = rotations.rotate_F(cube) elif abc == 'wgr': cube = rotations.rotate_D(cube) cube = rotations.rotate_R(cube) cube = rotations.rotate_R(cube) elif abc == 'ogw': cube = rotations.rotate_D_counter(cube) cube = rotations.rotate_F(cube) elif abc == 'oyg': cube = rotations.rotate_F(cube) elif abc == 'oby': cube = rotations.rotate_R_counter(cube) cube = rotations.rotate_D(cube) elif abc == 'gwo': cube = rotations.rotate_R(cube) cube = rotations.rotate_F_counter(cube) elif abc == 'grw': cube = rotations.rotate_R(cube) elif abc == 'gyr': cube = rotations.rotate_R(cube) cube = rotations.rotate_F(cube) elif abc == 'goy': cube = rotations.rotate_R(cube) cube = rotations.rotate_F(cube) cube = rotations.rotate_F(cube) elif abc == 'rwg': cube = rotations.rotate_F_counter(cube) elif abc == 'rbw': cube = rotations.rotate_F_counter(cube) cube = rotations.rotate_R(cube) elif abc == 'ryb': cube = rotations.rotate_F_counter(cube) cube = rotations.rotate_R(cube) cube = rotations.rotate_R(cube) elif abc == 'rgy': cube = rotations.rotate_F_counter(cube) cube = rotations.rotate_R_counter(cube) elif abc == 'bwr': cube = rotations.rotate_D(cube) cube = rotations.rotate_R_counter(cube) elif abc == 'byo': cube = rotations.rotate_F(cube) cube = rotations.rotate_D_counter(cube) elif abc == 'bry': cube = rotations.rotate_R_counter(cube) elif abc == 'ygo': cube = rotations.rotate_D_counter(cube) elif abc == 'yrg': return cube elif abc == 'ybr': cube = rotations.rotate_D(cube) elif abc == 'yob': cube = rotations.rotate_D(cube) cube = rotations.rotate_D(cube) return cube