Added benchmark

This commit is contained in:
Lukas Wölfer
2020-02-12 02:04:50 +01:00
parent a624a06f82
commit c05aa194ce
6 changed files with 178 additions and 126 deletions

View File

@@ -51,7 +51,7 @@ class ActionStack:
def solve(
board: Board, *, timeout: Optional[float] = None
board: Board, *, timeout: Optional[float] = None, verbose: bool = False
) -> Iterator[List[board_actions.Action]]:
"""Solve a solitaire puzzle"""
state_set = {board.state_identifier}
@@ -85,7 +85,8 @@ def solve(
count += 1
if count > 5000:
count = 0
print(f"{time.time() - iter_start} {len(stack)} {board.goal}")
if verbose:
print(f"{time.time() - iter_start} {len(stack)} {board.goal}")
if timeout is not None and time.time() - iter_start > timeout:
return