def testPath(self): choices = ["left", "right", "top", "down", "front", "back"] m = [random.choice(choices) for _ in xrange(1000)] n = ["anti_" + i for i in reversed(m)] cube = rubik.Cube() for i in m + n: getattr(cube, i)() self.assertEqual(cube, rubik.Cube())
def roux(): c = rubik.Cube() c.apply_alg(movealg()) if blockdefinitions.check24positions(blockdefinitions.rouxsolved, c): colorgreen() else: colorred()
def cross(): c = rubik.Cube() c.apply_alg(movealg()) if blockdefinitions.check6positions(blockdefinitions.cross_solved, c): colorgreen() else: colorred()
def f2lminusone(): c = rubik.Cube() c.apply_alg(movealg()) if blockdefinitions.check24positions(blockdefinitions.f2lminus1solved, c): colorgreen() else: colorred()
def twobytwobythree(): c = rubik.Cube() c.apply_alg(movealg()) if blockdefinitions.check12positions(blockdefinitions.twobytwobythreesolved, c): colorgreen() else: colorred()
def solved(): c = rubik.Cube() c.apply_alg(movealg()) if c.solved(): colorgreen() else: colorred()
def diamond(): c = rubik.Cube() c.apply_alg(movealg()) if blockdefinitions.check12positions(blockdefinitions.diamondsolved, c): colorgreen() else: colorred()
def test_moves(): id = rubik.Cube() for face in 'LRUDFB': rotation = getattr(rubik.Rotation, face) cube = id for i in range(4): cube = cube.apply(rotation) if i == 0: assert cube == rotation, "Cube() is the identity" assert cube == id, "{}x4 is the identity".format(face)
def test_invert(): id = rubik.Cube() assert id == id.invert() for face in 'LRUDFB': rotation = getattr(rubik.Rotation, face) assert rotation.apply( rotation.invert()) == id, "{}' {} is the identity".format( face, face) assert rotation.invert().apply( rotation) == id, "{} {}' is the identity".format(face, face)
def transcribe(e): c = rubik.Cube() try: solvestart = textArea.search("Solution: ", END, stopindex=1.0, backwards=TRUE) c.apply_alg(rubik.Algorithm(movestring(textArea.get(1.0, 2.0))[1] + movestring( textArea.get(solvestart, END))[1])) output_area.delete(1.0, END) movecount = len(textArea.get(solvestart, END).split()) - 1 if not c.solved(): messagebox.showwarning("Solution Does Not Work", "Warning: the solution written after \"Solution:\" does " "not work for the provided scramble.\n\nThe skeleton has" " been formatted anyway, but it may not work.") split_text = textArea.get(1.0, END).split("\n") formatted_text = "" linecount = 0.0 for line in split_text: insertion = False if ":" in line: insertion = True linecount = linecount + 1 split_line = line.split() for word in split_line: if word is "//": formatted_text = formatted_text + "\n" elif word in abbreviations: formatted_text = formatted_text + abbreviations.get(word) + " " else: formatted_text = formatted_text + word + " " # Adds the running movecount, but also detects any cancellations in the moves, even with previous lines if "//" in split_line and not insertion: formatted_text = formatted_text + "(" + str(lengthaftercancel(movestring(textArea.get(linecount, ( linecount + 1)))[0]) + lengthaftercancel(movestring(textArea.get(linecount, linecount + 1))[( 1)])) + "/" + str(lengthaftercancel(movestring(textArea.get(2.0, linecount + 1))[0]) + ( lengthaftercancel(movestring(textArea.get(2.0, linecount + 1))[1]))) + ")" formatted_text = formatted_text + "\n" output_area.insert(1.0, formatted_text + str(movecount) + " Moves.") except TclError: messagebox.showerror("Solution: deleted or modified", "Error: The word \"Solution: \" has been deleted or " "modified. Please type \"Solution: \" at the start " "of your solution (with a space before the first move of" " your solution).")
def partialdomino(): c = rubik.Cube() c.apply_alg(movealg()) is_solved = False if blockdefinitions.pdrsolved(c): is_solved = True c.apply_alg(x) if blockdefinitions.pdrsolved(c): is_solved = True c.apply_alg(z) if blockdefinitions.pdrsolved(c): is_solved = True if is_solved: colorgreen() else: colorred()
def eo(): c = rubik.Cube() c.apply_alg(movealg()) is_solved = False if blockdefinitions.eosolved(c): is_solved = True c.apply_alg(x) if blockdefinitions.eosolved(c): is_solved = True c.apply_alg(y) if blockdefinitions.eosolved(c): is_solved = True if is_solved: colorgreen() else: colorred()
def test_render(): cube = rubik.Cube() renderer = rubik.Renderer(cube) renderer.render()