예제 #1
0
def main():
    '''
    主函数
    '''
    # op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,然后打开跳一跳并【开始游戏】后再用本程序,确定开始?')
    # if not op:
    #    print('bye')
    #    return
    # 初始化AI
    ai.init()

    print('程序版本号:{}'.format(VERSION))
    debug.dump_device_info()
    check_screenshot()

    i, next_rest, next_rest_time = 0, random.randrange(3,
                                                       10), random.randrange(
                                                           5, 10)
    while True:
        pull_screenshot()
        im = Image.open('./autojump.png')
        # 获取棋子和 board 的位置
        piece_x, piece_y, board_x, board_y = find_piece_and_board(im)
        ts = int(time.time())
        # print(ts, piece_x, piece_y, board_x, board_y)
        set_button_position(im)
        press_time = jump(
            math.sqrt((board_x - piece_x)**2 + (board_y - piece_y)**2))

        # 在跳跃落下的瞬间 摄像机移动前截图 这个参数要自己校调
        time.sleep(0.2)
        pull_screenshot_temp()
        im_temp = Image.open('./autojump_temp.png')
        temp_piece_x, temp_piece_y = find_piece(im_temp)
        debug.computing_error(press_time, board_x, board_y, piece_x, piece_y,
                              temp_piece_x, temp_piece_y)

        if debug_switch:
            debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x,
                                        board_y)
            debug.save_debug_screenshot(ts, im_temp, temp_piece_x,
                                        temp_piece_y, board_x, board_y)
            # debug.backup_screenshot(ts)
        i = 0
        if i == next_rest:
            print('已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time))
            for j in range(next_rest_time):
                sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j))
                sys.stdout.flush()
                time.sleep(1)
            print('\n继续')
            i, next_rest, next_rest_time = 0, random.randrange(
                30, 100), random.randrange(10, 60)
        time.sleep(random.uniform(0.5, 0.6))  # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban
def main():
    '''
    主函数
    '''
    # op = yes_or_no('请确保手机打开了 ADB 并连接了电脑,然后打开跳一跳并【开始游戏】后再用本程序,确定开始?')
    # if not op:
    #    print('bye')
    #    return
    # 初始化AI
    ai.init()

    print('程序版本号:{}'.format(VERSION))
    debug.dump_device_info()
    check_screenshot()

    i, next_rest, next_rest_time = 0, random.randrange(3, 10), random.randrange(5, 10)
    while True:
        pull_screenshot()
        im = Image.open('./autojump.png')
        # 获取棋子和 board 的位置
        piece_x, piece_y, board_x, board_y = find_piece_and_board(im)
        ts = int(time.time())
        # print(ts, piece_x, piece_y, board_x, board_y)
        set_button_position(im)
        press_time = jump(math.sqrt((board_x - piece_x) ** 2 + (board_y - piece_y) ** 2))

        # 在跳跃落下的瞬间 摄像机移动前截图 这个参数要自己校调
        time.sleep(0.2)
        pull_screenshot_temp()
        im_temp = Image.open('./autojump_temp.png')
        temp_piece_x, temp_piece_y = find_piece(im_temp)
        debug.computing_error(press_time, board_x, board_y, piece_x, piece_y, temp_piece_x, temp_piece_y)

        if debug_switch:
            debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x, board_y)
            debug.save_debug_screenshot(ts, im_temp, temp_piece_x, temp_piece_y, board_x, board_y)
            # debug.backup_screenshot(ts)
        i = 0
        if i == next_rest:
            print('已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time))
            for j in range(next_rest_time):
                sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j))
                sys.stdout.flush()
                time.sleep(1)
            print('\n继续')
            i, next_rest, next_rest_time = 0, random.randrange(30, 100), random.randrange(10, 60)
        time.sleep(random.uniform(0.5, 0.6))  # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban
예제 #3
0
def main():
    ai.init()

    print('程序版本号:{}'.format(VERSION))
    debug.dump_device_info()
    check_screenshot()

    i, next_rest, next_rest_time = 0, random.randrange(3,
                                                       10), random.randrange(
                                                           5, 10)
    while True:
        pull_screenshot()
        im = Image.open('./autojump.png')
        # 获取棋子和 board 的位置
        piece_x, piece_y, board_x, board_y = find_piece_and_board(im)
        ts = int(time.time())
        # print(ts, piece_x, piece_y, board_x, board_y)
        set_button_position(im)
        press_time = jump(
            math.sqrt((board_x - piece_x)**2 + (board_y - piece_y)**2))

        # 在跳跃落下的瞬间 摄像机移动前截图 这个参数要自己校调
        time.sleep(0.04)
        pull_screenshot_temp()
        im_temp = Image.open('./autojump_temp.png')
        temp_piece_x, temp_piece_y = find_piece(im_temp)
        debug.computing_error(press_time, board_x, board_y, piece_x, piece_y,
                              temp_piece_x, temp_piece_y)

        if debug_switch:
            debug.save_debug_screenshot(ts, im, piece_x, piece_y, board_x,
                                        board_y, "d")
            debug.save_debug_screenshot(ts, im_temp, temp_piece_x,
                                        temp_piece_y, board_x, board_y, "t")
            # debug.backup_screenshot(ts)
        # i = 0
        # if i == next_rest:
        # print('已经连续打了 {} 下,休息 {}s'.format(i, next_rest_time))
        # for j in range(next_rest_time):
        #     sys.stdout.write('\r程序将在 {}s 后继续'.format(next_rest_time - j))
        #     sys.stdout.flush()
        #     time.sleep(1)
        # print('\n继续')
        # i, next_rest, next_rest_time = 0, random.randrange(1, 5), random.randrange(2, 6)
        time.sleep(random.uniform(1.0, 1.5))  # 为了保证截图的时候应落稳了,多延迟一会儿,随机值防 ban