Added unsolved pictures
BIN
pictures/unsolved/tmp1ern14si.png
Normal file
|
After Width: | Height: | Size: 5.0 MiB |
BIN
pictures/unsolved/tmp2_0vn4tl.png
Normal file
|
After Width: | Height: | Size: 5.0 MiB |
BIN
pictures/unsolved/tmp32jmcnfp.png
Normal file
|
After Width: | Height: | Size: 5.0 MiB |
BIN
pictures/unsolved/tmpcml2ldfl.png
Normal file
|
After Width: | Height: | Size: 5.0 MiB |
BIN
pictures/unsolved/tmpd7rbwwdb.png
Normal file
|
After Width: | Height: | Size: 5.0 MiB |
BIN
pictures/unsolved/tmpdudxuw0s.png
Normal file
|
After Width: | Height: | Size: 5.0 MiB |
BIN
pictures/unsolved/tmpeplvz9bk.png
Normal file
|
After Width: | Height: | Size: 5.0 MiB |
BIN
pictures/unsolved/tmph_esy__3.png
Normal file
|
After Width: | Height: | Size: 5.0 MiB |
BIN
pictures/unsolved/tmpn95ueb7_.png
Normal file
|
After Width: | Height: | Size: 5.0 MiB |
BIN
pictures/unsolved/tmpqzay4q08.png
Normal file
|
After Width: | Height: | Size: 5.0 MiB |
BIN
pictures/unsolved/tmputbych59.png
Normal file
|
After Width: | Height: | Size: 5.0 MiB |
BIN
pictures/unsolved/tmpx4uo6pg3.png
Normal file
|
After Width: | Height: | Size: 5.0 MiB |
@@ -12,16 +12,16 @@ from .board_possibilities import possible_actions
|
|||||||
@dataclass
|
@dataclass
|
||||||
class ActionStackFrame:
|
class ActionStackFrame:
|
||||||
iterator: Iterator[board_actions.Action]
|
iterator: Iterator[board_actions.Action]
|
||||||
action: Optional[board_actions.Action]
|
last_action: Optional[board_actions.Action]
|
||||||
state: int
|
state: int
|
||||||
|
|
||||||
def next(self) -> Optional[board_actions.Action]:
|
def next(self) -> Optional[board_actions.Action]:
|
||||||
"""Get next iteration of top action iterator"""
|
"""Get next iteration of top action iterator"""
|
||||||
try:
|
try:
|
||||||
self.action = next(self.iterator)
|
self.last_action = next(self.iterator)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return None
|
return None
|
||||||
return self.action
|
return self.last_action
|
||||||
|
|
||||||
|
|
||||||
class ActionStack:
|
class ActionStack:
|
||||||
@@ -35,7 +35,7 @@ class ActionStack:
|
|||||||
self.frames.append(
|
self.frames.append(
|
||||||
ActionStackFrame(
|
ActionStackFrame(
|
||||||
iterator=iter(possible_actions(board)),
|
iterator=iter(possible_actions(board)),
|
||||||
action=None,
|
last_action=None,
|
||||||
state=board.state_identifier,
|
state=board.state_identifier,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -64,23 +64,23 @@ def solve(
|
|||||||
def _limit_stack_size(stack_size: int) -> None:
|
def _limit_stack_size(stack_size: int) -> None:
|
||||||
if len(stack) == stack_size:
|
if len(stack) == stack_size:
|
||||||
stack.pop()
|
stack.pop()
|
||||||
assert stack.top.action is not None
|
assert stack.top.last_action is not None
|
||||||
stack.top.action.undo(board)
|
stack.top.last_action.undo(board)
|
||||||
assert board.state_identifier in state_set
|
assert board.state_identifier in state_set
|
||||||
|
|
||||||
def _backtrack_action() -> None:
|
def _backtrack_action() -> None:
|
||||||
stack.pop()
|
stack.pop()
|
||||||
assert stack.top.action is not None
|
assert stack.top.last_action is not None
|
||||||
stack.top.action.undo(board)
|
stack.top.last_action.undo(board)
|
||||||
assert board.state_identifier in state_set
|
assert board.state_identifier in state_set
|
||||||
|
|
||||||
def _skip_loop_move(action: board_actions.Action) -> bool:
|
def _skip_loop_move(action: board_actions.Action) -> bool:
|
||||||
if not isinstance(action, MoveAction):
|
if not isinstance(action, MoveAction):
|
||||||
return False
|
return False
|
||||||
for frame in stack.frames[-2::-1]:
|
for frame in stack.frames[-2::-1]:
|
||||||
if not isinstance(frame.action, MoveAction):
|
if not isinstance(frame.last_action, MoveAction):
|
||||||
continue
|
continue
|
||||||
if frame.action.cards == action.cards:
|
if frame.last_action.cards == action.cards:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -111,8 +111,10 @@ def solve(
|
|||||||
action.apply(board)
|
action.apply(board)
|
||||||
|
|
||||||
if board.solved():
|
if board.solved():
|
||||||
assert all(x.action is not None for x in stack.frames)
|
assert all(x.last_action is not None for x in stack.frames)
|
||||||
yield [typing.cast(board_actions.Action, x.action) for x in stack.frames]
|
yield [
|
||||||
|
typing.cast(board_actions.Action, x.last_action) for x in stack.frames
|
||||||
|
]
|
||||||
iter_start = time.time()
|
iter_start = time.time()
|
||||||
action.undo(board)
|
action.undo(board)
|
||||||
assert board.state_identifier in state_set
|
assert board.state_identifier in state_set
|
||||||
|
|||||||