Esempio n. 1
0
def init_objects(input_alg):
    """
    Initialise a cube, apply the algorithm to it and then for a second time to get to the correct state.
    :param input_alg: string containing an algorithm to parse.
    :type input_alg: str
    :return: Cube, Algorithm
    """
    cube = Cube(3)
    alg = Algorithm(input_alg)
    cube.apply(alg.alg())

    if cube.unsolved_corner_count >= DataSelector.MAX_ALLOWED_UNSOLVED_CORNERS or cube.unsolved_edge_count >= DataSelector.MAX_ALLOWED_UNSOLVED_EDGES:
        raise TooManyUnsolvedPiecesException(
            "This algorithm leaves a lot of pieces unsolved. The parser may be behaving incorrectly, or the alg is bad."
        )

    if cube.unsolved_corner_count + cube.unsolved_edge_count == 0:
        raise AlgorithmDoesNothingException(
            "This algorithm appears to do nothing.")

    return cube, alg
Esempio n. 2
0
 def init_cube(cell):
     alg = Algorithm(cell)
     cube = Cube(3)
     cube.apply(alg.alg())
     return alg, cube