首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

诶 本人还是决定把Python脚本施舍给你们了

这年头,猫说不定玩的都比你好

画质极差,凑活看看吧

真机运行

脚本如下:

defscreenshot():

cmd ='adb shell screencap -p /sdcard/1.png'

os.system(cmd)

cmd ='adb pull /sdcard/1.png'

os.system(cmd)

-------------------------------------------------------------------------------------------

#开始查找棋子的坐标,从start_y开始据目测棋子不会位于屏幕底部1/3处

foriinrange(start_y,int(height *2/3)):

forjinrange(border_x, width - border_x):#删除周围空白部分,加快程序运行速度

next_point = im[j,i]

#根据棋子的颜色判断,求所有点的和然后求平均值

if(50< next_point[]

x1_temp += j#点求和

x1_num +=1#点的个数

y1_max =max(i, y1_max)

--------------------------------------------------------------------------------------------

ifnotall((x1_temp,x1_num)):

return,,,

x1 = x1_temp / x1_num

y1 = y1_max -piece_height/2#棋子Y轴坐标上移到底盘高度的一半

#查找下一个棋盘的位置

foriinrange(start_y, height *2/3):

start_point = im[, i]

ifx2 or y2:

break

x2_temp =

x2_num =

forjinrange(width):

next_point = im[j,i]

ifabs(j - x1) < body_width:

continue

#棋盘为圆

ifabs(next_point[] - start_point[]) +abs(next_point[1] - start_point[1]) +abs(next_point[2] - start_point[2]) >10:

x2_temp += j

x2_num +=1

ifx2_temp:

x2 = x2_temp / x2_num

#按实际的角度通过tan值来算计算下一个棋盘的中心点的Y轴坐标

y2 = y1 -abs(x2 - x1) *abs(sample_y1 - sample_y2) /abs(sample_x1 - sample_x2)

ifnotall((x2, y2)):

return,,,

#跳到下一个棋盘

defjump(distance):

press_time = distance * press

press_time = max(press_time,200)#设置最小的按压时间位200ms

press_time = int(press_time)

cmd ='adb shell inputswipe {} {} {} {} {}'.format(swipe_x1,swipe_y1, swipe_x2, swipe_y2, press_time)

print(cmd)

os.system(cmd)

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180107G0NZBY00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券