예제 #1
0
def focus_on_face(cube, face):
    '''
    Given a cube and face that must be on place of RIGHT face of the
    canonical cube. Performs necessary rotations at returns rotated cube and
    rotation path that will return cube at start position.
    '''
    return rotate_path(cube, FOCUS_MAP[face])
예제 #2
0
 def rotation_action(cube):
     rotation.rotate_path(cube, path)
     return unified_path
예제 #3
0
    down[2,:] = back[2,:]
    back[2,:] = up[2,:]
    up[2,:] = front[2,:]
    front[2,:] = tmp
    return cube

def Rw(cube):
    right = cube.get_face(FaceType.RIGHT)
    cube.set_face(FaceType.RIGHT, cube.rotate_face(right, RotationType.ANTICLOCKWISE))
    back, down, front, up = cube.get_faces(FaceType.BACK, FaceType.DOWN, FaceType.FRONT, FaceType.UP)
    tmp = down[2,:].copy()
    down[2,:] = front[2,:]
    front[2,:] = up[2,:]
    up[2,:] = back[2,:]
    back[2,:] = tmp
    return cube


def perform_face_turn(cube, (face, rotation_type)):
    if rotation_type == RotationType.DOUBLE_ROTATE:
        cw = RotationType.CLOCKWISE
        return perform_face_turn(
                perform_face_turn(cube, (face, cw)),
                (face, cw))
    
    cube, retpath = focus_on_face(cube, face)
    cube = R(cube) if rotation_type == RotationType.CLOCKWISE else Rw(cube)
    cube, trash = rotate_path(cube, retpath)
    return cube