Ejemplo n.º 1
0
def test_for_basic_ability_to_solve():
    c = pc.Cube()
    alg = pc.Formula()
    random_alg = alg.random()
    c(random_alg)
    solver = CFOPSolver(c)
    solver.solve()
Ejemplo n.º 2
0
def custom(channel_id, letters, database_connection):
    """	Verifies and configures a cube with a sequence of characters."""
    if len(letters) != SQUARES_ON_A_CUBE:
        return (
            "You must provide "
            + str(SQUARES_ON_A_CUBE)
            + " colour characters but you have given "
            + str(len(letters))
            + "."
        )
    for x in range(0, SQUARES_ON_A_CUBE):
        if not letters[x] in COLOUR_CODES:
            return embolden(
                letters[x]
            ) + " is not a valid colour code. " "Please only use codes from this list: " + str(
                COLOUR_CODES
            )
    colours = list(map((lambda x: COLOUR_DECODE[x]), letters))
    mycube = pc.Cube(pc.array_to_cubies(colours))
    solver = CFOPSolver(mycube)
    try:
        solution = solver.solve()
    except ValueError:
        return "You have input an impossible cube configuration."
    state = str(solution.reverse())
    delete_cube(channel_id, database_connection)
    modify_and_draw_cube(channel_id, state, database_connection)
Ejemplo n.º 3
0
           U=Square(colordic[u[2][2]]),
           F=Square(colordic[f[0][2]])),
    Edge(B=Square(colordic[b[1][2]]), L=Square(colordic[l[1][0]])),
    Edge(L=Square(colordic[l[2][1]]), D=Square(colordic[d[1][0]])),
    Centre(L=Square(colordic[l[1][1]])),
    Corner(R=Square(colordic[r[2][2]]),
           B=Square(colordic[b[2][0]]),
           D=Square(colordic[d[2][2]])),
    Edge(U=Square(colordic[u[2][1]]), F=Square(colordic[f[0][1]])),
    Centre(F=Square(colordic[f[1][1]])),
    Edge(R=Square(colordic[r[1][0]]), F=Square(colordic[f[1][2]])),
    Corner(B=Square(colordic[b[0][2]]),
           U=Square(colordic[u[0][0]]),
           L=Square(colordic[l[0][0]])),
    Centre(D=Square(colordic[d[1][1]])),
    Edge(B=Square(colordic[b[0][1]]), U=Square(colordic[u[0][1]])),
    Centre(B=Square(colordic[b[1][1]]))
])

print(c)

solver = CFOPSolver(c)
solution = solver.solve(suppress_progress_messages=True)
length = len(solution)
solution = str(solution)
i = 0

while True:
    if i >= length:
        break
Ejemplo n.º 4
0
    if (us1[0] == "crear" and us1[1] == "algoritmo"):
        for x in range(0, 6):
            for y in range(0, 9):
                child += paso[carascubo[x][y]]

        print child

        c = pc.Cube()
        c.children = pc.array_to_cubies(child)

        c

        c.perform_algo('F F F F')
        c.perform_algo('B B B B')
        c.perform_algo('D D D D')
        c.perform_algo('R R R R')
        c.perform_algo('L L L L')
        c.perform_algo('U U U U')

        sol = CFOPSolver(c)
        sol1 = sol.solve()

    if (us1[0] == "crear" and us1[1] == "algoritmo"):
        for x in range(0, len(sol1)):
            sol2 = str(sol1[x])
            if len(sol2 == 2):
                rubikbot.movearm(sol2)
            else:
                sol2 += 'a'
                rubikbot.movearm(sol2)
Ejemplo n.º 5
0
rb = pc.Edge(R=colors[3][5], B=colors[2][3])

rub = pc.Corner(R=colors[3][8], U=colors[4][2], B=colors[2][6])
rdb = pc.Corner(R=colors[3][2], D=colors[5][8], B=colors[2][0])

ub = pc.Edge(U=colors[4][5], B=colors[2][7])
db = pc.Edge(D=colors[5][5], B=colors[2][1])

#########  SOLVE  ##########
c = pc.Cube([
    f, l, r, u, d, b, flu, fru, fu, fl, fr, fld, fd, fdr, lu, ld, lb, lub, ldb,
    ru, rd, rb, rub, rdb, ub, db
])
sol = CFOPSolver(c)

final_result = sol.solve(c)

ind = 0
for instr in final_result:
    if instr == 'F':
        face = 'red'
        orient = 'clockwise'
    if instr == 'F\'':
        face = 'red'
        orient = 'counter-clockwise'
    if instr == 'R':
        face = 'yellow'
        orient = 'clockwise'
    if instr == 'R\'':
        face = 'yellow'
        orient = 'counter-clockwise'
Ejemplo n.º 6
0
array_default = '000000000111111111222222222333333333444444444555555555'

array = 'yyyrggowwbyogybgoyrygoorrwrggbbwgwwooowwbrwrybbryrbbog'

cube_default = pc.Cube()

cubie = pc.array_to_cubies(array)

cube_main = pc.Cube(cubie)

print(cube_main)

#cube_main

solver = CFOPSolver(cube_main)

steps = solver.solve()
#steps = steps.mirror()

step_list = list(steps)
print(steps)
print(len(steps))

cube_solve = pc.Cube(cubie)

for i in range(len(step_list)):
    cube_solve(steps[i])
    print(cube_solve)
    sleep(0.3)
Ejemplo n.º 7
0
#   5:blue
#          !
top = "422415250"  #Oben (Gelb) 1
bot = "333333333"  #Unten (Weiß) 3
bac = "005145444"  #Hinten (Orange) 4
fro = "141201000"  #Vorne (Rot) 0
lef = "114054555"  #Links (Blau) 5
rig = "511220222"  #Rechts (Grün) 2
cubie = pc.array_to_cubies(lef + top + fro + bot + rig + bac)
print(cubie)
cube = pc.Cube(cubie)
cube_step = pc.Cube(cubie)

#Würfel anzeigen
print(cube)

#Würfel lösen
solver = CFOPSolver(cube)
solution = solver.solve(suppress_progress_messages=False)

#Würfel gelöst
print(cube)

#Schritte einzeln anzeigen
for step in solution:
    cube_step(step)
    print(step)
    print(cube_step)

print('\x1b[6;30;42m' + 'Gelöst!' + '\x1b[0m')
Ejemplo n.º 8
0
def test_solving_a_solved_cube():
    c = pc.Cube()
    solver = CFOPSolver(c)
    solver.solve()