Example #1
0
def print_symmetry_swaps(size):
    order = 'ULFRBD'

    if size == 2:
        cube = RubiksCube222(solved_222, 'URFDLB')
        rotate_xxx = rotate_222
    elif size == 3:
        cube = RubiksCube333(solved_333, 'URFDLB')
        rotate_xxx = rotate_333
    elif size == 4:
        cube = RubiksCube444(solved_444, 'URFDLB')
        rotate_xxx = rotate_444
    elif size == 5:
        cube = RubiksCube555(solved_555, 'URFDLB')
        rotate_xxx = rotate_555
    elif size == 6:
        cube = RubiksCube666(solved_666, 'URFDLB')
        rotate_xxx = rotate_666
    elif size == 7:
        cube = RubiksCube777(solved_777, 'URFDLB')
        rotate_xxx = rotate_777
    else:
        assert False

    for (index, _) in enumerate(cube.state):
        cube.state[index] = str(index)

    orig_state = cube.state[:]
    cube.print_cube()

    for seq in symmetry_48:
        cube.state = orig_state[:]
        seq_str = ' '.join(seq)

        if seq_str in ("", "x", "x'", "y", "y'", "z", "z'"):
            continue

        for step in seq:
            cube.state = rotate_xxx(cube.state[:], step)

        print('    "%s" : (%s),' % (' '.join(seq), ', '.join(cube.state)))
from rubikscubennnsolver.RubiksCube666 import RubiksCube666, solved_666
from rubikscubennnsolver.RubiksCube777 import RubiksCube777, solved_777

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s %(filename)20s %(levelname)8s: %(message)s")
log = logging.getLogger(__name__)

filename = sys.argv[1]

with open(filename, "r") as fh:

    if "2x2x2" in filename:
        cube = RubiksCube222(solved_222, "URFDLB")
    elif "3x3x3" in filename:
        cube = RubiksCube333(solved_333, "URFDLB")
    elif "4x4x4" in filename:
        cube = RubiksCube444(solved_444, "URFDLB")
    elif "5x5x5" in filename:
        cube = RubiksCube555(solved_555, "URFDLB")
    elif "6x6x6" in filename:
        cube = RubiksCube666(solved_666, "URFDLB")
    elif "7x7x7" in filename:
        cube = RubiksCube777(solved_777, "URFDLB")
    else:
        raise Exception("What size cube?")

    for line in fh:
        (state, steps_to_solve) = line.strip().split(":")
        cube.re_init()
        cube.nuke_corners()
Example #3
0
    if args.slow:
        cpu_mode = "slow"
    elif args.normal:
        cpu_mode = "normal"
    elif args.fast:
        cpu_mode = "fast"
    else:
        raise Exception("What CPU mode to use?")

    if size == 2:
        from rubikscubennnsolver.RubiksCube222 import RubiksCube222
        cube = RubiksCube222(args.state, args.order, args.colormap, args.debug)
    elif size == 3:
        from rubikscubennnsolver.RubiksCube333 import RubiksCube333
        cube = RubiksCube333(args.state, args.order, args.colormap, args.debug)
    elif size == 4:
        from rubikscubennnsolver.RubiksCube444 import RubiksCube444, solved_444
        cube = RubiksCube444(args.state,
                             args.order,
                             args.colormap,
                             avoid_pll=True,
                             debug=args.debug)
    elif size == 5:
        from rubikscubennnsolver.RubiksCube555 import solved_555

        if cpu_mode == "fast":
            from rubikscubennnsolver.RubiksCube555ForNNN import RubiksCube555ForNNN
            cube = RubiksCube555ForNNN(args.state, args.order, args.colormap,
                                       args.debug)
        else:
    max_solution_kociemba_string = None

    results = []
    order = 'URFDLB'

    for size in sorted(test_cases.keys()):

        if args.size != 'all' and size != args.size:
            continue

        # solve the cube
        if size == '2x2x2':
            cube = RubiksCube222(solved_222, order)

        elif size == '3x3x3':
            cube = RubiksCube333(solved_333, order)

        elif size == '4x4x4':
            cube = RubiksCube444(solved_444, order)

        elif size == '5x5x5':
            cube = RubiksCube555(solved_555, order)

        elif size == '6x6x6':
            cube = RubiksCube666(solved_666, order)

        elif size == '7x7x7':
            cube = RubiksCube777(solved_777, order)

        elif size == '8x8x8':
            cube = RubiksCubeNNNEven(solved_888, order)
Example #5
0
def print_cubes(filename):
    state = []
    with open(filename, 'r') as fh:
        for line in fh:
            if line.strip():
                state.append(line)
    state = ''.join(state)
    order = 'ULFRBD'

    len_state = len(state.replace('\n', '').replace(' ', ''))

    if len_state == 24:
        state = parse_ascii_222(state)
        cube = RubiksCube222(state, order)
        rotate_xxx = rotate_222

    elif len_state == 54:
        state = parse_ascii_333(state)
        cube = RubiksCube333(state, order)
        rotate_xxx = rotate_333

    elif len_state == 96:
        state = parse_ascii_444(state)
        cube = RubiksCube444(state, order)
        rotate_xxx = rotate_444

    elif len_state == 150:
        state = parse_ascii_555(state)
        cube = RubiksCube555(state, order)
        rotate_xxx = rotate_555

    elif len_state == 216:
        state = parse_ascii_666(state)
        cube = RubiksCube666(state, order)
        rotate_xxx = rotate_666

    elif len_state == 294:
        state = parse_ascii_777(state)
        cube = RubiksCube777(state, order)
        rotate_xxx = rotate_777

    else:
        raise Exception("cube has %d entries, what size is this?" % len_state)

    #cube.print_cube()
    tmp_state = cube.state[:]

    keepers = []

    for seq in symmetry_48:
        cube.state = tmp_state[:]

        for step in seq:
            cube.state = rotate_xxx(cube.state[:], step)

        if cube.state == tmp_state:
            log.info("================")
            log.info(' '.join(seq))
            log.info("================")
            cube.print_cube()
            log.info("\n\n\n\n\n")
            keepers.append(' '.join(seq))

    print("foo = (\n    \"" + '",\n    "'.join(keepers) + '"\n)')
Example #6
0
def getResults(state):
    if sys.version_info < (3, 4):
        raise SystemError("Must be using Python 3.4 or higher")

    logging.basicConfig(
        level=logging.INFO,
        format="%(asctime)s %(filename)22s %(levelname)8s: %(message)s")
    log = logging.getLogger(__name__)

    log.info("rubiks-cube-solver.py begin")

    start_time = dt.datetime.now()

    parser = argparse.ArgumentParser()
    parser.add_argument("--print-steps",
                        default=False,
                        action="store_true",
                        help="Display animated step-by-step solution")
    parser.add_argument("--debug",
                        default=False,
                        action="store_true",
                        help="set loglevel to DEBUG")
    parser.add_argument("--no-comments",
                        default=False,
                        action="store_true",
                        help="No comments in alg.cubing.net url")

    # CPU mode
    parser.add_argument(
        "--min-memory",
        default=False,
        action="store_true",
        help="Load smaller tables to use less memory...takes longer to run",
    )
    parser.add_argument("--fast",
                        default=True,
                        action="store_true",
                        help="Find a solution quickly")
    parser.add_argument("--normal",
                        default=False,
                        action="store_true",
                        help="Find a shorter solution but takes longer")
    parser.add_argument("--slow",
                        default=False,
                        action="store_true",
                        help="Find shortest solution we can, takes a while")

    action = parser.add_mutually_exclusive_group(required=False)
    parser.add_argument("--openwith",
                        default=None,
                        type=str,
                        help="Colors for sides U, L, etc")
    parser.add_argument("--colormap",
                        default=None,
                        type=str,
                        help="Colors for sides U, L, etc")
    parser.add_argument(
        "--order",
        type=str,
        default="URFDLB",
        help="order of sides in --state, default kociemba URFDLB")
    parser.add_argument("--solution333",
                        type=str,
                        default=None,
                        help="cube explorer optimal steps for solving 3x3x3")
    parser.add_argument(
        "--state",
        type=str,
        help="Cube state",
        # no longer used
        # parser.add_argument('--test', default=False, action='store_true')
        # 2x2x2
        #    default='DLRRFULLDUBFDURDBFBRBLFU')
        #    default='UUUURRRRFFFFDDDDLLLLBBBB')
        # 3x3x3
        #    default='RRBBUFBFBRLRRRFRDDURUBFBBRFLUDUDFLLFFLLLLDFBDDDUUBDLUU')
        #    default='UUUUUUUUURRRRRRRRRFFFFFFFFFDDDDDDDDDLLLLLLLLLBBBBBBBBB') # solved
        # 4x4x4
        # default='DRFDFRUFDURDDLLUFLDLLBLULFBUUFRBLBFLLUDDUFRBURBBRBDLLDURFFBBRUFUFDRFURBUDLDBDUFFBUDRRLDRBLFBRRLB') # xyzzy test cube
        # default='FLDFDLBDFBLFFRRBDRFRRURBRDUBBDLURUDRRBFFBDLUBLUULUFRRFBLDDUULBDBDFLDBLUBFRFUFBDDUBFLLRFLURDULLRU') # TPR cube
        # default="BRBLLLBRDLBBDDRRFUDFUDUDFUDDDRURBBBUUDRLFRDLLFBRFLRFLFFFBRULDRUBUBBLDBFRDLLUBUDDULFLRRFLFUBFUFUR",
    )
    #    default='UUUUUUUUUUUUUUUURRRRRRRRRRRRRRRRFFFFFFFFFFFFFFFFDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLBBBBBBBBBBBBBBBB') # solved

    # 5x5x5
    #    default='RFFFUDUDURBFULULFDBLRLDUFDBLUBBBDDURLRDRFRUDDBFUFLFURRLDFRRRUBFUUDUFLLBLBBULDDRRUFUUUBUDFFDRFLRBBLRFDLLUUBBRFRFRLLBFRLBRRFRBDLLDDFBLRDLFBBBLBLBDUUFDDD')
    #    https://www.speedsolving.com/forum/threads/arnauds-5x5x5-edge-pairing-method-examples.1447/
    #    default='LDFRDDUUUUFUUUBLUUUFLDFDRFDDFBBRRRULRRRBFRRRURFRFDUBDRUBFFFUBFFFUUFFFRLDLRFDLBDDLDDDRDDDDUDDDDUULDLFBFLFFULLLRFLLLRLLLLRRBLBBRBULULBBBRUBBBRBBBBULBRFB')
    #    default='UDLFDLDDLUFDUBRLBDLFLRBFRBLBBFUDURDULRRBRLFUURBUFLUBDUDRURRRBUFUFFFRUFFLDUURURFFULFFRLFDBRRFRDDBRFBBLBRDFBBBBUDDLLLDBUULUDULDLDDLBRRLRLUBBFFBDLFBDDLFR')
    #    default='UUUUUUUUUUUUUUUUUUUUUUUUURRRRRRRRRRRRRRRRRRRRRRRRRFFFFFFFFFFFFFFFFFFFFFFFFFDDDDDDDDDDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLLLLLLLLLLBBBBBBBBBBBBBBBBBBBBBBBBB') # solved
    #    default='DFFURRULDLDLURLBDDRRBFRURFBFBFRBDLBBFRBLRFBRBBFLULDLBLULLFRUBUFLDFFLDULDDLUURRDRFBRLULUDRBDUUUBBRFFDBDFURDBBDDRULBUDRDLLLBDRFDLRDLLFDBBUFBRURFFUFFUUFU') # step10 takes 2s
    #    default='URUBFUUFRDFFUUFLRDBLLBDDDLUULRDLDUBDLRBBLFLBRBFUUBBRBFFUDLFLLBFUFUDRLBFUBBURRLLRUFRDUFFDFRFUBRBBDRFRFLLFURLLFBRBLUDRDDRRDRRFDUDLFLDLUUDUDBRBBBRBDDLDFL') # step10 takes 9s
    #    default='RFUBLFUBRULLUDDRLRLLFFFLUBDBLBFFUFLFURBFFLDDLFFBBRLUUDRRDLLLRDFFLBBLFURUBULBRLBDRUURDRRDFURDBUUBBFBUDRUBURBRBDLFLBDFBDULLDBBDDDRRFURLDUDUBRDFRFFDFDRLU') # step10 takes 6s, centers take 37 steps :(

    # 6x6x6
    #    default='FBDDDFFUDRFBBLFLLURLDLLUFBLRFDUFLBLLFBFLRRBBFDRRDUBUFRBUBRDLUBFDRLBBRLRUFLBRBDUDFFFDBLUDBBLRDFUUDLBBBRRDRUDLBLDFRUDLLFFUUBFBUUFDLRUDUDBRRBBUFFDRRRDBULRRURULFDBRRULDDRUUULBLLFDFRRFDURFFLDUUBRUFDRFUBLDFULFBFDDUDLBLLRBL')
    #    default='UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUURRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB') # solved
    #    defult='xxxxxxxDRRLxxLDDBxxLUUDxxFRDUxxxxxxxxxxxxxxBBLBxxURFUxxDRBDxxDFDLxxxxxxxxxxxxxxULLRxxUFLLxxBLFRxxBBRDxxxxxxxxxxxxxxLFBRxxBUUFxxFDDFxxURUFxxxxxxxxxxxxxxRFDLxxURFUxxUBBFxxRULDxxxxxxxxxxxxxxBBLFxxFLLRxxDRBBxxFDRUxxxxxxx') # good step20 IDA test

    # 7x7x7
    #    default='DBDBDDFBDDLUBDLFRFRBRLLDUFFDUFRBRDFDRUFDFDRDBDBULDBDBDBUFBUFFFULLFLDURRBBRRBRLFUUUDUURBRDUUURFFFLRFLRLDLBUFRLDLDFLLFBDFUFRFFUUUFURDRFULBRFURRBUDDRBDLLRLDLLDLUURFRFBUBURBRUDBDDLRBULBULUBDBBUDRBLFFBLRBURRUFULBRLFDUFDDBULBRLBUFULUDDLLDFRDRDBBFBUBBFLFFRRUFFRLRRDRULLLFRLFULBLLBBBLDFDBRBFDULLULRFDBR')

    # 8x8x8
    #    default='DRRRURBDDBFBRBDDBRRDUFLLURFBFLFURLFLFRBRFUBDRFDFUUBLFF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LUUULLUBFFDULDFFBFFFUFFDUDRFBUFLDDLURFLRFLRFBUUBLRFDDRULUUUFFRDDBLRDULFURUDDBDLBBUUBFURFRFBRLBUULBLDDDBUBRFFULLUDFFDLDFUBLLBLDFFDDLBDUFUFFLBBBUBULDDFBRRFFLDUDDFRBLRRDDUDLBDBLURBUDBRRLUBBDRFBUFRDRDRBBDULBUFFDRBBDFBUULFFRLLDURRRDFFUUFULDULURLDLUUUDLBBUDLDRFBDBBDLUFBRRFDFLLDLFDBRBBRFUDDDBURDRBUBRUBDUBLDLLDLURLDFDBRUBDLDFRRRBRLULFRFLDRLBUBRUBLFBFDFFLFRFDFLBRULLRBLDRBBFURRRDUUULLULLDLBLBBDFBUUUBRRUFFBRUDBFRDFDLFLFFRFFFFRULDFFDFRUBBBRURBUFLBDFBBBBBRRRLFLFBDRRUFLURDDLRRBRLLFURRURBRFLLLFFURBFULFRFFBLDUUUUBDDUFFDRBRLDDFRBULDDDFFRURUFLDRFLDFBLRUFFUBBDFFDBLLDBDUBDLDLUDFBFLRULRRBDBLRBLDLUURRLLRULDBLBLLRRFDDRBBRBUBDDULDRFBFBBFLUFBLUULDDFDBRLLUBUBBDFBBLBBUBLULDRUDBLRULDUDLUFRRDLLUDDBUFLFLBUFUURFDRDLBURLLRRRULRBFFRRBRFBUBRBUUFRLRDRDLBBRFLLLDDBRFUFRBULFLFDRDDRRDBF')

    args = parser.parse_args()
    args.state = state
    if "G" in args.state:
        args.state = args.state.replace("G", "F")
        args.state = args.state.replace("Y", "D")
        args.state = args.state.replace("O", "L")
        args.state = args.state.replace("W", "U")

    if args.debug:
        log.setLevel(logging.DEBUG)

    try:
        size = int(sqrt((len(args.state) / 6)))

        if args.slow:
            cpu_mode = "slow"
        elif args.normal:
            cpu_mode = "normal"
        elif args.fast:
            cpu_mode = "fast"
        else:
            raise Exception("What CPU mode to use?")

        if size == 2:
            # rubiks cube libraries
            from rubikscubennnsolver.RubiksCube222 import RubiksCube222

            cube = RubiksCube222(args.state, args.order, args.colormap,
                                 args.debug)
        elif size == 3:
            # rubiks cube libraries
            from rubikscubennnsolver.RubiksCube333 import RubiksCube333

            cube = RubiksCube333(args.state, args.order, args.colormap,
                                 args.debug)
        elif size == 4:
            # rubiks cube libraries
            from rubikscubennnsolver.RubiksCube444 import RubiksCube444

            cube = RubiksCube444(args.state,
                                 args.order,
                                 args.colormap,
                                 avoid_pll=True,
                                 debug=args.debug)
        elif size == 5:
            # rubiks cube libraries
            from rubikscubennnsolver.RubiksCube555 import RubiksCube555

            cube = RubiksCube555(args.state, args.order, args.colormap,
                                 args.debug)
        elif size == 6:
            # rubiks cube libraries
            from rubikscubennnsolver.RubiksCube666 import RubiksCube666

            cube = RubiksCube666(args.state, args.order, args.colormap,
                                 args.debug)
        elif size == 7:
            # rubiks cube libraries
            from rubikscubennnsolver.RubiksCube777 import RubiksCube777

            cube = RubiksCube777(args.state, args.order, args.colormap,
                                 args.debug)
        elif size % 2 == 0:
            # rubiks cube libraries
            from rubikscubennnsolver.RubiksCubeNNNEven import RubiksCubeNNNEven

            cube = RubiksCubeNNNEven(args.state, args.order, args.colormap,
                                     args.debug)
        else:
            # rubiks cube libraries
            from rubikscubennnsolver.RubiksCubeNNNOdd import RubiksCubeNNNOdd

            cube = RubiksCubeNNNOdd(args.state, args.order, args.colormap,
                                    args.debug)

        if args.openwith:
            cube.print_cube()
            for step in args.openwith.split():
                cube.rotate(step)

        cube.cpu_mode = cpu_mode
        log.info("CPU mode %s" % cube.cpu_mode)
        cube.sanity_check()
        cube.print_cube()
        cube.www_header()
        cube.www_write_cube("Initial Cube")

        try:
            if args.solution333:
                solution333 = reverse_steps(args.solution333.split())
            else:
                solution333 = []
            cube.solve(solution333)
        except NotSolving:
            if cube.heuristic_stats:
                log.info("%s: heuristic_stats raw\n%s\n\n" %
                         (cube, pformat(cube.heuristic_stats)))

                for (key, value) in cube.heuristic_stats.items():
                    cube.heuristic_stats[key] = int(median(value))

                log.info("%s: heuristic_stats median\n%s\n\n" %
                         (cube, pformat(cube.heuristic_stats)))
                sys.exit(0)
            else:
                raise

        end_time = dt.datetime.now()
        log.info("Final Cube")
        cube.print_cube()
        res = cube.print_solution(not args.no_comments)

        log.info(
            "*********************************************************************************"
        )
        log.info(
            "See /tmp/rubiks-cube-NxNxN-solver/index.html for more detailed solve instructions"
        )
        log.info(
            "*********************************************************************************\n"
        )

        # Now put the cube back in its initial state and verify the solution solves it
        solution = cube.solution
        cube.re_init()
        len_steps = len(solution)

        for (i, step) in enumerate(solution):

            if args.print_steps:
                print(("Phase     : %s" % cube.phase()))
                print(("Move %d/%d: %s" % (i + 1, len_steps, step)))

            cube.rotate(step)

            www_desc = "Phase: %s<br>\nCube After Move %d/%d: %s<br>\n" % (
                cube.phase(), i + 1, len_steps, step)
            cube.www_write_cube(www_desc)

            if args.print_steps:
                cube.print_cube()
                print("\n\n\n\n")

        cube.www_footer()

        if args.print_steps:
            cube.print_cube()

        if args.min_memory:
            print("\n\n****************************************")
            print("--min-memory has been replaced by --fast")
            print("****************************************\n\n")

        log.info("rubiks-cube-solver.py end")
        log.info("Memory : {:,} bytes".format(
            resource.getrusage(resource.RUSAGE_SELF).ru_maxrss))
        log.info("Time   : %s" % (end_time - start_time))
        log.info("")

        success = True

        if not cube.solved():
            kociemba_string = cube.get_kociemba_string(False)
            # edge_swap_count = cube.get_edge_swap_count(edges_paired=True, orbit=None, debug=True)
            # corner_swap_count = cube.get_corner_swap_count(debug=True)

            # raise SolveError("cube should be solved but is not, edge parity %d, corner parity %d, kociemba %s" %
            #    (edge_swap_count, corner_swap_count, kociemba_string))
            raise SolveError("cube should be solved but is not")

    except (ImplementThis, SolveError, StuckInALoop, NoSteps, KeyError,
            NoPruneTableState, InvalidCubeReduction):
        cube.enable_print_cube = True
        cube.print_cube_layout()
        cube.print_cube()
        res = cube.print_solution(False)
        success = True
        print((cube.get_kociemba_string(True)))
        log.info("rubiks-cube-solver.py end")
        raise

    return res, success