Python advanced WeChat jump jump plug-in

Dev log:

Development process: start running --> configure mobile phone and computer (connection, screen capture, etc.) --> screenshot --> analyze the coordinates of the chess piece --> calculate the distance of the chess piece --> execute the function of pressing the phone screen to jump- ->Wait for 1~2 seconds-->Return to "Screenshot" to repeatedly execute the
plug-in. It is not suitable for the vast majority of Android phones on the market. It is not suitable for IOS system phones. The resolutions supported by the mainstream are 1280*720, 1920*1280, 2560 *1440.
WeChatJump (v1.0) development log:
(The resolution of the terminal mobile phone is 720*1280)
        Running and debugging:
The first overall run: There is a prompt that ADB is not installed, but it has been installed. After switching to the command line, the problem is displayed as normal operation.
Second overall run: There is a problem with receiving the input string.

        Parameter debugging:
The first parameter debugging: the compression coefficient "press_ratio" is 2.180, the circular jump seat is basically not good under the current parameters, and the probability of the square jump seat jumping out is very high. The main reason is that the jump parameter is too large, and the other The aspect is that when jumping, it is not in the direction of the top corner of the screen. As a result, the size of the jump cannot be well controlled during calculation, but in theory, this situation does not exist. The distance calculated by the program is the center point of the next jump seat to the checkers. distance from the center point. Maybe there is a problem when calculating the center point of the jump seat.
The second parameter debugging: the pressure coefficient "press_ratio" is 2.0 and the parameter is set to the same situation.
The third parameter debugging: the pressure coefficient "press_ratio" is 1.800, the situation is reversed, and the opposite situation occurs.
The fourth parameter debugging: the pressing coefficient "press_ratio" is 1.950. When jumping to the upper left, it is easy to exceed the jumping range, but it is not always the case. There are also cases where the center cannot be jumped. In the two cases, the store or the center point, the currently set parameter is 1.950, and the highest score is 306, but when the medicine bottle occurs, the probability of not being able to jump is quite large. Other circular jump seats jump The probability of not reaching the center point is relatively small, but it is larger than that of a square. The next step is to set it to 1.951~1.953
. The fifth parameter debugging: set the jump coefficient to 1.952. Due to the lack of time, the test was performed twice, and the above effects were not improved to a certain extent. Large, the highest score does not exceed 1.950. At present, the jump coefficient is 1.950 is the most suitable.

The source code of the main program part of the program:

def run():
    """Main function, complete the main task of the program"""
    open_game = input('Please make sure the phone has ADB turned on and connected to the computer, then turn on the jump and [start the game] before using this program, are you sure to start? y/n>>:')
    # if (open_game != 'y')or(open_game != 'Y'):
    # exit('Exit!')
    # Initialize:
    config = init()
    #Check the screenshot method:
    check_screenshot()
    print('Get a screenshot by the %s method'%SCREENSHOT_WAY)
    while True:
        #screenshot autojump.png
        get_screenShot()
        #Read the captured image
        img = Image.open('autojump.png')
        piece_x,piece_y,board_x,board_y = find_piece_and_board(img,config)
        #Calculate the distance of the chess pieces
        ntime = time.time()
        print(piece_x,piece_y,board_x,board_y,'------->')
        distance = math.sqrt((piece_x - board_x)**2 + (piece_y - board_y)**2)
        #Generate a random press point to prevent being Banned
        if DEBUG:
            debug.save_debug_screenshot(ntime,img,piece_x,piece_y,board_x,board_y)
            debug.backup_screenshot(ntime)
        press_point = (random.randint(*config['swipe']['x']),
                           random.randint(*config['swipe']['y']))
        #jump
        jump(distance,press_point,config['press_ratio'])
        #rest, stay (note that it should theoretically be a continuous interval that can rest for 1~2 seconds, not a discrete interval)
        time.sleep (random.randrange (1,3))

Time is short, so no analysis will be made for the time being. . . . . Subsequent updates. . .

Tool introduction:

The full name of adb is Android Debug Bridge, which acts as a debugging bridge. Through adb, we can easily debug Android programs through DDMS in Eclipse , which is a debug tool to put it bluntly. Adb works in a special way. It uses the method of listening to ports such as Socket TCP 5554 to let IDE communicate with Qemu. By default, adb will daemon-related network ports, so when we run Eclipse, the adb process will automatically run.
adb is a tool in android sdk . With this tool, you can directly operate and manage android emulators or real android devices (such as G1 mobile phones). Its main functions are:
* Run the device's shell (command line)
* Manage port mappings for emulators or devices
* Upload/download files between computer and device
* Install the local apk software to the emulator or android device
ADB is a client-server program, where the client is the computer you use to operate, and the server is the android device.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325507885&siteId=291194637