There are too many tricks for Wechat "Tiaoyitiao" mini program. Here I give a method to play the game automatically. Different from the older software proposal, I added the Arduino module to imitate the behaviors of the human.
How does it act?
Distinguish the Screenshot
First of all, we need to work out the program to distinguish the chess piece and board, furthermore, finding the distance between the chess piece and the target position and calculating the pressing time. It’s definitely a complicated process. I used the open-source project https://github.com/wangshub/wechat_jump_game. We should connect the mobile phone to the computer with USB and make sure that we have installed android adb debug command so that the mobile phone can take screenshots via the program for the next manipulation.
Control the Servo With Arduino
I wrote the C program with Arduino IDE, the Arduino serial only accepts string type input, for convenience I use the char_to_int(char i) function to transform the input type. The servo moves to an angle decided by the .write(angle) method, the parameter angle can be different in other situations. The delay time is associated with pressing time based on the distance between the target position and chess piece.
voidloop() { char a, b, c; int i; while(!Serial.available()); if(Serial.available()) { a = Serial.read(); delay(3); } if(Serial.available()) { b = Serial.read(); delay(3); } if(Serial.available()) { c = Serial.read(); delay(3); } if(b == NULL) { i = char_to_int(a); Serial.println(i, DEC); } elseif(c == NULL) { i = char_to_int(a) * 10 + char_to_int(b); Serial.println(i, DEC); } else { i = char_to_int(a) * 100 + char_to_int(b) * 10 + char_to_int(c); Serial.println(i, DEC); } i = i*23;
myservo.write(60); delay(i);
myservo.write(0); }
Control the Arduino Serial
In order to control the Arduino serial input value, we can use the serial monitor embedded in the Arduino IDE. And we can also use python to Implement the same functionality.
The last step is combining the picture distinguishing code and the serial controlling code. I’ve run the code with python3.6 and the whole process performed well.