Skip to content

play wechat game 'tiaoyitiao' automatically with python\opencv\adb

Notifications You must be signed in to change notification settings

invoker-LL/automatic_leap

Repository files navigation

automatic_leap

play wechat game 'tiaoyitiao' automatically with python\opencv\adb shell\windows .bat

Illustrate in step with functions' name:

  1. start the game in android phone, and connect the phone with computer using USB, then make sure all the eviroment dependencies done.

GetScreenshot():

  1. use adb interface and windows .bat script to make shotscreen, then transfer the shotscreen fig into computer.

  2. pre-process the fig: To reduce CV computing time, only save the middle part of the fig into variables. For the fact that the game is built in 2 dims picture to show 3 dims space, and the angle of axis-x and axis-y is 120°, together with the limit of width of figuer pixel, only save middle part is OK.
    Save 3 channel of the picture into different variable to tackle with some situation that color change gradually.

  3. Also, to tackle with some situation that color change gradually.we analyze 5 pictures in a loop until one good result is found, they are b,g,r channel, and original 3-ch picture(use cv2.cvtColor() to transform it as a gray one, denoted as figure-B), and fig-B after equalizeHist process respectively.

PreProcess():

  1. preprocess the fig with Canny Arithmetic to find the edge, then dilate the edge for better detection in following steps.

LocateDollandMiniCircle():

  1. use cv2.matchTemplate() to find the jumping doll(character) and return its bottum center coordinate A (x1,y1) in picture.

    use cv2.matchTemplate() to find the mini circle in whole picture and return its center coordinate B (x2,y2).

    in continuous leap, if we always jump into the next bat's center part, then before next jump, the mini circle(next bat's center part) will appear.Continuously Jumping into this part will get a exponential growth in score.

  2. if template result is good in 4)& 5), we can calculate the next jump length. the next target pats only have two different shapes: 1. Rectangle(in xyz axis 3dim space, it is quad-angle like diamond) 2. circle (oval)

LocateRectangle(): return the center coordinates of Rectangle

  1. find the upper 120° angle in whole picture using cv2.matchTemplate(), since we know every jump direction is 30° and is in upper part of the doll, we can find the target pat if it is quad-angle.

LocateCircles(): return the center coordinates of circle

  1. resize the x-axis of the 2-dim picture, we can transfer oval into good circle, then we use cv2.HoughCircles() to detect target circle if possible.

  2. calculate the jump length in 7)& 8), compare them with the result of 6), get the max result.

MakeJmpAction():

  1. transfer the jump length into finger touch duration time, then use adb shell script to simulate human touch in phone.
  2. after a few second for waiting the doll finishing jump, back to 1) step for loop.

About

play wechat game 'tiaoyitiao' automatically with python\opencv\adb

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published