Added debug branch, to make optimized run faster
This commit is contained in:
@@ -16,15 +16,15 @@ class Action:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def apply(self, action_board: board.Board) -> None:
|
def apply(self, action_board: board.Board) -> None:
|
||||||
#print(f"Applying {str(self)}")
|
|
||||||
assert self._before_state == 0
|
assert self._before_state == 0
|
||||||
assert self._after_state == 0
|
assert self._after_state == 0
|
||||||
|
if __debug__:
|
||||||
self._before_state = action_board.state_identifier
|
self._before_state = action_board.state_identifier
|
||||||
self._apply(action_board)
|
self._apply(action_board)
|
||||||
|
if __debug__:
|
||||||
self._after_state = action_board.state_identifier
|
self._after_state = action_board.state_identifier
|
||||||
|
|
||||||
def undo(self, action_board: board.Board) -> None:
|
def undo(self, action_board: board.Board) -> None:
|
||||||
#print(f"Undoing {str(self)}")
|
|
||||||
assert action_board.state_identifier == self._after_state
|
assert action_board.state_identifier == self._after_state
|
||||||
self._undo(action_board)
|
self._undo(action_board)
|
||||||
assert action_board.state_identifier == self._before_state
|
assert action_board.state_identifier == self._before_state
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ class SolitaireSolver:
|
|||||||
|
|
||||||
def solve(self) -> Iterator[List[board_actions.Action]]:
|
def solve(self) -> Iterator[List[board_actions.Action]]:
|
||||||
while self.stack:
|
while self.stack:
|
||||||
|
if len(self.stack) == -1:
|
||||||
|
self.stack.pop()
|
||||||
|
self.stack.action_stack[-1].undo(self.search_board)
|
||||||
|
assert (self.search_board.state_identifier
|
||||||
|
in self.state_set)
|
||||||
|
|
||||||
assert (self.search_board.state_identifier ==
|
assert (self.search_board.state_identifier ==
|
||||||
self.stack.state_stack[-1])
|
self.stack.state_stack[-1])
|
||||||
|
|||||||
Reference in New Issue
Block a user