Last active
October 30, 2019 21:37
-
-
Save vractal/b5c93eb7650d6cd463cbe0859a98713e to your computer and use it in GitHub Desktop.
Lumberjack bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from PIL import Image | |
GAME_URL = 'URL' | |
driver = webdriver.Firefox() | |
driver.get(GAME_URL) | |
driver.set_window_size(400, 800) | |
left_button = driver.find_element_by_id('button_left') | |
right_button = driver.find_element_by_id('button_right') | |
left_button.click() | |
is_direction_right = True | |
while True: | |
colision_right = False | |
colision_left = False | |
driver.save_screenshot("screenshot.png") | |
screenshot = Image.open('screenshot.png') | |
pix = screenshot.load() | |
if is_direction_right == True: | |
for i in range(290,330): | |
if pix[250,i] == (161, 116, 56,255): | |
colision_right = True | |
if colision_right == False: | |
right_button.click() | |
else: | |
if colision_left == False: | |
left_button.click() | |
is_direction_right = False | |
else: | |
for i in range(290,330): | |
if pix[150,i] == (161, 116, 56,255): | |
colision_left = True | |
if colision_left == False: | |
left_button .click() | |
else: | |
if colision_right == False: | |
right_button.click() | |
is_direction_right = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment