Пример #1
0
 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())
Пример #2
0
def roux():
    c = rubik.Cube()
    c.apply_alg(movealg())
    if blockdefinitions.check24positions(blockdefinitions.rouxsolved, c):
        colorgreen()
    else:
        colorred()
Пример #3
0
def cross():
    c = rubik.Cube()
    c.apply_alg(movealg())

    if blockdefinitions.check6positions(blockdefinitions.cross_solved, c):
        colorgreen()
    else:
        colorred()
Пример #4
0
def f2lminusone():
    c = rubik.Cube()
    c.apply_alg(movealg())

    if blockdefinitions.check24positions(blockdefinitions.f2lminus1solved, c):
        colorgreen()
    else:
        colorred()
Пример #5
0
def twobytwobythree():
    c = rubik.Cube()
    c.apply_alg(movealg())

    if blockdefinitions.check12positions(blockdefinitions.twobytwobythreesolved, c):
        colorgreen()
    else:
        colorred()
Пример #6
0
def solved():
    c = rubik.Cube()
    c.apply_alg(movealg())

    if c.solved():
        colorgreen()
    else:
        colorred()
Пример #7
0
def diamond():
    c = rubik.Cube()
    c.apply_alg(movealg())

    if blockdefinitions.check12positions(blockdefinitions.diamondsolved, c):
        colorgreen()
    else:
        colorred()
Пример #8
0
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)
Пример #9
0
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)
Пример #10
0
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).")
Пример #11
0
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()
Пример #12
0
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()
Пример #13
0
def test_render():
    cube = rubik.Cube()
    renderer = rubik.Renderer(cube)
    renderer.render()