add masking
This commit is contained in:
28
cube.py
28
cube.py
@ -38,12 +38,12 @@ class LSECube:
|
||||
# "DF": Edge("DF", True),
|
||||
# }
|
||||
self.edges = {
|
||||
"UB": Edge("", True),
|
||||
"UB": Edge("UB", True),
|
||||
"UR": Edge("UR", True),
|
||||
"UF": Edge("", True),
|
||||
"UF": Edge("UF", True),
|
||||
"UL": Edge("UL", True),
|
||||
"DB": Edge("", True),
|
||||
"DF": Edge("", True),
|
||||
"DB": Edge("DB", True),
|
||||
"DF": Edge("DF", True),
|
||||
}
|
||||
self.centers = {
|
||||
"U": "U",
|
||||
@ -58,16 +58,22 @@ class LSECube:
|
||||
"UBL": "UBL",
|
||||
}
|
||||
|
||||
def __hash__(self):
|
||||
def eolrb_hash(self):
|
||||
# TODO: I fucking hate this language. why can't hashing be simpelr
|
||||
hash_dict = lambda d: hashlib.md5(str(sorted(d.items())).encode()).hexdigest()
|
||||
edges_hash = hash_dict(self.edges)
|
||||
centers_hash = hash_dict(self.centers)
|
||||
corners_hash = hash_dict(self.corners)
|
||||
eolrb_state = {}
|
||||
# mask edges to only care about LR edges and orientation of everything else
|
||||
for location, edge in self.edges.items():
|
||||
if edge.name in ["UR", "UL"]:
|
||||
eolrb_state[location] = edge
|
||||
else:
|
||||
eolrb_state[location] = Edge("", edge.oriented)
|
||||
|
||||
eolrb_state["center_oriented"] = self.centers["U"] in ["U", "D"]
|
||||
eolrb_state["UFR"] = self.corners["UFR"]
|
||||
|
||||
return int(
|
||||
hashlib.md5(
|
||||
(edges_hash + centers_hash + corners_hash).encode()
|
||||
).hexdigest(),
|
||||
hashlib.md5(hash_dict(eolrb_state).encode()).hexdigest(),
|
||||
16,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user