Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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