Skip to content

Latest commit

 

History

History
42 lines (25 loc) · 1.9 KB

readme.md

File metadata and controls

42 lines (25 loc) · 1.9 KB

Slither.io bot using openCV

"Working" GIF

Requirements

opencv, python3-dev and python-tk via package manager. pillow, numpy, imutils, pyautogui via pip.

Using openCV version 4.5, python 3.8

Usage

IMPORTANT slither.io must be in low quality mode (top right of the screen), due to changes in the contrast, brightness and colour values.

Edit the capture_size.conf file to set the bounds of the slither.io window.

For example 19, 91, 970, 1015, where 19, 91 is the upper left value and 970, 1015 is the bottom right value. Performance can be improved by reducing the area, but at the cost of enemy snake avoidance. Ensure that the yellow center marker is in the middle of the player snake head, else the contour detection will detect the player snake as an enemy.

Options for finding these values on windows: Stackoverflow or Point Position or trial and error...

On linux with xdotool, for example xdotool getmouselocation --shell from a terminal emulator with the mouse positioned at the corners of the slither.io window.

python3 slither.py from within pySlither/slither/.

Press q to exit the mouse control.

How it works

Screengrabs the area with slither.io playing in. Uses openCV for image tracking and contour detection and pyautogui for the required mouse input. Uses blob.png for target matching to the food items. A heavily filtered, colour and morphological, image is used for the contour detection of enemys.

Visuals

  • Green rectangle = food
  • Pink cross = current target food
  • Yellow cross = center / neutral point
  • Red cross = enemy midpoint
  • Orange = escape direction

Viewport 1: General Vision

Viewport 2: Contour based enemy detection