Browse Source

added criteria files

Neccor 4 years ago
parent
commit
d7aba92113
7 changed files with 326 additions and 0 deletions
  1. BIN
      assets/continue.png
  2. BIN
      assets/ok.png
  3. BIN
      assets/options.png
  4. BIN
      assets/ready.png
  5. BIN
      assets/surrender.png
  6. 163
    0
      lose_first.py
  7. 163
    0
      win_first.py

BIN
assets/continue.png View File


BIN
assets/ok.png View File


BIN
assets/options.png View File


BIN
assets/ready.png View File


BIN
assets/surrender.png View File


+ 163
- 0
lose_first.py View File

@@ -0,0 +1,163 @@
1
+import cv2
2
+import time, random
3
+import pyautogui
4
+from datetime import datetime, date
5
+
6
+print(f"Hello")
7
+
8
+def find_image(image, coef=None):
9
+	print(f"\n[find_image] {image}")
10
+	template = cv2.imread("assets/{}".format(image), 0)
11
+	width, height = template.shape[::-1]
12
+	screen = cv2.imread("screenshot.png", 0)
13
+	width2, height2 = screen.shape[::-1]
14
+	match = cv2.matchTemplate(screen, template, cv2.TM_CCOEFF_NORMED)
15
+	value, location = cv2.minMaxLoc(match)[1], cv2.minMaxLoc(match)[3]
16
+	print(f"Value for {image}: {value}")
17
+	if (value >= 0.8):
18
+		return (location[0], location[1], width, height, value)
19
+	else:
20
+		print("Error while searching for image")
21
+		return None
22
+
23
+def sleeper():
24
+	# Random Time
25
+	time.sleep(random.choices(population=[int(1),int(2),int(3),int(4),int(5),int(6),int(7),int(8)],
26
+							weights=[0.03, 0.07, 0.1, 0.3, 0.3, 0.1, 0.07, 0.03])[0])
27
+	return
28
+
29
+
30
+def loose_loop(loose_rounds):
31
+	sleeper()
32
+	pyautogui.screenshot("screenshot.png")
33
+
34
+	v_options = False
35
+	v_surrender = False
36
+	v_ok = False
37
+	v_continue = False
38
+	v_ready = False
39
+
40
+	loose_rounds += 1
41
+	print(loose_rounds)
42
+
43
+	# Options
44
+
45
+	v_options_counter = 0
46
+	while v_options == False:
47
+		sleeper()
48
+		pyautogui.screenshot("screenshot.png")
49
+		options = find_image("options.png")
50
+		if options != None:
51
+			v_options = True
52
+			pyautogui.click((options[0], options[1]))
53
+		elif v_options_counter >= 10:
54
+			v_options = True
55
+			print(f"Skip options")
56
+		else:
57
+			print(f"Zahnräder nicht gefunden")
58
+			sleeper()
59
+
60
+	# Surrender
61
+
62
+	v_surrender_counter = 0
63
+	while v_surrender == False:
64
+		sleeper()
65
+		pyautogui.screenshot("screenshot.png")
66
+		surrender = find_image("surrender.png")
67
+		if surrender != None:
68
+			v_surrender = True
69
+			pyautogui.click((surrender[0], surrender[1]))
70
+		elif v_surrender_counter >= 10:
71
+			v_surrender = True
72
+			print(f"Skip options")
73
+		else:
74
+			print(f"Surrender nicht gefunden")
75
+			sleeper()
76
+
77
+	# OK
78
+
79
+	v_ok_counter = 0
80
+	while v_ok == False:
81
+		sleeper()
82
+		pyautogui.screenshot("screenshot.png")
83
+		ok = find_image("ok.png")
84
+		if ok != None:
85
+			v_ok = True
86
+			pyautogui.click((ok[0], ok[1]))
87
+		elif v_ok_counter >= 10:
88
+			v_ok = True
89
+			print(f"Skip options")
90
+		else:
91
+			print(f"OK nicht gefunden")
92
+			sleeper()
93
+
94
+	# Continue
95
+
96
+	v_continue_counter = 0
97
+	while v_continue == False:
98
+		sleeper()
99
+		pyautogui.screenshot("screenshot.png")
100
+		f_continue = find_image("continue.png")
101
+		if f_continue != None:
102
+			v_continue = True
103
+			pyautogui.click((f_continue[0], f_continue[1]))
104
+		elif v_continue_counter >= 10:
105
+			v_continue = True
106
+			print(f"Skip options")
107
+		else:
108
+			print(f"Continue nicht gefunden")
109
+			sleeper()
110
+
111
+	# Ready
112
+
113
+	v_ready_counter = 0
114
+	while v_ready == False:
115
+		sleeper()
116
+		pyautogui.screenshot("screenshot.png")
117
+		ready = find_image("ready.png")
118
+		if ready != None:
119
+			v_ready = True
120
+			pyautogui.click((ready[0], ready[1]))
121
+		elif v_ready_counter >= 10:
122
+			v_ready = True
123
+			print(f"Skip options")
124
+		else:
125
+			print(f"Ready nicht gefunden")
126
+			sleeper()
127
+
128
+	print(f"\n\n Loop complete restarting \nRunde {loose_rounds} absolviert\n\n")
129
+
130
+	if loose_rounds >= 30:
131
+		print(f"{loose_rounds} Spiele absolviert\nWechsle Modus")
132
+
133
+
134
+def win_loop(win_rounds):
135
+	time.sleep(1)
136
+
137
+	while win_rounds <= 31:
138
+		time.sleep(1)
139
+		pyautogui.screenshot("screenshot.png")
140
+		f_continue = find_image("continue.png")
141
+		f_ready = find_image("ready.png")
142
+		if f_continue != None:
143
+			pyautogui.click((f_continue[0], f_continue[1]))
144
+		elif f_ready != None:
145
+			pyautogui.click((f_ready[0], f_ready[1]))
146
+			print(f"Siege: {win_rounds}")
147
+		else:
148
+			print(f"Kein Ergebniss gefunden")
149
+			time.sleep(1)
150
+
151
+
152
+# Niederlage
153
+loose_rounds = 0
154
+while loose_rounds <= 30:
155
+	loose_loop(loose_rounds)
156
+	loose_rounds += 1
157
+
158
+# Siege
159
+win_rounds = 0
160
+while win_rounds <= 30:
161
+	print("winorund loop")
162
+	win_loop(win_rounds)
163
+	win_rounds += 1

+ 163
- 0
win_first.py View File

@@ -0,0 +1,163 @@
1
+import cv2
2
+import time, random
3
+import pyautogui
4
+from datetime import datetime, date
5
+
6
+print(f"Hello")
7
+
8
+def find_image(image, coef=None):
9
+	print(f"\n[find_image] {image}")
10
+	template = cv2.imread("assets/{}".format(image), 0)
11
+	width, height = template.shape[::-1]
12
+	screen = cv2.imread("screenshot.png", 0)
13
+	width2, height2 = screen.shape[::-1]
14
+	match = cv2.matchTemplate(screen, template, cv2.TM_CCOEFF_NORMED)
15
+	value, location = cv2.minMaxLoc(match)[1], cv2.minMaxLoc(match)[3]
16
+	print(f"Value for {image}: {value}")
17
+	if (value >= 0.8):
18
+		return (location[0], location[1], width, height, value)
19
+	else:
20
+		print("Error while searching for image")
21
+		return None
22
+
23
+def sleeper():
24
+	# Random Time
25
+	time.sleep(random.choices(population=[int(1),int(2),int(3),int(4),int(5),int(6),int(7),int(8)],
26
+							weights=[0.03, 0.07, 0.1, 0.3, 0.3, 0.1, 0.07, 0.03])[0])
27
+	return
28
+
29
+
30
+def loose_loop(loose_rounds):
31
+	sleeper()
32
+	pyautogui.screenshot("screenshot.png")
33
+
34
+	v_options = False
35
+	v_surrender = False
36
+	v_ok = False
37
+	v_continue = False
38
+	v_ready = False
39
+
40
+	loose_rounds += 1
41
+	print(loose_rounds)
42
+
43
+	# Options
44
+
45
+	v_options_counter = 0
46
+	while v_options == False:
47
+		sleeper()
48
+		pyautogui.screenshot("screenshot.png")
49
+		options = find_image("options.png")
50
+		if options != None:
51
+			v_options = True
52
+			pyautogui.click((options[0], options[1]))
53
+		elif v_options_counter >= 10:
54
+			v_options = True
55
+			print(f"Skip options")
56
+		else:
57
+			print(f"Zahnräder nicht gefunden")
58
+			sleeper()
59
+
60
+	# Surrender
61
+
62
+	v_surrender_counter = 0
63
+	while v_surrender == False:
64
+		sleeper()
65
+		pyautogui.screenshot("screenshot.png")
66
+		surrender = find_image("surrender.png")
67
+		if surrender != None:
68
+			v_surrender = True
69
+			pyautogui.click((surrender[0], surrender[1]))
70
+		elif v_surrender_counter >= 10:
71
+			v_surrender = True
72
+			print(f"Skip options")
73
+		else:
74
+			print(f"Surrender nicht gefunden")
75
+			sleeper()
76
+
77
+	# OK
78
+
79
+	v_ok_counter = 0
80
+	while v_ok == False:
81
+		sleeper()
82
+		pyautogui.screenshot("screenshot.png")
83
+		ok = find_image("ok.png")
84
+		if ok != None:
85
+			v_ok = True
86
+			pyautogui.click((ok[0], ok[1]))
87
+		elif v_ok_counter >= 10:
88
+			v_ok = True
89
+			print(f"Skip options")
90
+		else:
91
+			print(f"OK nicht gefunden")
92
+			sleeper()
93
+
94
+	# Continue
95
+
96
+	v_continue_counter = 0
97
+	while v_continue == False:
98
+		sleeper()
99
+		pyautogui.screenshot("screenshot.png")
100
+		f_continue = find_image("continue.png")
101
+		if f_continue != None:
102
+			v_continue = True
103
+			pyautogui.click((f_continue[0], f_continue[1]))
104
+		elif v_continue_counter >= 10:
105
+			v_continue = True
106
+			print(f"Skip options")
107
+		else:
108
+			print(f"Continue nicht gefunden")
109
+			sleeper()
110
+
111
+	# Ready
112
+
113
+	v_ready_counter = 0
114
+	while v_ready == False:
115
+		sleeper()
116
+		pyautogui.screenshot("screenshot.png")
117
+		ready = find_image("ready.png")
118
+		if ready != None:
119
+			v_ready = True
120
+			pyautogui.click((ready[0], ready[1]))
121
+		elif v_ready_counter >= 10:
122
+			v_ready = True
123
+			print(f"Skip options")
124
+		else:
125
+			print(f"Ready nicht gefunden")
126
+			sleeper()
127
+
128
+	print(f"\n\n Loop complete restarting \nRunde {loose_rounds} absolviert\n\n")
129
+
130
+	if loose_rounds >= 30:
131
+		print(f"{loose_rounds} Spiele absolviert\nWechsle Modus")
132
+
133
+
134
+def win_loop(win_rounds):
135
+	time.sleep(1)
136
+
137
+	while win_rounds <= 31:
138
+		time.sleep(1)
139
+		pyautogui.screenshot("screenshot.png")
140
+		f_continue = find_image("continue.png")
141
+		f_ready = find_image("ready.png")
142
+		if f_continue != None:
143
+			pyautogui.click((f_continue[0], f_continue[1]))
144
+		elif f_ready != None:
145
+			pyautogui.click((f_ready[0], f_ready[1]))
146
+			print(f"Siege: {win_rounds}")
147
+		else:
148
+			print(f"Kein Ergebniss gefunden")
149
+			time.sleep(1)
150
+
151
+
152
+# Niederlage
153
+loose_rounds = 0
154
+while loose_rounds <= 30:
155
+	loose_loop(loose_rounds)
156
+	loose_rounds += 1
157
+
158
+# Siege
159
+win_rounds = 0
160
+while win_rounds <= 30:
161
+	print("winorund loop")
162
+	win_loop(win_rounds)
163
+	win_rounds += 1

Loading…
Cancel
Save