fix nasty bug where eolr permutation would also change orientation

This commit is contained in:
2024-08-24 11:16:23 +03:00
parent 7e247e8980
commit 67e8c7a639
4 changed files with 5 additions and 13 deletions

View File

@ -6,7 +6,6 @@ import sys
from eolr import ( from eolr import (
eolrb_states_generator, eolrb_states_generator,
EOLROrientation, EOLROrientation,
EOLRPermutation,
EOLR_PERMUTATIONS, EOLR_PERMUTATIONS,
) )
import humanize import humanize

View File

@ -29,14 +29,6 @@ class LSECube:
self.reset() self.reset()
def reset(self): def reset(self):
# self.edges = {
# "UB": Edge("UB", True),
# "UR": Edge("UR", True),
# "UF": Edge("UF", True),
# "UL": Edge("UL", True),
# "DB": Edge("DB", True),
# "DF": Edge("DF", True),
# }
self.edges = { self.edges = {
"UB": Edge("UB", True), "UB": Edge("UB", True),
"UR": Edge("UR", True), "UR": Edge("UR", True),
@ -70,6 +62,7 @@ class LSECube:
eolrb_state[location] = Edge("", edge.oriented) eolrb_state[location] = Edge("", edge.oriented)
eolrb_state["center_oriented"] = self.centers["U"] in ["U", "D"] eolrb_state["center_oriented"] = self.centers["U"] in ["U", "D"]
# the value of UFR is supposed to be the key of the value "UFR" in self.corners but whatever
eolrb_state["UFR"] = self.corners["UFR"] eolrb_state["UFR"] = self.corners["UFR"]
return int( return int(

View File

@ -69,8 +69,9 @@ def eolrb_states_generator(
for auf in range(4): for auf in range(4):
state = LSECube() state = LSECube()
apply_eolr_auf(state, auf) apply_eolr_auf(state, auf)
apply_eolr_orientation(state, ori) # applying permutation before orientation is crucial, as permutation swaps pieces and doesn't care about their orientation
apply_eolr_permutation(state, perm) apply_eolr_permutation(state, perm)
apply_eolr_orientation(state, ori)
yield (state, ori, perm, auf) yield (state, ori, perm, auf)
return generator(), num_permutations return generator(), num_permutations

View File

@ -61,8 +61,7 @@ def create_eolrb_prune_table(prune_depth: int):
for alg in generator: for alg in generator:
cube.reset() cube.reset()
cube.alg(" ".join(alg)) cube.alg(" ".join(alg))
solution = reverse_algorithm(alg) prune_table[cube.eolrb_hash()].append(reverse_algorithm(alg))
prune_table[cube.eolrb_hash()].append(solution)
return prune_table return prune_table
@ -83,7 +82,7 @@ def solve_eolrb(cube: LSECube, prune_table: Dict, solve: int):
for prune_solution in prune_table[c.eolrb_hash()]: for prune_solution in prune_table[c.eolrb_hash()]:
alg = condense_algorithm(moves + prune_solution) alg = condense_algorithm(moves + prune_solution)
# TODO: this is very weird # TODO: this is very weird
for _ in range(10): for _ in range(5):
alg = condense_algorithm(alg) alg = condense_algorithm(alg)
if len(alg) > 2: if len(alg) > 2:
# TODO: check if this is mc # TODO: check if this is mc