def get_fake_444(self): if self.fake_444 is None: self.fake_444 = RubiksCube444(solved_444, 'URFDLB') self.fake_444.lt_init() self.fake_444.enable_print_cube = False else: self.fake_444.re_init() return self.fake_444
def pair_inside_edges_via_444(self): fake_444 = RubiksCube444(solved_4x4x4, 'URFDLB') fake_444.lt_init() # Fill in the corners so that we can avoid PLL parity when pairing the edges start_444 = 0 start_nnn = 0 for x in range(6): fake_444.state[start_444+1] = self.state[start_nnn+1] fake_444.state[start_444+4] = self.state[start_nnn + self.size] fake_444.state[start_444+13] = self.state[start_nnn + (self.size * self.size) - self.size + 1] fake_444.state[start_444+16] = self.state[start_nnn + (self.size * self.size)] start_nnn += self.size * self.size start_444 += 16 # Fill in the edges start_444 = 0 start_nnn = 0 half_size = int(self.size/2) for x in range(6): fake_444.state[start_444+2] = self.state[start_nnn + half_size] fake_444.state[start_444+3] = self.state[start_nnn + half_size + 1] fake_444.state[start_444+5] = self.state[start_nnn + (self.size * (half_size-1)) + 1] fake_444.state[start_444+8] = self.state[start_nnn + (self.size * half_size)] fake_444.state[start_444+9] = self.state[start_nnn + (self.size * half_size) + 1] fake_444.state[start_444+12] = self.state[start_nnn + (self.size * (half_size+1))] fake_444.state[start_444+14] = self.state[start_nnn + (self.size * self.size) - half_size] fake_444.state[start_444+15] = self.state[start_nnn + (self.size * self.size) - half_size + 1] start_nnn += self.size * self.size start_444 += 16 fake_444.sanity_check() fake_444.group_edges() half_size_str = str(half_size) for step in fake_444.solution: if step == 'EDGES_GROUPED': continue # Rotate the entire cube if step.startswith('4'): step = str(self.size) + step[1:] elif step in ("Uw", "Uw'", "Uw2", "Lw", "Lw'", "Lw2", "Fw", "Fw'", "Fw2", "Rw", "Rw'", "Rw2", "Bw", "Bw'", "Bw2", "Dw", "Dw'", "Dw2"): step = half_size_str + step self.rotate(step) log.info("Inside edges are paired, %d steps in" % self.get_solution_len_minus_rotates(self.solution))
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)))
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() # cube.nuke_edges() # cube.nuke_centers()
def build_state_table(): cube = RubiksCube444( 'DRFDFRUFDURDDLLUFLDLLBLULFBUUFRBLBFLLUDDUFRBURBBRBDLLDURFFBBRUFUFDRFURBUDLDBDUFFBUDRRLDRBLFBRRLB', 'URFDLB') cube.nuke_corners() cube.nuke_edges() original_state = cube.state[:] log.info("cache start") for side in (cube.sideU, cube.sideL, cube.sideF, cube.sideR, cube.sideB, cube.sideD): for pos in side.center_pos: if cube.state[pos] in ('U', 'D'): cube.state[pos] = 'U' elif cube.state[pos] in ('L', 'R'): cube.state[pos] = 'L' elif cube.state[pos] in ('F', 'B'): cube.state[pos] = 'F' cube.lt_UD_centers_stage = LookupTable444UDCentersStage(cube) cube.lt_LR_centers_stage = LookupTable444LRCentersStage(cube) cube.lt_FB_centers_stage = LookupTable444FBCentersStage(cube) lt_ULFRBD_centers_stage = LookupTableIDA444ULFRBDCentersStage(cube) workq = deque() explored = set() UD_explored = {} LR_explored = {} FB_explored = {} count = 0 for step in moves_444: workq.append(([ step, ], cube.state[:])) while workq: (steps, prev_state) = workq.popleft() cube.state = rotate_444(prev_state, steps[-1]) state = lt_ULFRBD_centers_stage.state() UD_state = cube.lt_UD_centers_stage.state() LR_state = cube.lt_LR_centers_stage.state() FB_state = cube.lt_FB_centers_stage.state() count += 1 if count % 100000 == 0: UD_count = len(UD_explored) LR_count = len(LR_explored) FB_count = len(FB_explored) log.info("%d UD states, %d LR state, %d FB states, %d on workq" % (UD_count, LR_count, FB_count, len(workq))) if UD_count == 735471 and LR_count == 735471 and FB_count == 735471: break if state in explored: continue else: explored.add(state) keep_going = False if UD_state not in UD_explored: UD_explored[UD_state] = ' '.join(reverse_steps(steps)) keep_going = True if LR_state not in LR_explored: LR_explored[LR_state] = ' '.join(reverse_steps(steps)) keep_going = True if FB_state not in FB_explored: FB_explored[FB_state] = ' '.join(reverse_steps(steps)) keep_going = True if not keep_going: continue # Only build the table 4-deep for now if len(steps) == 4: continue prev_step = steps[-1] for step in moves_444: # U2 followed by U2 is a no-op if step == prev_step and step.endswith("2"): continue # U' followed by U is a no-op if prev_step.endswith("'") and not step.endswith( "'") and step == prev_step[0:-1]: continue # U followed by U' is a no-op if not prev_step.endswith("'") and step.endswith( "'") and step[0:-1] == prev_step: continue workq.append((steps + [ step, ], cube.state[:])) log.info("cache end") log.info("write start") with open('UD_state.txt', 'w') as fh: for key in sorted(UD_explored.keys()): value = UD_explored[key] fh.write("%s:%s\n" % (key, value)) with open('LR_state.txt', 'w') as fh: for key in sorted(LR_explored.keys()): value = LR_explored[key] fh.write("%s:%s\n" % (key, value)) with open('FB_state.txt', 'w') as fh: for key in sorted(FB_explored.keys()): value = FB_explored[key] fh.write("%s:%s\n" % (key, value)) log.info("write end")
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: from rubikscubennnsolver.RubiksCube555 import RubiksCube555 cube = RubiksCube555(args.state, args.order, args.colormap, args.debug) elif size == 6:
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) elif size == '9x9x9': cube = RubiksCubeNNNOdd(solved_999, order)
#!/usr/bin/env python3 from pprint import pformat, pprint from rubikscubennnsolver.RubiksCube444 import RubiksCube444, solved_444 import sys # This is only called by ida_search.c, it uses ULFRBD order cube = RubiksCube444(sys.argv[1], "ULFRBD") if cube.edge_solution_leads_to_pll_parity(): print(True) else: print(False)
#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LURDDDRUFDLBRDRLFBDBLDRFBFFBURULUDRRBRDFRFFLULLUBRDRRRDUFRBLFULUBBUFFBRBBFRLFDRRDBLDFRDRDDRLRUULBDURDURFDDLFDUUDBFLBDUFBULFRRDUDUBFBUDBBFUDFUUDLUDDRFDDDFRRRBUDRBFBBULLUFBLRLFLLBRRRRUBDRFLFDFDBLRFLURULULFFBUUUUFDBBLDLUBBRUBBBRBFLULLBLUUULLUBFFDULDFFBFFFUFFDUDRFBUFLDDLURFLRFLRFBUUBLRFDDRULUUUFFRDDBLRDULFURUDDBDLBBUUBFURFRFBRLBUULBLDDDBUBRFFULLUDFFDLDFUBLLBLDFFDDLBDUFUFFLBBBUBULDDFBRRFFLDUDDFRBLRRDDUDLBDBLURBUDBRRLUBBDRFBUFRDRDRBBDULBUFFDRBBDFBUULFFRLLDURRRDFFUUFULDULURLDLUUUDLBBUDLDRFBDBBDLUFBRRFDFLLDLFDBRBBRFUDDDBURDRBUBRUBDUBLDLLDLURLDFDBRUBDLDFRRRBRLULFRFLDRLBUBRUBLFBFDFFLFRFDFLBRULLRBLDRBBFURRRDUUULLULLDLBLBBDFBUUUBRRUFFBRUDBFRDFDLFLFFRFFFFRULDFFDFRUBBBRURBUFLBDFBBBBBRRRLFLFBDRRUFLURDDLRRBRLLFURRURBRFLLLFFURBFULFRFFBLDUUUUBDDUFFDRBRLDDFRBULDDDFFRURUFLDRFLDFBLRUFFUBBDFFDBLLDBDUBDLDLUDFBFLRULRRBDBLRBLDLUURRLLRULDBLBLLRRFDDRBBRBUBDDULDRFBFBBFLUFBLUULDDFDBRLLUBUBBDFBBLBBUBLULDRUDBLRULDUDLUFRRDLLUDDBUFLFLBUFUURFDRDLBURLLRRRULRBFFRRBRFBUBRBUUFRLRDRDLBBRFLLLDDBRFUFRBULFLFDRDDRRDBF') args = parser.parse_args() if args.debug: log.setLevel(logging.DEBUG) if args.test: cube = RubiksCube444(solved_4x4x4, args.colormap, avoid_pll=True, use_tsai=args.tsai) cube.test() sys.exit(0) try: size = int(sqrt((len(args.state) / 6))) if size == 2: cube = RubiksCube222(args.state, args.order, args.colormap, args.debug) elif size == 3: cube = RubiksCube333(args.state, args.order, args.colormap, args.debug) elif size == 4: cube = RubiksCube444(args.state, args.order, args.colormap,
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)')
def build_symmetry_48(): """ http://kociemba.org/math/symmetric.htm I ran this once to build symmetry_48 """ half_edge_rotations = ( "x x y", "x x y'", "x y y", "z y y", "x' y y", "z' y y", ) half_rotations = ( "x x", "y y", "z z", ) reflections_xyz = ( "reflect-x", "reflect-y", "reflect-z", ) quarter_rotations = ( "x", "x'", "y", "y'", "z", "z'", ) third_edge_rotations = ( "x y", "x y'", "z y'", "x' y'", ) rotations = [""] rotations.extend(quarter_rotations) rotations.extend(half_rotations) ''' rotations.extend(quarter_rotations) rotations.extend(half_rotations) rotations.extend(half_edge_rotations) rotations.extend(third_edge_rotations) ''' for a in quarter_rotations: for b in quarter_rotations + half_rotations: rotation = "%s %s" % (a, b) if rotation in ("x x x", "y y y", "z z z"): continue if ("x x'" in rotation or "x' x" in rotation or "y y'" in rotation or "y' y" in rotation or "z z'" in rotation or "z' z" in rotation): continue if rotation not in rotations: rotations.append(rotation) #log.info("rotations:\n%s" % pformat(rotations)) #log.info("Found %d rotations" % len(rotations)) reflections = [""] reflections.extend(reflections_xyz) cube = RubiksCube444( 'FLDFDLBDFBLFFRRBDRFRRURBRDUBBDLURUDRRBFFBDLUBLUULUFRRFBLDDUULBDBDFLDBLUBFRFUFBDDUBFLLRFLURDULLRU', 'URFDLB') #cube.print_cube() found_cubes = [] tmp_state = cube.state[:] attempts = 0 symmetry_48 = [] for reflect in reflections: for rotate in rotations: cube.state = tmp_state[:] if reflect: cube.state = rotate_444(cube.state[:], reflect) if rotate: for step in rotate.split(): cube.state = rotate_444(cube.state[:], step) cube_state_string = ''.join(cube.state) if cube_state_string not in found_cubes: tmp = "%s %s" % (reflect, rotate) symmetry_48.append(tuple(tmp.strip().split())) #print("%d: %s %s" % (len(found_cubes) + 1, reflect, rotate)) found_cubes.append(cube_state_string) attempts += 1 symmetry_48 = tuple(symmetry_48) #print("attempts: %d" % attempts) log.info("symmetry_48 = \n%s\n" % pformat(symmetry_48)) print("symmetry_48 = (") for seq in symmetry_48: print(" \"%s\"," % ' '.join(seq)) print(")")
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') #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DRFLFDFDBLRFLURULULFFBUUUUFDBBLDLUBBRUBBBRBFLULLBLUUULLUBFFDULDFFBFFFUFFDUDRFBUFLDDLURFLRFLRFBUUBLRFDDRULUUUFFRDDBLRDULFURUDDBDLBBUUBFURFRFBRLBUULBLDDDBUBRFFULLUDFFDLDFUBLLBLDFFDDLBDUFUFFLBBBUBULDDFBRRFFLDUDDFRBLRRDDUDLBDBLURBUDBRRLUBBDRFBUFRDRDRBBDULBUFFDRBBDFBUULFFRLLDURRRDFFUUFULDULURLDLUUUDLBBUDLDRFBDBBDLUFBRRFDFLLDLFDBRBBRFUDDDBURDRBUBRUBDUBLDLLDLURLDFDBRUBDLDFRRRBRLULFRFLDRLBUBRUBLFBFDFFLFRFDFLBRULLRBLDRBBFURRRDUUULLULLDLBLBBDFBUUUBRRUFFBRUDBFRDFDLFLFFRFFFFRULDFFDFRUBBBRURBUFLBDFBBBBBRRRLFLFBDRRUFLURDDLRRBRLLFURRURBRFLLLFFURBFULFRFFBLDUUUUBDDUFFDRBRLDDFRBULDDDFFRURUFLDRFLDFBLRUFFUBBDFFDBLLDBDUBDLDLUDFBFLRULRRBDBLRBLDLUURRLLRULDBLBLLRRFDDRBBRBUBDDULDRFBFBBFLUFBLUULDDFDBRLLUBUBBDFBBLBBUBLULDRUDBLRULDUDLUFRRDLLUDDBUFLFLBUFUURFDRDLBURLLRRRULRBFFRRBRFBUBRBUUFRLRDRDLBBRFLLLDDBRFUFRBULFLFDRDDRRDBF') 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
def pair_inside_edges_via_444(self): fake_444 = RubiksCube444(solved_4x4x4, 'URFDLB') fake_444.lt_init() # The corners don't matter but it does make troubleshooting easier if they match fake_444.state[1] = self.state[1] fake_444.state[4] = self.state[6] fake_444.state[13] = self.state[31] fake_444.state[16] = self.state[36] fake_444.state[17] = self.state[37] fake_444.state[20] = self.state[42] fake_444.state[29] = self.state[67] fake_444.state[32] = self.state[72] fake_444.state[33] = self.state[73] fake_444.state[36] = self.state[78] fake_444.state[45] = self.state[103] fake_444.state[48] = self.state[108] fake_444.state[49] = self.state[109] fake_444.state[52] = self.state[114] fake_444.state[61] = self.state[139] fake_444.state[64] = self.state[144] fake_444.state[65] = self.state[145] fake_444.state[68] = self.state[150] fake_444.state[77] = self.state[175] fake_444.state[80] = self.state[180] fake_444.state[81] = self.state[181] fake_444.state[84] = self.state[186] fake_444.state[93] = self.state[211] fake_444.state[96] = self.state[216] # Upper fake_444.state[2] = self.state[3] fake_444.state[3] = self.state[4] fake_444.state[5] = self.state[13] fake_444.state[8] = self.state[18] fake_444.state[9] = self.state[19] fake_444.state[12] = self.state[24] fake_444.state[14] = self.state[33] fake_444.state[15] = self.state[34] # Left fake_444.state[18] = self.state[39] fake_444.state[19] = self.state[40] fake_444.state[21] = self.state[49] fake_444.state[24] = self.state[54] fake_444.state[25] = self.state[55] fake_444.state[28] = self.state[60] fake_444.state[30] = self.state[69] fake_444.state[31] = self.state[70] # Front fake_444.state[34] = self.state[75] fake_444.state[35] = self.state[76] fake_444.state[37] = self.state[85] fake_444.state[40] = self.state[90] fake_444.state[41] = self.state[91] fake_444.state[44] = self.state[96] fake_444.state[46] = self.state[105] fake_444.state[47] = self.state[106] # Right fake_444.state[50] = self.state[111] fake_444.state[51] = self.state[112] fake_444.state[53] = self.state[121] fake_444.state[56] = self.state[126] fake_444.state[57] = self.state[127] fake_444.state[60] = self.state[132] fake_444.state[62] = self.state[141] fake_444.state[63] = self.state[142] # Back fake_444.state[66] = self.state[147] fake_444.state[67] = self.state[148] fake_444.state[69] = self.state[157] fake_444.state[72] = self.state[162] fake_444.state[73] = self.state[163] fake_444.state[76] = self.state[168] fake_444.state[78] = self.state[177] fake_444.state[79] = self.state[178] # Down fake_444.state[82] = self.state[183] fake_444.state[83] = self.state[184] fake_444.state[85] = self.state[193] fake_444.state[88] = self.state[198] fake_444.state[89] = self.state[199] fake_444.state[92] = self.state[204] fake_444.state[94] = self.state[213] fake_444.state[95] = self.state[214] fake_444.group_edges() for step in fake_444.solution: if step == 'EDGES_GROUPED': continue if step.startswith('4'): step = '6' + step[1:] elif step.startswith('3'): raise ImplementThis('4x4x4 steps starts with 3') elif step in ("Uw", "Uw'", "Uw2", "Lw", "Lw'", "Lw2", "Fw", "Fw'", "Fw2", "Rw", "Rw'", "Rw2", "Bw", "Bw'", "Bw2", "Dw", "Dw'", "Dw2"): step = '3' + step # log.warning("fake_444 step %s" % step) self.rotate(step) log.info("Inside edges are paired, %d steps in" % self.get_solution_len_minus_rotates(self.solution))
def pair_inside_edges_via_444(self): fake_444 = RubiksCube444(solved_4x4x4, 'URFDLB') fake_444.lt_init() # The corners don't matter but it does make troubleshooting easier if they match start_index = 0 fake_444.state[1] = self.state[start_index+1] fake_444.state[4] = self.state[start_index + self.size] fake_444.state[13] = self.state[start_index + (self.size * self.size) - self.size + 1] fake_444.state[16] = self.state[start_index + (self.size * self.size)] start_index += self.size * self.size fake_444.state[17] = self.state[start_index+1] fake_444.state[20] = self.state[start_index + self.size] fake_444.state[29] = self.state[start_index + (self.size * self.size) - self.size + 1] fake_444.state[32] = self.state[start_index + (self.size * self.size)] start_index += self.size * self.size fake_444.state[33] = self.state[start_index+1] fake_444.state[36] = self.state[start_index + self.size] fake_444.state[45] = self.state[start_index + (self.size * self.size) - self.size + 1] fake_444.state[48] = self.state[start_index + (self.size * self.size)] start_index += self.size * self.size fake_444.state[49] = self.state[start_index+1] fake_444.state[52] = self.state[start_index + self.size] fake_444.state[61] = self.state[start_index + (self.size * self.size) - self.size + 1] fake_444.state[64] = self.state[start_index + (self.size * self.size)] start_index += self.size * self.size fake_444.state[65] = self.state[start_index+1] fake_444.state[68] = self.state[start_index + self.size] fake_444.state[77] = self.state[start_index + (self.size * self.size) - self.size + 1] fake_444.state[80] = self.state[start_index + (self.size * self.size)] start_index += self.size * self.size fake_444.state[81] = self.state[start_index+1] fake_444.state[84] = self.state[start_index + self.size] fake_444.state[93] = self.state[start_index + (self.size * self.size) - self.size + 1] fake_444.state[96] = self.state[start_index + (self.size * self.size)] start_index += self.size * self.size # Upper half_size = int(self.size/2) start_index = 0 fake_444.state[2] = self.state[start_index + half_size] fake_444.state[3] = self.state[start_index + half_size + 1] fake_444.state[5] = self.state[start_index + (self.size * (half_size-1)) + 1] fake_444.state[8] = self.state[start_index + (self.size * half_size)] fake_444.state[9] = self.state[start_index + (self.size * half_size) + 1] fake_444.state[12] = self.state[start_index + (self.size * (half_size+1))] fake_444.state[14] = self.state[start_index + (self.size * self.size) - half_size] fake_444.state[15] = self.state[start_index + (self.size * self.size) - half_size + 1] start_index += self.size * self.size # Left fake_444.state[18] = self.state[start_index + half_size] fake_444.state[19] = self.state[start_index + half_size + 1] fake_444.state[21] = self.state[start_index + (self.size * (half_size-1)) + 1] fake_444.state[24] = self.state[start_index + (self.size * half_size)] fake_444.state[25] = self.state[start_index + (self.size * half_size) + 1] fake_444.state[28] = self.state[start_index + (self.size * (half_size+1))] fake_444.state[30] = self.state[start_index + (self.size * self.size) - half_size] fake_444.state[31] = self.state[start_index + (self.size * self.size) - half_size + 1] start_index += self.size * self.size # Front fake_444.state[34] = self.state[start_index + half_size] fake_444.state[35] = self.state[start_index + half_size + 1] fake_444.state[37] = self.state[start_index + (self.size * (half_size-1)) + 1] fake_444.state[40] = self.state[start_index + (self.size * half_size)] fake_444.state[41] = self.state[start_index + (self.size * half_size) + 1] fake_444.state[44] = self.state[start_index + (self.size * (half_size+1))] fake_444.state[46] = self.state[start_index + (self.size * self.size) - half_size] fake_444.state[47] = self.state[start_index + (self.size * self.size) - half_size + 1] start_index += self.size * self.size # Right fake_444.state[50] = self.state[start_index + half_size] fake_444.state[51] = self.state[start_index + half_size + 1] fake_444.state[53] = self.state[start_index + (self.size * (half_size-1)) + 1] fake_444.state[56] = self.state[start_index + (self.size * half_size)] fake_444.state[57] = self.state[start_index + (self.size * half_size) + 1] fake_444.state[60] = self.state[start_index + (self.size * (half_size+1))] fake_444.state[62] = self.state[start_index + (self.size * self.size) - half_size] fake_444.state[63] = self.state[start_index + (self.size * self.size) - half_size + 1] start_index += self.size * self.size # Back fake_444.state[66] = self.state[start_index + half_size] fake_444.state[67] = self.state[start_index + half_size + 1] fake_444.state[69] = self.state[start_index + (self.size * (half_size-1)) + 1] fake_444.state[72] = self.state[start_index + (self.size * half_size)] fake_444.state[73] = self.state[start_index + (self.size * half_size) + 1] fake_444.state[76] = self.state[start_index + (self.size * (half_size+1))] fake_444.state[78] = self.state[start_index + (self.size * self.size) - half_size] fake_444.state[79] = self.state[start_index + (self.size * self.size) - half_size + 1] start_index += self.size * self.size # Down fake_444.state[82] = self.state[start_index + half_size] fake_444.state[83] = self.state[start_index + half_size + 1] fake_444.state[85] = self.state[start_index + (self.size * (half_size-1)) + 1] fake_444.state[88] = self.state[start_index + (self.size * half_size)] fake_444.state[89] = self.state[start_index + (self.size * half_size) + 1] fake_444.state[92] = self.state[start_index + (self.size * (half_size+1))] fake_444.state[94] = self.state[start_index + (self.size * self.size) - half_size] fake_444.state[95] = self.state[start_index + (self.size * self.size) - half_size + 1] start_index += self.size * self.size fake_444.group_edges() #fake_444.print_cube() #fake_444.print_solution() half_size_str = str(half_size) for step in fake_444.solution: if step == 'EDGES_GROUPED': continue # Rotate the entire cube if step.startswith('4'): step = str(self.size) + step[1:] elif step in ("Uw", "Uw'", "Uw2", "Lw", "Lw'", "Lw2", "Fw", "Fw'", "Fw2", "Rw", "Rw'", "Rw2", "Bw", "Bw'", "Bw2", "Dw", "Dw'", "Dw2"): step = half_size_str + step #log.warning("fake_444 step %s" % step) self.rotate(step)
(((bitfield >> 48) & 0xF) << 0) # c03 -> c33 ) logging.basicConfig(level=logging.INFO, format='%(asctime)s %(filename)20s %(levelname)8s: %(message)s') log = logging.getLogger(__name__) # Color the errors and warnings in red logging.addLevelName(logging.ERROR, "\033[91m %s\033[0m" % logging.getLevelName(logging.ERROR)) logging.addLevelName(logging.WARNING, "\033[91m %s\033[0m" % logging.getLevelName(logging.WARNING)) COUNT = 1000000 #COUNT = 10000 cube = RubiksCube444(solved_444, 'URFDLB') state = cube.state[:] # For 1,000,000 this took 0:00:05.157367 at 193,897 nodes-per-sec start_time0 = dt.datetime.now() for x in range(COUNT): state = rotate_444(state[:], "U") end_time0= dt.datetime.now() delta = end_time0 - start_time0 print ("{:,} rotates using python rotate_444() took {} at {:,} nodes-per-sec".format(COUNT, pretty_time(delta), int(COUNT/delta.total_seconds()))) # For 1,000,000 this took 0:00:18.350457 at 54,494 nodes-per-sec ''' cube.re_init()
from rubikscubennnsolver.RubiksCube666 import RubiksCube666, solved_666, moves_666, rotate_666 from rubikscubennnsolver.RubiksCube777 import RubiksCube777, solved_777, moves_777, rotate_777 from buildercore import parse_ascii_444 import logging import sys if __name__ == '__main__': logging.basicConfig( level=logging.INFO, format='%(asctime)s %(filename)24s %(levelname)8s: %(message)s') log = logging.getLogger(__name__) state = parse_ascii_444(""" . . . . . U U . . U U . . . . . . . . . . . . . . . . . . . . . . L L . . F F . . R R . . F F . . L L . . F F . . R R . . F F . . . . . . . . . . . . . . . . . . . . . . U U . . U U . . . . . """) cube = RubiksCube444(state, 'ULFRBD')