aboutsummaryrefslogtreecommitdiff
path: root/bot.py
blob: f19694aba1966e62da603765c56481f47247b391 (plain) (blame)
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
import time

import mss
import pyautogui as pg
from keyboard import press_and_release
from numpy import array, uint8


def begin():
    pg.click(440, 900, 2)


TREE = uint8([56, 116, 161])

# from left to right
posY = [360, 460]
# from bottom to up
posX = [640, 540, 440, 340, 240, 140]


def is_tree(c1):
    if c1[0] == TREE[0] and c1[1] == TREE[1] and c1[2] == TREE[2]:
        return True
    else:
        return False


def parse_screen(img, moves):
    left = [img[x, posY[0]] for x in posX]
    for i in range(6):
        if is_tree(left[i]):
            moves.append("right, right")
        else:
            moves.append("left, left")


with mss.mss() as sct:
    screen = sct.monitors[1]
    screen["width"] = screen["width"] / 2.0
    begin()

    while True:
        img = array(sct.grab(screen))
        moves = list()
        parse_screen(img, moves)
        for m in moves:
            press_and_release(m)
        time.sleep(0.145)
Powered by cgit v1.2.3 (git 2.41.0)