Skip to content

Instantly share code, notes, and snippets.

@vractal
Last active October 30, 2019 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vractal/b5c93eb7650d6cd463cbe0859a98713e to your computer and use it in GitHub Desktop.
Save vractal/b5c93eb7650d6cd463cbe0859a98713e to your computer and use it in GitHub Desktop.
Lumberjack bot
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