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)
Esempio n. 2
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()
Esempio 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
Esempio n. 4
0
    print("            ", up[0])
    print("            ", up[1])
    print("            ", up[2])
    print(left[0], front[0], right[0], back[0])
    print(left[1], front[1], right[1], back[1])
    print(left[2], front[2], right[2], back[2])
    print("            ", down[0])
    print("            ", down[1])
    print("            ", down[2])
    print()


def menu(solver):
    print("If you want the solution, please enter: yes")
    response = input()
    if response == "yes":
        print("Solving is process...\n")
        solution = solver.solve(suppress_progress_messages=False)

    else:
        print("The input is not 'yes'")
        menu(solver)


if __name__ == "__main__":
    mycube = pc.Cube()
    new_cube, formula_scramble = scramble_cube(mycube)
    dispay_cube(new_cube, formula_scramble)
    solver = CFOPSolver(mycube)
    menu(solver)
Esempio n. 5
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)
Esempio n. 6
0
ru = pc.Edge(R=colors[3][7], U=colors[4][1])
rd = pc.Edge(R=colors[3][1], D=colors[5][7])
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\'':
Esempio n. 7
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)
Esempio n. 8
0
                      validation_data=generate_input_arrays(
                          validation_features, validation_targets),
                      validation_steps=VALID_STEPS)

  # The returned "history" object holds a record
  # of the loss values and metric values during training
  print('\nhistory dict:', history.history)

  print('\n# Evaluate on test data')

  eval_cube = pc.Cube()
  alg = pc.Formula()
  random_alg = alg.random()
  eval_cube(random_alg)
  eval_cube_array = cubeAsArray(eval_cube)
  solver = CFOPSolver(eval_cube)
  eval_solution = solver.solve(suppress_progress_messages=True)
  eval_solution = eval_solution.optimise()
  eval_solution = str(eval_solution).split()
  eval_solution.append('#')

  results = model.evaluate_generator(generate_eval_arrays(
                                     eval_cube_array, eval_solution),
                                     steps=len(eval_solution))
  print('test loss, test acc:', results)

  print('\n# Solved cube sanity check')

  solved_cube = pc.Cube()
  solved_cube_array = cubeAsArray(solved_cube)
  solved_features_array = init_features_array()
Esempio n. 9
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')
Esempio n. 10
0
def test_solving_a_solved_cube():
    c = pc.Cube()
    solver = CFOPSolver(c)
    solver.solve()
Esempio n. 11
0
 def normal_solver(self):
     return CFOPSolver(
         self.scramble_ref).solve(suppress_progress_messages=True)