Windows fixes

This commit is contained in:
Lukas Wölfer
2020-02-12 01:49:16 +01:00
parent 4cd25719e2
commit a624a06f82
4 changed files with 10 additions and 9 deletions

View File

@@ -114,6 +114,7 @@ def handle_actions(
) -> None: ) -> None:
automatic_count = 0 automatic_count = 0
for action in actions: for action in actions:
print(action)
if automatic(action): if automatic(action):
automatic_count += 1 automatic_count += 1
else: else:

View File

@@ -130,7 +130,7 @@ def possible_goal_move_actions(
if not (card.number == search_board.getGoal(card.suit) + 1): if not (card.number == search_board.getGoal(card.suit) + 1):
continue continue
obvious = all( obvious = all(
search_board.getGoal(other_suit) >= search_board.getGoal(card.suit) search_board.getGoal(other_suit) >= card.number - 1
for other_suit in set(board.NumberCard.Suit) - {card.suit} for other_suit in set(board.NumberCard.Suit) - {card.suit}
) )
yield board_actions.GoalAction( yield board_actions.GoalAction(

View File

@@ -87,7 +87,7 @@ def solve(
count = 0 count = 0
print(f"{time.time() - iter_start} {len(stack)} {board.goal}") print(f"{time.time() - iter_start} {len(stack)} {board.goal}")
if timeout is not None and time.time() - iter_start > timeout: if timeout is not None and time.time() - iter_start > timeout:
raise StopIteration return
# _limit_stack_size(80) # _limit_stack_size(80)

View File

@@ -18,6 +18,7 @@ NEW_BUTTON = (1900, 1100)
def solve() -> None: def solve() -> None:
with tempfile.TemporaryDirectory() as screenshot_dir: with tempfile.TemporaryDirectory() as screenshot_dir:
print("Taking screenshot")
screenshot_file = Path(screenshot_dir) / "screenshot.png" screenshot_file = Path(screenshot_dir) / "screenshot.png"
screenshot = pyautogui.screenshot(region=(*OFFSET, *SIZE)) screenshot = pyautogui.screenshot(region=(*OFFSET, *SIZE))
screenshot.save(screenshot_file) screenshot.save(screenshot_file)
@@ -27,18 +28,17 @@ def solve() -> None:
conf = configuration.load("test_config.zip") conf = configuration.load("test_config.zip")
board = parse_board(image, conf) board = parse_board(image, conf)
assert board.check_correct() assert board.check_correct()
try: solution_iterator = next(solver.solve(board, timeout=10), None)
solution = list(next(solver.solve(board, timeout=10))) if solution_iterator is None:
except StopIteration:
clicker.click(NEW_BUTTON, OFFSET) clicker.click(NEW_BUTTON, OFFSET)
time.sleep(10) time.sleep(10)
return return
solution=list(solution_iterator)
print(f"Solved in {len(solution)} steps") print(f"Solved in {len(solution)} steps")
for step in solution: clicker.handle_actions(solution, OFFSET, conf)
print(step) time.sleep(2)
clicker.handle_action(step, OFFSET, conf)
clicker.click(NEW_BUTTON, OFFSET) clicker.click(NEW_BUTTON, OFFSET)
time.sleep(10) time.sleep(7)
def main() -> None: def main() -> None: