Пример #1
0
def rouxsolved(c):
    if not square_solved(c):
        return False
    c.apply_alg(y)
    if square_solved(c):
        c.apply_alg(rubik.Algorithm("y'"))
        return True
    else:
        c.apply_alg(rubik.Algorithm("y'"))
        return False
Пример #2
0
def diamondsolved(c):
    if not twobytwosolved(c):
        return False
    c.apply_alg(rubik.Algorithm("y2"))
    if twobytwosolved(c):
        c.apply_alg(rubik.Algorithm("y2"))
        return True
    else:
        c.apply_alg(rubik.Algorithm("y2"))
        return False
Пример #3
0
def pdrsolved(c):
    if not eosolved(c):
        return False
    c.apply_alg(y)

    if not eosolved(c):
        c.apply_alg(rubik.Algorithm("y'"))
        return False
    c.apply_alg(rubik.Algorithm("y'"))

    return True
Пример #4
0
def f2lsolved(c):
    if not twobytwobythreesolved(c):
        return False
    c.apply_alg(rubik.Algorithm("y2"))
    if twobytwobythreesolved(c):
        c.apply_alg(rubik.Algorithm("y2"))
        return True
    else:
        c.apply_alg(rubik.Algorithm("y2"))
        print("false")
        return False
Пример #5
0
def f2lminus1solved(c):
    if not twobytwosolved(c):
        return False
    c.apply_alg(y)
    if not twobytwosolved(c):
        c.apply_alg(rubik.Algorithm("y'"))
        return False
    c.apply_alg(y)
    if twobytwosolved(c):
        c.apply_alg(rubik.Algorithm("y2"))
        return True
    else:
        c.apply_alg(rubik.Algorithm("y2"))
        return False
Пример #6
0
def twobytwobythreesolved(c):
    if not twobytwosolved(c):
        return False

    c.apply_alg(y)
    if not square_solved(c):
        c.apply_alg(rubik.Algorithm("y'"))
        return False

    c.apply_alg(rubik.Algorithm("x y'"))
    if square_solved(c):
        c.apply_alg(z)
        return True
    else:
        c.apply_alg(z)
        return False
Пример #7
0
def square_solved(c):
    if not (c.cube[0][1][0] == c.cube[0][1][1] == c.cube[0][2][0] ==
            c.cube[0][2][1]):
        return False

    c.apply_alg(z)
    if not c.cube[0][1][2] == c.cube[0][2][2]:
        c.apply_alg(rubik.Algorithm("z'"))
        return False

    c.apply_alg(x)
    if c.cube[0][0][2] == c.cube[0][1][2]:
        c.apply_alg(rubik.Algorithm('y z z x'))
        return True
    else:
        c.apply_alg(rubik.Algorithm('y z z x'))
        return False
Пример #8
0
def check8positions(func, c):
    for i in range(8):
        c.apply_alg(y)
        if i == 4:
            c.apply_alg(rubik.Algorithm("x2"))

        if func(c):
            return True
    return False
Пример #9
0
def check6positions(func, c):
    for i in range(4):
        c.apply_alg(x)
        if func(c):
            return True
    c.apply_alg(z)
    if func(c):
        return True
    c.apply_alg(rubik.Algorithm("z2"))
    if func(c):
        return True
    return False
Пример #10
0
def check24positions(func, c):
    for i in range(24):
        if i == 4 or i == 8 or i == 12:
            c.apply_alg(z)
        if i == 16:
            c.apply_alg(x)
        if i == 20:
            c.apply_alg(rubik.Algorithm('x2'))
        if func(c):
            return True
        c.apply_alg(y)
    return False
Пример #11
0
def cross_solved(c):
    if not c.cube[0][0][1] == c.cube[0][1][0] == c.cube[0][1][2] == c.cube[0][
            2][1] == c.cube[0][1][1]:
        return False
    c.apply_alg(x)
    is_solved = True
    for i in range(4):
        c.apply_alg(z)
        if not c.cube[0][0][1] == c.cube[0][1][1]:
            is_solved = False
    c.apply_alg(rubik.Algorithm("x'"))
    return is_solved
Пример #12
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).")
Пример #13
0
def movealg():
    short = textArea.get("start", INSERT)
    pos = textArea.search(short, '0.0', stopindex=END)
    return rubik.Algorithm(movestring(textArea.get(2.0, pos))[0] + movestring(textArea.get(1.0, 2.0))[1] + movestring(textArea.get(2.0, pos))[1])
Пример #14
0
scroll.config(command=textArea.yview)
textArea.config(yscrollcommand=scroll.set)
output_area = Text(root, width=100, height=20)
output_area.grid(row=1, column=0, sticky=NSEW)
output_scroll = Scrollbar(root)
output_scroll.grid(row=1, column=1, sticky=NS)
output_scroll.config(command=output_area.yview)
output_area.config(yscrollcommand=output_scroll.set)

textArea.insert(1.0, "Scramble: \n\nSolution: ")

root.rowconfigure(0, weight=1)
root.rowconfigure(1, weight=1)
root.columnconfigure(0, weight=1)

x = rubik.Algorithm('x')
y = rubik.Algorithm('y')
z = rubik.Algorithm('z')

abbreviations = {
        "222": "2x2x2",
        "2x2x2": "2x2x2",
        "2X2X2": "2x2x2",
        "2x2": "2x2x2",
        "2X2": "2x2x2",
        "sq": "Square",
        "SQ": "Square",
        "122": "Square",
        "1x2x2": "Square",
        "1X2X2": "Square",
        "square": "Square",
Пример #15
0
def eosolved(c):
    up = c.cube[0][1][1]
    c.apply_alg(z)
    left = c.cube[0][1][1]
    c.apply_alg(z)
    down = c.cube[0][1][1]
    c.apply_alg(z)
    right = c.cube[0][1][1]

    if c.cube[0][0][1] == up or c.cube[0][1][0] == up or c.cube[0][1][
            2] == up or c.cube[0][2][1] == up or (
                c.cube[0][0][1]) == down or c.cube[0][1][0] == down or c.cube[
                    0][1][2] == down or c.cube[0][2][1] == down:
        c.apply_alg(z)
        return False

    c.apply_alg(rubik.Algorithm("z2"))

    if c.cube[0][0][1] == up or c.cube[0][1][0] == up or c.cube[0][1][
            2] == up or c.cube[0][2][1] == up or (
                c.cube[0][0][1]) == down or c.cube[0][1][0] == down or c.cube[
                    0][1][2] == down or c.cube[0][2][1] == down:
        c.apply_alg(rubik.Algorithm("z'"))
        return False

    c.apply_alg(z)

    if c.cube[0][0][1] == left or c.cube[0][1][0] == left or c.cube[0][1][
            2] == left or c.cube[0][2][1] == left or (
                c.cube[0][0][1]
            ) == right or c.cube[0][1][0] == right or c.cube[0][1][
                2] == right or c.cube[0][2][1] == right:
        c.apply_alg(rubik.Algorithm("z2"))
        return False

    c.apply_alg(rubik.Algorithm("z2"))

    if c.cube[0][0][1] == left or c.cube[0][1][0] == left or c.cube[0][1][
            2] == left or c.cube[0][2][1] == left or (
                c.cube[0][0][1]
            ) == right or c.cube[0][1][0] == right or c.cube[0][1][
                2] == right or c.cube[0][2][1] == right:
        return False

    c.apply_alg(x)

    if c.cube[0][1][0] == left or c.cube[0][1][2] == left or c.cube[0][1][
            0] == right or c.cube[0][1][2] == right:
        c.apply_alg(rubik.Algorithm("x'"))
        return False

    c.apply_alg(rubik.Algorithm("x2"))

    if c.cube[0][1][0] == left or c.cube[0][1][2] == left or c.cube[0][1][
            0] == right or c.cube[0][1][2] == right:
        c.apply_alg(x)
        return False

    c.apply_alg(y)

    if c.cube[0][1][0] == up or c.cube[0][1][2] == up or c.cube[0][1][
            0] == down or c.cube[0][1][2] == down:
        c.apply_alg(rubik.Algorithm("y' x'"))
        return False

    c.apply_alg(rubik.Algorithm("x2"))

    if c.cube[0][1][0] == up or c.cube[0][1][2] == up or c.cube[0][1][
            0] == down or c.cube[0][1][2] == down:
        c.apply_alg(rubik.Algorithm("y x'"))
        return False

    c.apply_alg(rubik.Algorithm("y x'"))
    return True