a
This commit is contained in:
parent
8613d67ea6
commit
2154840844
@ -298,12 +298,13 @@ def breadth_first_search(
|
|||||||
|
|
||||||
step_count = 0
|
step_count = 0
|
||||||
while q and max_steps > 0:
|
while q and max_steps > 0:
|
||||||
if max_steps % 1000 == 0 and step_count:
|
if step_count % 1000 == 0 and step_count:
|
||||||
print(".", end="", flush=True)
|
print(f".", end="", flush=True)
|
||||||
if (
|
if (
|
||||||
bidirectional_fallback_threshold is not None
|
bidirectional_fallback_threshold is not None
|
||||||
and step_count > bidirectional_fallback_threshold
|
and step_count > bidirectional_fallback_threshold
|
||||||
):
|
):
|
||||||
|
print("bidirectional", end=" ")
|
||||||
return bidirectional_search(start, max_steps)
|
return bidirectional_search(start, max_steps)
|
||||||
step_count += 1
|
step_count += 1
|
||||||
|
|
||||||
@ -339,6 +340,8 @@ def print_path(path: list[Axis]):
|
|||||||
def bidirectional_search(
|
def bidirectional_search(
|
||||||
start: Skewb, max_steps: int, end: Skewb = solved_skewb
|
start: Skewb, max_steps: int, end: Skewb = solved_skewb
|
||||||
) -> list[Twist] | None:
|
) -> list[Twist] | None:
|
||||||
|
if start == end:
|
||||||
|
return []
|
||||||
start.assert_valid()
|
start.assert_valid()
|
||||||
q = deque([start])
|
q = deque([start])
|
||||||
q2 = deque([end])
|
q2 = deque([end])
|
||||||
@ -544,12 +547,13 @@ def get_paths_from_heuristic(
|
|||||||
return all(match >= m for match, m in zip(matches, mask))
|
return all(match >= m for match, m in zip(matches, mask))
|
||||||
|
|
||||||
print(f"{mask=} {s=}", end=" ")
|
print(f"{mask=} {s=}", end=" ")
|
||||||
if heuristic_i == len(heuristic_permutation) - 3:
|
if sum(mask) == len(heuristic_permutation) - 3:
|
||||||
# print("going bidirectional now.")
|
# print("going bidirectional now.")
|
||||||
|
print("end-bi", end=" ", flush=True)
|
||||||
path = bidirectional_search(s, max_steps=200000)
|
path = bidirectional_search(s, max_steps=200000)
|
||||||
else:
|
else:
|
||||||
path = breadth_first_search(
|
path = breadth_first_search(
|
||||||
s, step_finished, bidirectional_fallback_threshold=20000
|
s, step_finished, bidirectional_fallback_threshold=200000
|
||||||
)
|
)
|
||||||
print(f" {path=}")
|
print(f" {path=}")
|
||||||
if path is None:
|
if path is None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user