preface
Use Python to automatically play “Stop stepping on white blocks”. Let’s have fun
The development tools
Python version: 3.6.4
Related modules:
Numpy module;
Cv2 module;
Pyautogui module;
Pyscreenshot module;
And some modules that come with Python.
Environment set up
Install Python and add it to the environment variables. PIP installs the required related modules.
Introduction of the principle
Rules of the game:
Principle introduction:
The principle is actually quite simple, the main loop code is shown below:
The first is to capture the game interface:
Binary game interface:
Morphological treatment:
Achieve contour detection:
This is the end of this article. Thank you for watching. In the next article, we will share Python AI version of Snake