Zum Inhalt

beginner special

BeginnerSolver

solve(self)

Solves the cube provided to the solver

Returns:

Type Description
str

solution to the cube

Source code in core/solver/beginner/__init__.py
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
def solve(self):
    solution = []
    solution += WhiteCross.solve(self.cube)
    check_white_cross(self.cube)
    solution += WhiteFace.solve(self.cube)
    check_white_face(self.cube)
    solution += SecondLayer.solve(self.cube)
    check_second_layer(self.cube)
    solution += YellowCross.solve(self.cube)
    check_yellow_cross(self.cube)
    solution += YellowEdge.solve(self.cube)
    check_yellow_edge(self.cube)
    solution += YellowCornerPosition.solve(self.cube)
    check_yellow_corner_position(self.cube)
    solution += YellowCornerOrientation.solve(self.cube)
    return solution

check_face(cube, cubie, face)

Checks that the color of a face on a cubie is correct => solved

Parameters:

Name Type Description Default
cube Cube

Cube to check

required
cubie Cubie

Cubie to check

required
face str

Face of the cubie to check

required
Source code in core/solver/beginner/__init__.py
 6
 7
 8
 9
10
11
12
13
14
15
def check_face(cube: Cube, cubie: Cubie, face: str):
    """
    Checks that the color of a face on a cubie is correct => solved

    Args:
        cube (Cube): Cube to check
        cubie (Cubie): Cubie to check
        face (str): Face of the cubie to check
    """
    assert cubie.faces[face] == cube.face_color(face), f"Invalid color on cubie '{cubie.get_name()}'"

check_second_layer(cube)

Checks that the second layer step was correctly executed

Parameters:

Name Type Description Default
cube Cube

Cube to check

required
Source code in core/solver/beginner/__init__.py
43
44
45
46
47
48
49
50
51
52
53
54
def check_second_layer(cube: Cube):
    """
    Checks that the second layer step was correctly executed

    Args:
        cube (Cube): Cube to check
    """
    check_white_face(cube)
    for side in 'LF FR RB BL'.split():
        cubie = cube.cubies[Cube.get_cubie_name(side)]
        check_face(cube, cubie, side[0])
        check_face(cube, cubie, side[1])

check_white_cross(cube)

Checks that the white cross step was correctly executed

Parameters:

Name Type Description Default
cube Cube

Cube to check

required
Source code in core/solver/beginner/__init__.py
17
18
19
20
21
22
23
24
25
26
27
def check_white_cross(cube: Cube):
    """
    Checks that the white cross step was correctly executed

    Args:
        cube (Cube): Cube to check
    """
    for side in 'LFRB': 
        cubie = cube.cubies[Cube.get_cubie_name('D' + side)]
        check_face(cube, cubie, 'D')
        check_face(cube, cubie, side)

check_white_face(cube)

Checks that the white face step was correctly executed

Parameters:

Name Type Description Default
cube Cube

Cube to check

required
Source code in core/solver/beginner/__init__.py
29
30
31
32
33
34
35
36
37
38
39
40
41
def check_white_face(cube: Cube):
    """
    Checks that the white face step was correctly executed

    Args:
        cube (Cube): Cube to check
    """
    check_white_cross(cube)
    for side in 'LF FR RB BL'.split():
        cubie = cube.cubies[Cube.get_cubie_name('D' + side)]
        check_face(cube, cubie, 'D')
        check_face(cube, cubie, side[0])
        check_face(cube, cubie, side[1])

check_yellow_corner_orientation(cube)

Checks that the yellow corner orientation step was correctly executed

Parameters:

Name Type Description Default
cube Cube

Cube to check

required
Source code in core/solver/beginner/__init__.py
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
def check_yellow_corner_orientation(cube: Cube):
    """
    Checks that the yellow corner orientation step was correctly executed

    Args:
        cube (Cube): Cube to check
    """
    check_yellow_corner_position(cube)
    for side in 'LF FR RB BL'.split():
        cubie = cube.cubies[Cube.get_cubie_name('U' + side)]
        check_face(cube, cubie, 'U')
        check_face(cube, cubie, side[0])
        check_face(cube, cubie, side[1])

check_yellow_corner_position(cube)

Checks that the yellow corner position step was correctly executed

Parameters:

Name Type Description Default
cube Cube

Cube to check

required
Source code in core/solver/beginner/__init__.py
80
81
82
83
84
85
86
87
88
89
90
91
def check_yellow_corner_position(cube: Cube):
    """
    Checks that the yellow corner position step was correctly executed

    Args:
        cube (Cube): Cube to check
    """
    check_yellow_edge(cube)
    for side in 'LF FR RB BL'.split():
        cubie_by_faces = cube.cubies[Cube.get_cubie_name('U' + side)]
        cubie_by_colors = cube.cubie_by_colors(cube.face_color('U'), cube.face_color(side[0]), cube.face_color(side[1]))
        assert cubie_by_colors == cubie_by_faces, f"Corners not in the right positions!\nFound: {cubie_by_faces}\nExpected: {cubie_by_colors}"

check_yellow_cross(cube)

Checks that the yellow cross step was correctly executed

Parameters:

Name Type Description Default
cube Cube

Cube to check

required
Source code in core/solver/beginner/__init__.py
56
57
58
59
60
61
62
63
64
65
66
def check_yellow_cross(cube: Cube):
    """
    Checks that the yellow cross step was correctly executed

    Args:
        cube (Cube): Cube to check
    """
    check_second_layer(cube)
    for side in 'LFRB':
        cubie = cube.cubies[Cube.get_cubie_name('U' + side)]
        check_face(cube, cubie, 'U')

check_yellow_edge(cube)

Checks that the yellow edge step was correctly executed

Parameters:

Name Type Description Default
cube Cube

Cube to check

required
Source code in core/solver/beginner/__init__.py
68
69
70
71
72
73
74
75
76
77
78
def check_yellow_edge(cube: Cube):
    """
    Checks that the yellow edge step was correctly executed

    Args:
        cube (Cube): Cube to check
    """
    check_yellow_cross(cube)
    for side in 'LFRB':
        cubie = cube.cubies[Cube.get_cubie_name('U' + side)]
        check_face(cube, cubie, side)