-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrowPuzzleSolver.py
More file actions
114 lines (96 loc) · 3.94 KB
/
arrowPuzzleSolver.py
File metadata and controls
114 lines (96 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import pyautogui
import time
# Define the region where you want pyautogui to operate
region_left = 460
region_top = 200
region_width = 400
region_height = 450
# Generate a list of target image filenames
target_images = ["sq{}.png".format(i) for i in range(1, 38)]
target_images.append("Finish1.png")
target_images.append("Finish2.png")
target_images.append("Finish3.png")
target_images.append("Finish4.png")
target_images.append("Finish5.png")
target_images.append("Finish6.png")
target_images.append("Finish7.png")
target_images.append("GameOver.png")
time.sleep(0.3)
while True:
time.sleep(0.3)
try:
found_target = False
for target_image in target_images:
target_point = pyautogui.locateOnScreen(target_image, region=(region_left, region_top, region_width, region_height), grayscale=True)
if target_point is not None:
found_target = True
click_x = target_point.left + target_point.width / 2
click_y = target_point.top + target_point.height + 60
if click_y > 660:
click_y = 640
print(click_x, click_y)
if target_image == "GameOver.png":
print("FOUND SOLUTION")
pyautogui.moveTo(640, 680)
pyautogui.click()
if target_image == "Finish1.png":
print("FOUND SOLUTION")
pyautogui.moveTo(660, 250)
pyautogui.click()
pyautogui.moveTo(710, 285)
pyautogui.click()
pyautogui.moveTo(810, 335)
pyautogui.click()
pyautogui.moveTo(660, 250)
pyautogui.click()
pyautogui.moveTo(765, 300)
pyautogui.click()
elif target_image == "Finish2.png":
print("FOUND SOLUTION")
pyautogui.moveTo(660, 250)
pyautogui.click()
pyautogui.moveTo(710, 285)
pyautogui.click()
pyautogui.moveTo(810, 335)
pyautogui.click()
elif target_image == "Finish3.png":
print("FOUND SOLUTION")
pyautogui.moveTo(660, 250)
pyautogui.click()
pyautogui.moveTo(710, 285)
pyautogui.click()
pyautogui.moveTo(810, 335)
pyautogui.click()
pyautogui.moveTo(765, 300)
pyautogui.click()
elif target_image == "Finish4.png":
print("FOUND SOLUTION")
pyautogui.moveTo(660, 250)
pyautogui.click()
pyautogui.moveTo(710, 285)
pyautogui.click()
pyautogui.moveTo(810, 335)
pyautogui.click()
pyautogui.moveTo(660, 250)
pyautogui.click()
elif target_image == "Finish5.png":
print("FOUND SOLUTION")
pyautogui.moveTo(660, 250)
pyautogui.click()
elif target_image == "Finish6.png":
print("FOUND SOLUTION")
pyautogui.moveTo(765, 300)
pyautogui.click()
elif target_image == "Finish7.png":
print("FOUND SOLUTION")
pyautogui.moveTo(660, 250)
pyautogui.click()
pyautogui.moveTo(765, 300)
pyautogui.click()
else:
pyautogui.moveTo(click_x, click_y)
pyautogui.click()
if not found_target:
print("NONE FOUND")
except KeyboardInterrupt:
break