aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bot.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/bot.py b/bot.py
index f19694a..0716450 100644
--- a/bot.py
+++ b/bot.py
@@ -2,7 +2,7 @@ import time
2 2
3import mss 3import mss
4import pyautogui as pg 4import pyautogui as pg
5from keyboard import press_and_release 5from keyboard import send
6from numpy import array, uint8 6from numpy import array, uint8
7 7
8 8
@@ -25,15 +25,6 @@ def is_tree(c1):
25 return False 25 return False
26 26
27 27
28def parse_screen(img, moves):
29 left = [img[x, posY[0]] for x in posX]
30 for i in range(6):
31 if is_tree(left[i]):
32 moves.append("right, right")
33 else:
34 moves.append("left, left")
35
36
37with mss.mss() as sct: 28with mss.mss() as sct:
38 screen = sct.monitors[1] 29 screen = sct.monitors[1]
39 screen["width"] = screen["width"] / 2.0 30 screen["width"] = screen["width"] / 2.0
@@ -42,7 +33,10 @@ with mss.mss() as sct:
42 while True: 33 while True:
43 img = array(sct.grab(screen)) 34 img = array(sct.grab(screen))
44 moves = list() 35 moves = list()
45 parse_screen(img, moves) 36 left = [img[x, posY[0]] for x in posX]
46 for m in moves: 37 for i in range(6):
47 press_and_release(m) 38 if is_tree(left[i]):
39 send("right, right", True, True)
40 else:
41 send("left, left", True, True)
48 time.sleep(0.145) 42 time.sleep(0.145)
Powered by cgit v1.2.3 (git 2.41.0)