We won the Hackathon IIT Goa's Cepheus: HackTheGame 🎉🥳
Automating game using openCV in python
Atari Breakout is a hidden Google game which turns Google Images into a playable classic arcade video game with a Google twist. The aim of the game is to bat the ball at the colored blocks until there are none left, while making sure the ball does not pass your paddle.
Game link: https://elgoog.im/breakout
The original Game operates through user by mouse or keyboard keys. But in the automated Version, the game requires no such operations from user. Game is played automatically by object detection and template matching.
Team Name: thisDot
- Madhav jha (f4a88c53)
- Anjali kushwaha (EEBAE845)
- Python Installed in PC/laptop
- Internet connection
- Browser to play game in
- Starting the game:https://elgoog.im/breakout/ 🔌
- Resize the window as following:
- Splitting the screen into two halfs(as shown in picture)🖥️
- Running the code.
-
openCV for object detection and template matching The game contains a ball(object which has to be detected) which moves accordingly after hitting the slider in specific path. For automating the game The ball image is read through the method cv2.imgread and detected through cv2.matchTemplate
-
numpy
-
matplotlib.pyplot as plt
-
pyautogui for keyboard functionality
-
ImageGrab for capturing screen.
- def showImg -for displaying Image
- def readImg - for reading Image
- def grab_screen_img - for capturing screen
- We take ScreenShot of the region where game is being played
- We keep track of the ball current location via
newX and newY
variables and previous location viapreX and preY
- To trace the
ball
we draw acircle
at it's center and arectangle
around it - Using values after many games we change the position of the
platform
with regards to the ball current position + acceleration in X and Y positions + etc.
Github repo: https://github.com/jhamadhav/atari-breakout-hack
Demo video: link
Youtube link for HighScore video: https://youtu.be/NGpsUYme_vk
Drive link for HighScore video: https://drive.google.com/folderview?id=1abjxEn0O53cpht0BiNOV0o6mRnGguA5s