Uploaded a Chrome Dinosaur Game automation script

A script that can play Chrome Dinosaur Game for you.
This commit is contained in:
Abdul Rehman Kalsekar 2022-10-01 00:18:12 +05:30 committed by GitHub
parent 6e7e9f2588
commit d678b2bb0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

46
Dino Automation/main.py Normal file
View File

@ -0,0 +1,46 @@
import pyautogui # pip install pyautogui
from PIL import Image, ImageGrab # pip install pillow
from numpy import asarray
import time
def click(key):
pyautogui.keyDown(key)
return
def isCollision(data):
# Check colison for birds
for i in range(530,560):
for j in range(80, 127):
if data[i, j] < 171:
click("down")
return
# Check colison for cactus
for i in range(530, 620):
for j in range(130, 160):
if data[i, j] < 100:
click("up")
return
return
if __name__ == "__main__":
time.sleep(5)
click('up')
while True:
image = ImageGrab.grab().convert('L')
data = image.load()
isCollision(data)
# # Draw the rectangle for cactus
# for i in range(530, 610):
# for j in range(130, 160):
# data[i, j] = 0
# # # Draw the rectangle for birds
# for i in range(530, 560):
# for j in range(100, 125):
# data[i, j] = 171
# image.show()
# break