Zum Inhalt

Cubie

Cubie

Represents a subcube.

It contains the colors of its faces in the faces dicrionary.

__init__(self) special

Initializes a new Cubie that has no facelets

Source code in core/solver/Cubie.py
11
12
13
14
15
def __init__(self):
    """
    Initializes a new Cubie that has no facelets
    """
    self.faces: Dict[str, TileColor] = {}

__str__(self) special

Gets the string representation of this cubie including its faces and colors

Returns:

Type Description
[type]

String representation of this cubie

Source code in core/solver/Cubie.py
38
39
40
41
42
43
44
45
def __str__(self):
    """
    Gets the string representation of this cubie including its faces and colors

    Returns:
        [type]: String representation of this cubie
    """
    return ', '.join(map(lambda x: x[0] + " " + x[1].name, self.faces.items()))

color_facing(self, color)

Finds the face that has the given color

Parameters:

Name Type Description Default
color TileColor

Color to search for

required

Returns:

Type Description
str

str: Face with the given color

Source code in core/solver/Cubie.py
17
18
19
20
21
22
23
24
25
26
27
def color_facing(self, color: TileColor) -> str:
    """
    Finds the face that has the given color

    Args:
        color (TileColor): Color to search for

    Returns:
        str: Face with the given color
    """
    return ''.join([key for key in self.faces if (self.faces[key] == color)])

get_name(self)

Gets the name of this cubie

Returns:

Type Description
str

str: Name of the cubie

Source code in core/solver/Cubie.py
29
30
31
32
33
34
35
36
def get_name(self) -> str:
    """
    Gets the name of this cubie

    Returns:
        str: Name of the cubie
    """
    return ''.join(sorted(self.faces.keys()))