当前位置:手机游戏 > 手游资讯 > 新手问答 > 跳一跳刷分(全自动刷分跳一跳)

跳一跳刷分(全自动刷分跳一跳)

作者:佚名 来源:哪吒游戏网 2020-03-17 20:04:46

跳一跳刷分(全自动刷分跳一跳),哪吒游戏网给大家带来详细的跳一跳刷分(全自动刷分跳一跳)介绍,大家可以阅读一下,希望这篇跳一跳刷分(全自动刷分跳一跳)可以给你带来参考价值。

前天看到了 教你用Python来玩微信跳一跳 这篇文章,心想如果能做成全自动的刷分脚本该多好,于是开始挖坑。。。

主要思路是用模板匹配找出小人位置,再用漫水填充去除背景,然后从上往下扫描到不是背景的第一个像素,根据小人坐标的x坐标和目标像素x坐标之差作为按的时间长短的依据。

但是由于去除背景后存在噪点,直接使用第一个不为背景的像素,在某些圆形平台上效果不佳。假设该像素为(x, y),那么我会在纵坐标y+15上从两边向中间扫描找出左右边界,取它们的中点作为目标target_x。

代码如下

# -*- encoding: utf-8 -*-
#
# Created on: Sat Dec 30 20:25:18 2017
import os
import wda
import cv2
import time
import numpy as np
from PIL import Image
from matplotlib import pyplot as plt
c = wda.Client('http://192.168.1.101:8100')
s = c.session()
template = cv2.imread('/Users/qq456cvb/Desktop/template.bmp')
hh, ww, _ = template.shape
print(hh)
print(ww)
kernel = np.ones((3,3),np.uint8)
for _ in range(10000):
    time.sleep(1.5)
    img = c.screenshot('1.bmp')
    img = np.array(Image.open('1.bmp'))
    img = img[:, :, ::-1].copy() 
    h, w, _ = img.shape
    img2 = img.copy()
    mask = np.zeros((h+2, w+2), np.uint8)
    cv2.floodFill(img2, mask, (0, 0), (0, 0, 0), (3, 3, 3), (4, 2, 2))
    # find actor
    res = cv2.matchTemplate(img,template,cv2.TM_CCORR_NORMED)
    min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
    for i in range(max_loc[1] + hh // 2 - 40, max_loc[1] + hh // 2 + 180):
        for j in range(max_loc[0] + ww // 2 - 40, max_loc[0] + ww // 2 + 40):
            img2[i, j, :] = [0, 0, 0]
    img2 = cv2.erode(img2,kernel)
    
    found_x = 0
    found_y = 0
    for y in range(950, 1350, 2):
        found = False
        for x in range(w // 6, w - w // 6, 2):
            if not np.array_equal(img2[y, x, :], [0, 0, 0]):
                # found_x = x
                found_y = y
                found = True
                break
        if found:
            break
    print(found_y)
    
    n = 0
    for x in range(w // 6, w - w // 6):
        if not np.array_equal(img2[found_y + 15, x, :], [0, 0, 0]):
            found_x += x
            break
    for x in range(w - w // 6 - 1, w // 6, -1):
        if not np.array_equal(img2[found_y + 15, x, :], [0, 0, 0]):
            found_x += x
            break
    found_x //= 2
    cv2.line(img2, (found_x, 0), (found_x, h - 1), (0,0,255), 4)
    cv2.line(img2, (max_loc[0] + ww // 2, 0), (max_loc[0] + ww // 2, h - 1), (255, 0, 0), 4)
    img3 = cv2.pyrDown(img2)
    img3 = cv2.pyrDown(img3)
    cv2.imshow("test", img3)
    cv2.waitKey(30)
    print(max_loc[0])
    print(found_x)
    press_time = abs(found_x - (max_loc[0] + ww // 2)) / 655.5
    s.tap_hold(200,200,press_time)

这是我在iphoneX上的测试代码,当然你需要安装WebDriverAgent跳一跳刷分,来使用Python控制iOS。template图片是我截取的小人头部圆形中心的一块矩形区域,用来做模板匹配来得到小人位置,如下图:

其中倒数第二行的655.5是点按时间与x轴距离之间的线性系数,读者可根据准确性跳一跳刷分,机型不同自行调整。目前该脚本刷个几千分还是没有什么问题的,在后面越来越难的情况下也会极小概率失手,可能是我系数调得不好??

总结:以上内容就是针对跳一跳刷分(全自动刷分跳一跳)详细阐释,如果您觉得有更好的建议可以提供给哪吒游戏网小编,跳一跳刷分(全自动刷分跳一跳)部分内容转载自互联网,有帮助可以收藏一下。



上一篇: 跳一跳刷分(小游戏“跳一跳”刷屏后出现代玩服务 轻松刷分但有风险)

下一篇: dnf男弹药刷图加点([弹药]DNF弹药专家刷图加点心得)

本文标签: 跳一跳刷分 lol隐藏分和跳段 钻石隐藏分多少跳段
猜你喜欢