What would you see in your Chrome browser when there is no internet connection ? Yes, everybody knows that dinosaur game that comes on screen. So, in this article, we are going to build a simple python bot that plays Chrome Dino Game without user interaction. Here we are not using any machine learning or artificial intelligence to counter this problem but we will use simple image/screen processing.
We will work with
PIL (Python Imaging Library) for implementation. This project is very basic and consists of only about 50 lines of code but its result will make you surprise.
Some libraries used are:
- PIL : Python Imaging Library (PIL) is a free library for the Python programming language that adds support for opening, manipulating, and saving many different image file formats.
- Pyautogui : PyAutoGUI is a Python module for programmatically controlling the mouse and keyboard without any user interaction.
- Time : Python “Time” Module which allows us to handle various operations regarding time, its conversions and representations, which find its use in various applications in life.
- Numpy :NumPy is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays.
- Click on the restart button using Pyautogui library using “replaybutton” coordinates.
- Calculate the sum of all white pixels values present in the box in front of Dinosaur.
- If the sum of pixels values present at any time in the box becomes less than the sum of white pixels values, it means either “bush” or “bird” is coming. So either we have to make our Dino jump or bend down.
- In order to protect Dino from “Bush”, we make a jump.
- In order to protect Dino from “Bird”, we always keep our Dino down.
Below is the Python implementation –
Improvements : Over a period of time, the Dino Bot Game becomes fast. The Birds and Bushes start coming very fast. So we are not making our Bot to learn all these things, changing its speed based on past learning. So our bot will function for around 2000 score. In order to score more, we have to apply machine learning and artificial intelligence.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Speech Recognition in Python using Google Speech API
- Project Idea | ( Character Recognition from Image )
- Python | Get a google map image of specified location using Google Static Maps API
- Python | Named Entity Recognition (NER) using spaCy
- Python | Reading contents of PDF using OCR (Optical Character Recognition)
- Python | Multiple Face Recognition using dlib
- Python | Face recognition using GUI
- Python - Get Today's Current Day using Speech Recognition
- Magnetic Ink Character Recognition using Python
- Speech Recognition in Hindi using Python
- Python | Whatsapp birthday bot
- Chat Bot in Python with ChatterBot Module
- How to make a Twitter Bot in Python?
- Python - Making a Reddit bot with PRAW
- Project Idea | (Dynamic Hand Gesture Recognition using neural network)
- ML | Implement Face recognition using k-NN with scikit-learn
- Food Recognition Selenium using Caloriemama API
- ML | Face Recognition Using PCA Implementation
- FaceNet - Using Facial Recognition System
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.