Ejemplo n.º 1
0
def deface_unsolved_faced_corner(cube, facetosolve, ccolor):
    cornerrowcells = jbrik_cube.get_cornercell_rowcells_for_face(facetosolve)
    for cornerrowcell in cornerrowcells:
        if cube.get_cell_val_by_rowcell(
                cornerrowcell) == ccolor and not is_crosscorner_solved(
                    (cube, cornerrowcell)):
            log_utils.log(cornerrowcell + " is faced but not solved")
            defacemovestrset = jbrik_cube.get_solveface_corner_oppfaceorbit_trans(
                cornerrowcell)
            defacemove = defacemovestrset.split(" ")[0]
            defaceunwindmove = jbrik_solver_move_lib.reversetransition(
                defacemove)
            o2move = defacemovestrset.split(" ")[1]

            log_utils.log("Moving: " + defacemove + " to move " +
                          cornerrowcell + " off solve face.")
            cube = jbrik_solver_move_lib.perform_rotation_str(defacemove, cube)

            log_utils.log("Moving: " + o2move + " to move " + cornerrowcell +
                          " out of unwind move")
            cube = jbrik_solver_move_lib.perform_rotation_str(o2move, cube)

            log_utils.log("Moving: " + defaceunwindmove)
            cube = jbrik_solver_move_lib.perform_rotation_str(
                defaceunwindmove, cube)

            break

    return cube
Ejemplo n.º 2
0
def move_solveface_orbitcells_to_oppface(cube, solveface, ccolor):
    solvefaceorbits = jbrik_cube.FACEORBITS[solveface]
    for orbitrowcell in solvefaceorbits:
        log_utils.log("Checking solveface orbit rowcell: " + orbitrowcell +
                      " for needed transitions.")
        if cube.get_cell_val_by_rowcell(orbitrowcell) == ccolor:
            rotfacedir = jbrik_cube.get_solvefacefaceorbit_o2_trans(
                orbitrowcell)
            rotface = rotfacedir[0]
            rotdir = rotfacedir[1:3]
            rotstr = rotfacedir + "1"
            unwindmove = jbrik_solver_move_lib.reversetransition(rotstr)

            log_utils.log("Rotate face: " + rotface.__str__() + " " + rotdir +
                          " to move it to opposite solve face.")
            cube = jbrik_solver_move_lib.perform_rotation_str(rotstr, cube)

            oppface = jbrik_cube.OPPOSITEFACES[solveface]
            rotstr = oppface.__str__() + "CW1"
            log_utils.log("Rotate oppface: " + rotstr +
                          " to move target cell<???> out of the way of unwind")
            cube = jbrik_solver_move_lib.perform_rotation_str(rotstr, cube)

            log_utils.log("Performing unwind: " + unwindmove)
            cube = jbrik_solver_move_lib.perform_rotation_str(unwindmove, cube)
            break

    return cube
Ejemplo n.º 3
0
def solvecrosscorner_o2(cube, solverowcell, oppface):
    log_utils.log("Performing 2nd order crosscorner solve for: " +
                  solverowcell)

    rotmstrset = jbrik_cube.get_oppfaceorbit_o2_trans(solverowcell)
    rotstr1 = rotmstrset.split(" ")[0]
    rotstr2 = rotmstrset.split(" ")[1]

    log_utils.log("Rotate face: " + rotstr1 + " to put " + solverowcell +
                  " into position to align with solveface.")
    cube = jbrik_solver_move_lib.perform_rotation_str(rotstr1, cube)
    unwindmove1 = jbrik_solver_move_lib.reversetransition(rotstr1)

    log_utils.log("Rotate face: " + rotstr2 + " to put " + solverowcell +
                  " to align with solveface.")
    cube = jbrik_solver_move_lib.perform_rotation_str(rotstr2, cube)
    unwindmove2 = jbrik_solver_move_lib.reversetransition(rotstr2)

    log_utils.log("Rotate face: " + unwindmove1 +
                  " to unwind first transition")
    cube = jbrik_solver_move_lib.perform_rotation_str(unwindmove1, cube)

    log_utils.log("Rotate face: " + unwindmove2 +
                  " to unwind second transition")
    cube = jbrik_solver_move_lib.perform_rotation_str(unwindmove2, cube)

    return cube
Ejemplo n.º 4
0
def facecross_o1(cube, ccolor, facetosolve, atomic=False):
    startsolvelen = -1
    while cube.get_current_solve_move_list().__len__() != startsolvelen:
        startsolvelen = cube.get_current_solve_move_list().__len__()

        log_utils.log("Checking for 1st order face transitions for face: " +
                      facetosolve.__str__())

        # check for first order moves
        for rowcell in jbrik_cube.get_cross_rowcell_for_face(facetosolve):
            log_utils.log("Checking state of " + rowcell)
            if cube.get_cell_val_by_rowcell(rowcell) == ccolor:
                log_utils.log(rowcell + " is faced.\n")
                continue
            #can replace some of this
            solvestr = get_facestr_for_cross_rowcell(rowcell, ccolor, cube)
            if solvestr != "" and solvestr is not None:
                log_utils.log(rowcell + " is solved by: " + solvestr)
                log_utils.log("Solve move list: " +
                              cube.get_current_solve_move_list().__str__())
                cube = jbrik_solver_move_lib.perform_rotation_str(
                    solvestr, cube)
                if atomic:
                    return cube
            else:
                log_utils.log("No first order solution for " + rowcell + "\n")

        log_utils.log("Start solve length: " + startsolvelen.__str__() +
                      " solvelist length: " +
                      cube.get_current_solve_move_list().__len__().__str__() +
                      "\n")
        cube.print_cube("", True)
    return cube
Ejemplo n.º 5
0
def perform_lr_solve_on_cross_rowcell(facetosolve, crossrowcell, cube):
    crossrowcellcolor = cube.get_cell_val_by_rowcell(crossrowcell)
    adjrowcell = jbrik_cube.get_adjrowccell_for_rowcell(crossrowcell)
    adjrowcellcolor = cube.get_cell_val_by_rowcell(adjrowcell)
    adjrowcellcolorccolor = cube.get_center_color_for_rowcell(adjrowcell)

    # if this rowcell is already aligned with adjacent color same as center color
    if adjrowcellcolor == adjrowcellcolorccolor:
        adjrowcell = jbrik_cube.get_adjrowccell_for_rowcell(crossrowcell)
        lrrowcells = jbrik_cube.get_oppface_centerrowcell_lr_middle_destcells(
            crossrowcell)
        lcrossrowcell = lrrowcells.split(" ")[0]
        rcrossrowcell = lrrowcells.split(" ")[1]

        lcrossccolor = cube.get_center_color_for_rowcell(lcrossrowcell)
        rcrossccolor = cube.get_center_color_for_rowcell(rcrossrowcell)

        if crossrowcellcolor == lcrossccolor:
            log_utils.log("Perform an L cross solve on: " + crossrowcell)
            solutionlist = get_lrcross_solution_list(facetosolve,
                                                     lcrossrowcell, adjrowcell,
                                                     "L")

            for lmove in solutionlist:
                cube = jbrik_solver_move_lib.perform_rotation_str(lmove, cube)

            if not is_middle_rowcell_solved(lcrossrowcell, cube):
                cube = swap_backwards_oriented_mid_rowcell(
                    facetosolve, lcrossrowcell, "swap", cube)

        elif crossrowcellcolor == rcrossccolor:
            log_utils.log("Perform a R cross solve on: " + crossrowcell)
            solutionlist = get_lrcross_solution_list(facetosolve,
                                                     rcrossrowcell, adjrowcell,
                                                     "R")

            for rmove in solutionlist:
                cube = jbrik_solver_move_lib.perform_rotation_str(rmove, cube)

            if not is_middle_rowcell_solved(rcrossrowcell, cube):
                cube = swap_backwards_oriented_mid_rowcell(
                    facetosolve, rcrossrowcell, "swap", cube)

    return cube
Ejemplo n.º 6
0
def swap_backwards_oriented_mid_rowcell(facetosolve, rowcell, swaptype, cube):
    rowcellcolor = cube.get_cell_val_by_rowcell(rowcell)
    rowcellccolor = cube.get_center_color_for_rowcell(rowcell)
    adjrowcell = jbrik_cube.get_adjrowccell_for_rowcell(rowcell)
    adjrowcellcolor = cube.get_cell_val_by_rowcell(adjrowcell)
    adjrowcellccolor = cube.get_center_color_for_rowcell(adjrowcell)

    # check orientation
    if rowcellcolor == adjrowcellccolor and adjrowcellcolor == rowcellccolor:
        log_utils.log("Rowcell: " + rowcell +
                      " is backwards oriented, swapping.")
        if jbrik_cube.FIVESIXMIDROWCROSSROWCELLS_L.__contains__(rowcell):
            # its a leftswap
            #movestrlist = get_leftcross_solution_list(facetosolve, adjrowcell, rowcell)
            movestrlist = get_lrcross_solution_list(facetosolve, adjrowcell,
                                                    rowcell, "L")
            log_utils.log("leftswap " + swaptype + " rowcell: " + rowcell +
                          " of color: " + rowcellccolor +
                          " and adjacent cell: " + adjrowcell +
                          " with color: " + adjrowcellcolor)
        else:
            # its a rightswap
            #movestrlist = get_rightcross_solution_list(facetosolve, adjrowcell, rowcell)
            movestrlist = get_lrcross_solution_list(facetosolve, adjrowcell,
                                                    rowcell, "R")
            log_utils.log("Rightswap " + swaptype + " rowcell: " + rowcell +
                          " of color: " + rowcellccolor +
                          " and adjacent cell: " + adjrowcell +
                          " with color: " + adjrowcellcolor)

        for rmove in movestrlist:
            cube = jbrik_solver_move_lib.perform_rotation_str(rmove, cube)

        cube = jbrik_solver_move_lib.perform_rotation_str("3CW2", cube)

        if swaptype != "back":
            for rmove in movestrlist:
                cube = jbrik_solver_move_lib.perform_rotation_str(rmove, cube)

    return cube
Ejemplo n.º 7
0
def facecross_o2(cube, ccolor, facetosolve):
    log_utils.log("Checking for 2nd order face transitions for face: " +
                  facetosolve.__str__())
    opptosolveface = jbrik_cube.OPPOSITEFACES[facetosolve]
    log_utils.log("Face: " + opptosolveface.__str__() +
                  " is opposite to the solving face.")

    o2inposition = False
    for rowcell in jbrik_cube.get_cross_rowcell_for_face(opptosolveface):
        if cube.get_cell_val_by_rowcell(rowcell) == ccolor:
            log_utils.log(rowcell + " is a second order facing transition.")

            #identify the first cell that isn't faced
            for facecell in jbrik_cube.get_cross_rowcell_for_face(facetosolve):
                log_utils.log("Checking state of " + facecell)
                if cube.get_cell_val_by_rowcell(facecell) != ccolor:
                    log_utils.log(facecell + " is not faced, move " + rowcell +
                                  " here.\n")

                    for crosscell in jbrik_cube.get_cross_rowcell_for_face(
                            opptosolveface):
                        adjfaceforrowcell = jbrik_cube.get_adj_face_for_rowcell(
                            crosscell)
                        if adjfaceforrowcell == jbrik_cube.get_adj_face_for_rowcell(
                                facecell):
                            log_utils.log("Rotate face: " +
                                          opptosolveface.__str__() +
                                          " until " + crosscell + " is " +
                                          ccolor)
                            break

                    rotcount = 0
                    while cube.get_cell_val_by_rowcell(crosscell) != ccolor:
                        rotcount = rotcount + 1
                        cube = jbrik_solver_move_lib.perform_rotation_str(
                            opptosolveface.__str__() + "CW1", cube, False)
                    if rotcount > 0:
                        movestr = opptosolveface.__str__(
                        ) + "CW" + rotcount.__str__()
                        log_utils.log("Perform transition: " + movestr)
                        cube.get_current_solve_move_list().append(movestr)
                        cube.print_cube()
                        o2inposition = True
                        break

            cube = facecross_o1(cube, ccolor, facetosolve)
            if o2inposition:
                break

    log_utils.log("No more second order transitions for face: " +
                  facetosolve.__str__())
    return cube
Ejemplo n.º 8
0
def face_oppface_cross(cube):
    log_utils.log("Positioning opposite face cross.")
    facetosolve = 3
    ccolor = cube.get_center_color_for_facenum(facetosolve)

    faced = False
    while not faced:
        #determine count of faced crosscells
        facedcelllist = []
        crosscells = jbrik_cube.get_cross_rowcell_for_face(facetosolve)
        for crosscell in crosscells:
            if cube.get_cell_val_by_rowcell(crosscell) == ccolor:
                facedcelllist.append(crosscell)

        if facedcelllist.__len__() == 4:
            faced = True
            break

        alignmenttype = "0"
        tface = facetosolve.__str__()
        fface = "6"
        rface = "4"

        if facedcelllist.__len__() > 1:
            facedcelllist.sort()
            log_utils.log("Solved cells: " + facedcelllist.__str__())
            solvedcells = facedcelllist[0] + " " + facedcelllist[1]

            facemap = jbrik_cube.OPPFACECELL_RFACE_CENTER_ALIGN_MAP[solvedcells]
            alignmenttype = facemap.split(" ")[0]
            tface = facetosolve.__str__()
            fface = facemap.split(" ")[1].__str__()
            rface = facemap.split(" ")[2].__str__()

        # start anywhere with 0 or line
        if alignmenttype != "V":
            log_utils.log("Performing line movelist.")
            # F R U R' U' F'
            movelist = [fface + "CW1", rface + "CW1", tface + "CW1", rface + "CC1", tface + "CC1", fface + "CC1"]

        else:
            # align v to left/top for frontface
            log_utils.log("Performing shortcut V movelist.")
            # F U R U' R' F'
            movelist = [fface + "CW1", tface + "CW1", rface + "CW1", tface + "CC1", rface + "CC1", fface + "CC1"]

        for rmove in movelist:
            cube = jbrik_solver_move_lib.perform_rotation_str(rmove, cube)

    cube.finalize_solve_phase(4,)
    log_utils.log("Opposite face cross positioned")
    return cube
Ejemplo n.º 9
0
def swap_non_oriented_mid_rowcells_to_top(facetosolve, cube):
    # change this to get all mid row cells
    for rowcell in jbrik_cube.MIDDLE_ROWCCELLS:
        rowcellcolor = cube.get_cell_val_by_rowcell(rowcell)
        rowcellccolor = cube.get_center_color_for_rowcell(rowcell)
        adjrowcell = jbrik_cube.get_adjrowccell_for_rowcell(rowcell)
        adjrowcellcolor = cube.get_cell_val_by_rowcell(adjrowcell)
        adjrowcellccolor = cube.get_center_color_for_rowcell(adjrowcell)
        ccolor = cube.get_center_color_for_facenum(facetosolve)

        if (rowcellcolor != rowcellccolor and adjrowcellcolor != adjrowcellccolor and rowcellcolor != ccolor
            and adjrowcellcolor != ccolor) \
           or (rowcellcolor == rowcellccolor and adjrowcellcolor == ccolor):

            log_utils.log(
                "Rowcell: " + rowcell +
                " is either a total missalign or solved by an LR swap, with "
                "cell color: " + rowcellcolor + " and adjacent color: " +
                adjrowcellcolor)

            movedir = jbrik_cube.get_centerrow_orbit_trans_dir(rowcell)

            # get middle cell in the direction of movement and if it's solved skip this transition
            midlrs = jbrik_cube.MIDDLE_ROWCCELLS_LR_ADJ[rowcell]

            movestrlist = ""
            if movedir == "L":
                if is_middle_rowcell_solved(midlrs.split(" ")[0], cube):
                    return cube

                movestrlist = get_lrcross_solution_list(
                    facetosolve, adjrowcell, rowcell, "L")
            else:
                if is_middle_rowcell_solved(midlrs.split(" ")[1], cube):
                    return cube

                movestrlist = get_lrcross_solution_list(
                    facetosolve, adjrowcell, rowcell, "R")

            movestrlist.append(facetosolve.__str__() + "CW2")

            # one time put is in the right place but reverse
            for i in range(0, 3):
                for rmove in movestrlist:
                    cube = jbrik_solver_move_lib.perform_rotation_str(
                        rmove, cube)

            return cube

    return cube
Ejemplo n.º 10
0
def align_oppface_crossrowcell_to_adj_ccolor(facetosolve, cube):
    oppfacecrossrowcells = jbrik_cube.get_cross_rowcell_for_face(facetosolve)

    for crossrowcell in oppfacecrossrowcells:
        ccolor = cube.get_center_color_for_facenum(facetosolve)
        rowcellcolor = cube.get_cell_val_by_rowcell(crossrowcell)
        adjrowcell = jbrik_cube.get_adjrowccell_for_rowcell(crossrowcell)
        adjrowcellcolor = cube.get_cell_val_by_rowcell(adjrowcell)
        adjrowcellccolor = cube.get_center_color_for_rowcell(adjrowcell)

        # will be an issue here if all adjcell have ccolor
        if adjrowcellcolor == ccolor or rowcellcolor == ccolor:
            continue

        # if crossrowcellcolor is not facetosolve ccolor then it must be one of the adj ccolors
        testrowcell = adjrowcell
        testrowcellccolor = adjrowcellccolor
        rotcount = 0
        while adjrowcellcolor != testrowcellccolor:
            if rotcount > 3:
                log_utils.log("No solveface alignment.")
                return cube

            log_utils.log(
                "Rotate face: " + facetosolve.__str__() +
                " CW1 and check for match to adjacent face center color.")
            rotcount = rotcount + 1
            testrowcell = jbrik_cube.get_dest_pos_for_face_rotation(
                testrowcell,
                facetosolve.__str__() + "CW1")
            testrowcellccolor = cube.get_center_color_for_rowcell(testrowcell)

        # we've idetified a match, rotate here
        if rotcount > 0:
            rotstr = facetosolve.__str__() + "CW" + rotcount.__str__()
            log_utils.log("Perform transition: " + rotstr)
            cube = jbrik_solver_move_lib.perform_rotation_str(rotstr, cube)

            adjtestrowcell = jbrik_cube.get_adjrowccell_for_rowcell(
                testrowcell)
            log_utils.log("Solveface orbit rowcell: " + adjtestrowcell +
                          " of color: " + adjrowcellcolor +
                          " is aligned for LR check.")

            cube = perform_lr_solve_on_cross_rowcell(facetosolve,
                                                     adjtestrowcell, cube)
            return cube

    return cube
Ejemplo n.º 11
0
def position_oppface_corners(cube):
    log_utils.log("Positioning oppface corners.")
    facetosolve = 3

    solved = False
    while not solved:
        positionedrowcell = ""
        cornercelladjfacelist = []

        # identify a corner thats positioned correctly, 3 face colors sorted = 3 center colors sorted
        for cornerrowcell in jbrik_cube.get_cornercell_rowcells_for_face(facetosolve):
            if is_corner_positioned(cornerrowcell, cube):
                log_utils.log("Rowcell: " + cornerrowcell + " is positioned correctly.")
                positionedrowcell = cornerrowcell
                break

        # orient so that this corner is front top right, we can map this,
        # nothing is positioned do algo on any random corner
        cornercelladjfacelist = jbrik_cube.OPPFACE_CELL_FACE_MAP.get("7.1")
        if positionedrowcell != "":
            # otherwise do it the positioned corner
            cornercelladjfacelist = jbrik_cube.OPPFACE_CELL_FACE_MAP[positionedrowcell]
            log_utils.log("Adjacent faces for " + positionedrowcell + ": " + cornercelladjfacelist.__str__())

        # if 7.1 f=2, t=3, l=5, r=6
        tface = facetosolve.__str__()
        fface = cornercelladjfacelist[0].__str__()
        lface = cornercelladjfacelist[2].__str__()
        rface = cornercelladjfacelist[3].__str__()

        # perform this algorith
        # URU'L'UR'U'L
        movelist =  [tface + "CW1", rface + "CW1", tface + "CC1", lface + "CC1", tface + "CW1", rface + "CC1", tface + "CC1", lface + "CW1"]
        log_utils.log("Constructed movelist: " + movelist.__str__())

        for rmove in movelist:
            cube = jbrik_solver_move_lib.perform_rotation_str(rmove, cube)

        # will only take 3 cycles because only 2 possible states
        # no corner positioned = 2 cycles
        # 1 corner positioned = 1 cycles
        # 4 corners positioned = no cycles
        if are_all_corners_positioned(facetosolve, cube):
            solved = True

    cube.finalize_solve_phase(6,)
    log_utils.log("Opposite face corners positioned")
    return cube
Ejemplo n.º 12
0
def move_oppfaceorbit_rowcells_into_o2_and_solve(cube, oppface, ccolor):
    oppfaceorbit = jbrik_cube.FACEORBITS[oppface]

    # identify first, if any rowcells are solvable on oppface orbit
    log_utils.log("Looking for " + ccolor + " rowcell on opp face orbit")
    for rowcell in oppfaceorbit:
        if cube.get_cell_val_by_rowcell(rowcell) == ccolor:
            log_utils.log(rowcell + " is on opp face orbit and is " + ccolor)
            rotstr = get_movestr_to_move_rowcell_to_o2_solve_pos(
                cube, rowcell, oppface)

            destrowcell = rowcell

            if rotstr != "":
                destradjowcell = jbrik_cube.get_non_oppface_adj_rowcell_for_corner(
                    destrowcell, oppface)
                destrowcell = jbrik_cube.get_dest_pos_for_face_rotation(
                    destradjowcell, rotstr)

                destradjowcell = jbrik_cube.get_non_oppface_adj_rowcell_for_corner(
                    destrowcell, oppface)
                cube = jbrik_solver_move_lib.perform_rotation_str(rotstr, cube)

                log_utils.log(destradjowcell +
                              " is in 2nd order solve position.")
                cube = solvecrosscorner_o2(cube, destradjowcell, oppface)

            else:
                log_utils.log(destrowcell + " is in 2nd order solve position.")
                cube = solvecrosscorner_o2(cube, destrowcell, oppface)

            # recurse
            cube = move_oppfaceorbit_rowcells_into_o2_and_solve(
                cube, oppface, ccolor)

    return cube
Ejemplo n.º 13
0
def solve_oppface_corners(cube):
    log_utils.log("Solving opposite face corners.")
    facetosolve = 3
    ccolor = cube.get_center_color_for_facenum(facetosolve)

    solved = False
    while not solved:
        unsolvedcornerlist = []
        for cornerrowcell in jbrik_cube.get_cornercell_rowcells_for_face(
                facetosolve):
            if not is_corner_solved(cornerrowcell, ccolor, cube):
                unsolvedcornerlist.append(cornerrowcell)

        if unsolvedcornerlist.__len__() != 0:
            unsolvedcornerlist.sort()
            if unsolvedcornerlist.__len__() == 4:
                unsolvedcorners = unsolvedcornerlist[
                    0] + " " + unsolvedcornerlist[1] + " " + unsolvedcornerlist[
                        2] + " " + unsolvedcornerlist[3]
            elif unsolvedcornerlist.__len__() == 3:
                unsolvedcorners = unsolvedcornerlist[
                    0] + " " + unsolvedcornerlist[
                        1] + " " + unsolvedcornerlist[2]
            elif unsolvedcornerlist.__len__() == 2:
                unsolvedcorners = unsolvedcornerlist[
                    0] + " " + unsolvedcornerlist[1]
            elif unsolvedcornerlist.__len__() == 1:
                print("investigate this case")

            # orient so that (top) oppface front right corner is unsolved (as well as the front left corner) if you can get both
            # find right hand face for solved rowcell combo
            tface = facetosolve.__str__()
            bface = "1"
            rface = jbrik_cube.OPPFACECELL_RFACE_CORNER_ALIGN_MAP[
                unsolvedcorners].split(" ")[0].__str__()
            cornertosolve = jbrik_cube.OPPFACECELL_RFACE_CORNER_ALIGN_MAP[
                unsolvedcorners].split(" ")[1]

            # special case where solved rows are opposites
            if unsolvedcorners == "7.1 9.3" or unsolvedcorners == "7.3 9.1":
                # rotate once to move unsolved corner into top/front/right
                cube = jbrik_solver_move_lib.perform_rotation_str(
                    tface + "CW1", cube)

            # do this algo 2, check for solve
            # if not solved, 2 more times
            # rotate top until next unsolved corner is in front top right
            # (R' D' R D) x2/4 + u inbetween and after
            movelist = [
                rface + "CC1", bface + "CC1", rface + "CW1", bface + "CW1"
            ]

            for i in range(0, unsolvedcornerlist.__len__()):
                # after 2 check for solve,
                attemptcount = 0
                while not is_corner_solved(cornertosolve, ccolor,
                                           cube) and attemptcount < 2:
                    cube = attempt_corner_solve(movelist, cube)
                    attemptcount += 1

                if are_all_corners_solved(cube, facetosolve):
                    # final rotation
                    cube = jbrik_solver_move_lib.perform_rotation_str(
                        tface + "CW1", cube)
                    break

                # rotate until next unsolved is in top/front/right, never more than 2 turns
                attemptcount = 0
                while is_corner_solved(cornertosolve, ccolor,
                                       cube) and attemptcount < 2:
                    cube = jbrik_solver_move_lib.perform_rotation_str(
                        tface + "CW1", cube)
                    attemptcount += 1

        else:
            solved = True

    cube.finalize_solve_phase(7, )
    log_utils.log("Opposite face corners solved.")
    return cube
Ejemplo n.º 14
0
def facecross_o3(cube, ccolor, facetosolve):
    unwindlist = []
    resultpos = ""

    # identify the next rowcell that needs to be faced
    for rowcelltoface in jbrik_cube.get_cross_rowcell_for_face(facetosolve):
        log_utils.log("Checking state of " + rowcelltoface)
        if cube.get_cell_val_by_rowcell(rowcelltoface) != ccolor:
            log_utils.log(rowcelltoface + " is the rowcell to face.\n")
            resultpos = rowcelltoface
            break

    if resultpos == "":
        log_utils.log("No more cross positions to face on face: " +
                      facetosolve.__str__())
        return cube

    # identify the first rowcell we can move into resultpos
    opptosolveface = jbrik_cube.OPPOSITEFACES[facetosolve]
    rowcelltomove = ""
    for facenum in range(1, 7):
        log_utils.log("Checking face: " + facenum.__str__() +
                      " for cross cells that can face: " + resultpos)
        if facenum == facetosolve or facenum == opptosolveface:
            log_utils.log("Skipping solve/opp face: " + facenum.__str__())
            continue

        rowcelltomove = get_centerrowcell_of_color_from_face(
            cube, facenum, ccolor)
        if rowcelltomove != "":
            break

    # rotate rowcell into middle row if needed by checking if CW rotation puts rowcelltomove adj oppface or solveface
    if rowcelltomove != "":
        rotdir = "CW"
        rotface = jbrik_cube.get_face_for_rowcell(rowcelltomove)
        nextpos = jbrik_cube.get_next_centerpos_for_face_rotation(
            rotface, rowcelltomove)
        resultposadjface = jbrik_cube.get_adj_face_for_rowcell(resultpos)

        # if nextpos is not adj to oppface or solveface we want to go there
        rowcelladjtonextpos = jbrik_cube.get_adjrowccell_for_rowcell(nextpos)
        nextposadjface = jbrik_cube.get_face_for_rowcell(rowcelladjtonextpos)
        if nextposadjface != opptosolveface and nextposadjface != facetosolve:
            # first align resultpos to to the face we want to rotate
            rotcount = 0
            while cube.get_cell_val_by_rowcell(resultpos) == ccolor:
                rotcount = rotcount + 1
                cube = jbrik_solver_move_lib.perform_rotation_str(
                    facetosolve.__str__() + "CW1", cube, False)
            if rotcount > 0:
                movestr = facetosolve.__str__() + "CW" + rotcount.__str__()
                log_utils.log("Perform transition: " + movestr)
                cube.get_current_solve_move_list().append(movestr)

            rotface = jbrik_cube.get_face_for_rowcell(rowcelltomove)
            log_utils.log("Rotating face: " + rotface.__str__() + " " +
                          "CW1 to move: " + rowcelltomove +
                          " into position: " + nextpos +
                          " for next rotation to opposite face.")
            movestr = rotface.__str__() + "CW1"
            cube = jbrik_solver_move_lib.perform_rotation_str(movestr, cube)
            rowcelltomove = nextpos

        # Were in the middle row at this point and in o1 position, either use an o1 transition or use a static move set to find face and move
        if nextposadjface == resultposadjface:
            log_utils.log("Rowcell: " + nextpos +
                          " is in first order solve position for: " +
                          resultpos)
            o1move = jbrik_cube.get_crosscenter_solvface_trans(nextpos)
            cube = jbrik_solver_move_lib.perform_rotation_str(o1move, cube)

            return cube

        # we're in o2 position (solveface rotation) but a non midrow because we're on a 4/6 face
        if jbrik_cube.FIVESIXMIDROWCROSSROWCELLS.__contains__(rowcelltomove):
            log_utils.log(
                rowcelltomove +
                " is an o2 position but non mid row because it on a 4/6 face")
            nextposmovestr = jbrik_cube.get_crosscenter_solvface_trans(
                rowcelltomove)
            resultpos = jbrik_cube.get_dest_pos_for_face_rotation(
                rowcelltomove, nextposmovestr)

            rotcount = 0
            while cube.get_cell_val_by_rowcell(resultpos) == ccolor:
                rotcount = rotcount + 1
                cube = jbrik_solver_move_lib.perform_rotation_str(
                    facetosolve.__str__() + "CW1", cube, False)
            if rotcount > 0:
                movestr = facetosolve.__str__() + "CW" + rotcount.__str__()
                log_utils.log("Performed transition: " + movestr)
                cube.get_current_solve_move_list().append(movestr)

            # resultpos is now ready to be faced
            cube = jbrik_solver_move_lib.perform_rotation_str(
                nextposmovestr, cube)

            return cube

        # we're in a middle row but a non o1 position rotate a non face position into the dest cell for nextpos
        if rowcelltomove != opptosolveface and rowcelltomove != facetosolve:
            # identify the destination of the next nextpos rotation
            nextposmovestr = jbrik_cube.get_crosscenter_solvface_trans(
                rowcelltomove)
            resultpos = jbrik_cube.get_dest_pos_for_face_rotation(
                rowcelltomove, nextposmovestr)

            rotcount = 0
            while cube.get_cell_val_by_rowcell(resultpos) == ccolor:
                rotcount = rotcount + 1
                cube = jbrik_solver_move_lib.perform_rotation_str(
                    facetosolve.__str__() + "CW1", cube, False)
            if rotcount > 0:
                movestr = facetosolve.__str__() + "CW" + rotcount.__str__()
                log_utils.log("Perform transition: " + movestr)
                cube.get_current_solve_move_list().append(movestr)

            # resultpos is now ready to be faced
            cube = jbrik_solver_move_lib.perform_rotation_str(
                nextposmovestr, cube)

            return cube

        # we're on the oppface orbit,
        # rotate solveface until rowcelltomove and rowcelltoface share an adjface
        # rotate the adjface until rowcelltoface is ccolor, might be a transition for this get_facetrans_to_resultin_rowcell(rowcelltomove)
        print(" if we made it this far nextpos is on oppface orbit??")

        print("should never get here eject")

    return cube
Ejemplo n.º 15
0
def solve_crossoppface_orbits(cube):
    facetosolve = 3

    solved = False

    while not solved:
        crosscells = jbrik_cube.get_cross_rowcell_for_face(facetosolve)
        solvedcells = []
        for crosscell in crosscells:
            if not is_rowcell_solved(facetosolve, crosscell, cube):

                tface = facetosolve.__str__()

                # a CW rotation is a leftshift
                if is_nextpos_solved_by_rowcell(facetosolve, crosscell, cube):
                    log_utils.log("A leftshift of rowcell: " + crosscell +
                                  " solves the next pos.")

                    # "0.0": ["f", "l", "r"],
                    facemap = jbrik_cube.OPPFACE_CENTERCELL_FACEMAP[crosscell]
                    rface = facemap[2].__str__()

                    # R U R' U R U2 R' U
                    movelist = [
                        rface + "CW1",
                        tface + "CW1",
                        rface + "CC1",
                        tface + "CW1",
                        rface + "CW1",
                        tface + "CW2",
                        rface + "CC1",
                        tface + "CW1",
                    ]

                    for move in movelist:
                        cube = jbrik_solver_move_lib.perform_rotation_str(
                            move, cube)

                elif is_180pos_solved_by_rowcell(facetosolve, crosscell, cube):
                    log_utils.log("A 180shift of rowcell: " + crosscell +
                                  " solves the 180 pos.")

                    #destrowcell = jbrik_cube.get_oneeightydswap_targetcell(crosscell)
                    destrowcell = jbrik_cube.get_ninetydswap_targetcell(
                        crosscell, "CW")
                    facemap = jbrik_cube.OPPFACE_CENTERCELL_FACEMAP[
                        destrowcell]
                    rface = facemap[2].__str__()

                    # first a CW1 before calculating faces
                    cube = jbrik_solver_move_lib.perform_rotation_str(
                        tface + "CW1", cube)

                    movelist = [
                        rface + "CW1",
                        tface + "CW1",
                        rface + "CC1",
                        tface + "CW1",
                        rface + "CW1",
                        tface + "CW2",
                        rface + "CC1",
                        tface + "CW1",
                    ]

                    for move in movelist:
                        cube = jbrik_solver_move_lib.perform_rotation_str(
                            move, cube)

                    destrowcell = jbrik_cube.get_oneeightydswap_targetcell(
                        destrowcell)
                    facemap = jbrik_cube.OPPFACE_CENTERCELL_FACEMAP[
                        destrowcell]

                    rface = facemap[2].__str__()
                    movelist = [
                        rface + "CW1",
                        tface + "CW1",
                        rface + "CC1",
                        tface + "CW1",
                        rface + "CW1",
                        tface + "CW2",
                        rface + "CC1",
                        tface + "CW1",
                    ]
                    for move in movelist:
                        cube = jbrik_solver_move_lib.perform_rotation_str(
                            move, cube)

            else:
                solvedcells.append(crosscell)

        if solvedcells.__len__() == 4:
            solved = True

    cube.finalize_solve_phase(5, )
    log_utils.log("Opposite face cross solved")
    return cube
Ejemplo n.º 16
0
def move_oppface_corner_into_oppfaceorbit(cube, oppface, ccolor):
    # we know solveface is one because we're solving the cross, could dynamically figure out though using oppface
    solveface = 1

    oppfaceorbit = jbrik_cube.FACEORBITS[oppface]
    oppfacecornerrowcells = jbrik_cube.get_cornercell_rowcells_for_face(
        oppface)
    solvefacecornerrowcells = jbrik_cube.get_cornercell_rowcells_for_face(
        solveface)

    unsolvedcorner = ""
    unsolvedadjfaces = []
    # identify first unsolved corner on solveface
    for solverowcell in solvefacecornerrowcells:
        if not is_crosscorner_solved((cube, solverowcell)):
            log_utils.log(solverowcell + " is not solved")
            unsolvedcorner = solverowcell
            solverowcelladjcells = jbrik_cube.get_adjrowccell_for_rowcell(
                solverowcell)
            for solveadjrowcell in solverowcelladjcells:
                unsolvedadjfaces.append(
                    jbrik_cube.get_face_for_rowcell(solveadjrowcell))

            unsolvedadjfaces.sort()

        if unsolvedcorner != "":
            break

    # get first cccolor cell on oppface
    for rowcell in oppfacecornerrowcells:
        if cube.get_cell_val_by_rowcell(rowcell) == ccolor:
            log_utils.log("Move : " + rowcell + " to opposite face orbit.")
            adjcell = jbrik_cube.get_non_oppface_adj_rowcell_for_corner(
                rowcell, oppface)

            # before determining rotface move rowcell to under unsolved corner
            # rotate oppface unit rowcell shares the same adjfaces as solveadjrowcell
            for oppfacecornerrowcell in oppfacecornerrowcells:
                destrowcelladjfaces = []
                destrowcelladjrowcells = jbrik_cube.get_adjrowccell_for_rowcell(
                    oppfacecornerrowcell)
                for destrowcelladjrowcell in destrowcelladjrowcells:
                    destrowcelladjfaces.append(
                        jbrik_cube.get_face_for_rowcell(destrowcelladjrowcell))

                destrowcelladjfaces.sort()
                if destrowcelladjfaces == unsolvedadjfaces:
                    break

            log_utils.log("Rotate face: " + oppface.__str__() + " until " +
                          oppfacecornerrowcell + " is color: " + ccolor)
            rotcount = 0
            destrowcell = rowcell
            while destrowcell != oppfacecornerrowcell:
                destrowcell = jbrik_cube.get_next_pos_for_face_rotation(
                    oppface, destrowcell)
                rotcount += 1

            rotstr = oppface.__str__() + "CW" + rotcount.__str__()
            if rotcount > 0:
                cube = jbrik_solver_move_lib.perform_rotation_str(rotstr, cube)

            # pick a face to rotate, doesn't matter which because oppfacecornerrowcell is under an unsolved rowcell
            rotface = unsolvedadjfaces[0]

            # rotface need to be the face that puts the unsolved corner onto the orbit
            rotdir = "CW"
            # try CW rotation
            destrowcell = jbrik_cube.get_next_pos_for_face_rotation(
                rotface, oppfacecornerrowcell)
            if not oppfaceorbit.__contains__(destrowcell):
                rotdir = "CC"

            rotstr = rotface.__str__() + rotdir + "1"
            unwindmove = jbrik_solver_move_lib.reversetransition(rotstr)
            log_utils.log(
                "Rotate face: " + rotstr +
                " to put target<??> into position for 2nd order solve.")
            cube = jbrik_solver_move_lib.perform_rotation_str(rotstr, cube)

            log_utils.log(
                "Rotate face: " + oppface.__str__() +
                " 180 to move target<??> out of the way of the unwind move: " +
                unwindmove)
            rotstr = oppface.__str__() + rotdir + "2"
            cube = jbrik_solver_move_lib.perform_rotation_str(rotstr, cube)

            log_utils.log("Performing unwind: " + unwindmove)
            cube = jbrik_solver_move_lib.perform_rotation_str(unwindmove, cube)

    return cube
Ejemplo n.º 17
0
def attempt_corner_solve(movelist, cube):
    for i in range(0, 2):
        for rmove in movelist:
            cube = jbrik_solver_move_lib.perform_rotation_str(rmove, cube)

    return cube