开局托儿所破解!!!!(基于airscript,python)!!

演示           

本想放视频,可airscrpt跑的时候要用屏幕,在录视频两个进程其冲突,所以录视频失败!!

所以展示运行图片,具体运行可以看airscript官网,这里主要用到了找图的功能,用这功能去识别手机中16*10的数字矩阵,然后用算法去实现效果(slide滑动)

这里的算法比较简单

   

最高分可得122,最少可得90+

其中1,2,3到9的图片为数字图片:

如图

图片资源:如下:

链接:https://pan.baidu.com/s/1cicMXdSh7e37dwrsHDp2_A?pwd=k66j 
提取码:k66j

代码在:

# __init__.py 为初始化加载文件

#导入-资源路径规划库
from airscript.system import R
from airscript.action import slide
#导入-节点检索库
from airscript.node import Selector

#导入-屏幕检索库
from airscript.screen import FindColors # 找色
from airscript.screen import CompareColors # 比色
from airscript.screen import FindImages # 找图
from airscript.screen import Ocr # 文字识别
import time
print('开始了')
dic = []
for j in range(1,10):
    ress = FindImages(R(__file__).res(f"/img/{j}.png")).confidence(0.9).find_all()
    for i in ress:
        # print(i)
        temp  = {}
        temp['value'] = j
        temp['loc'] = i['result']
        dic.append(temp)

count = 0
for i in dic:
    count+=i['value']

print(count)
if len(dic)!=160:
    print("error")
    exit(1)
else:
    dic.sort(key=lambda x: [x['loc'][1]])
    map = []
    for i in range(16):
        temp = dic[i*10:(i+1)* 10]
        map.append(sorted(temp,key=lambda x:x['loc'][0]))


        # print(i)


def drag(x1,y1,x2,y2):
    print(x1,y1,'->',x2,y2)
    clear(x1,y1,x2,y2)
    slide(map[x1][y1]['loc'][0],map[x1][y1]['loc'][1],map[x2][y2]['loc'][0],map[x2][y2]['loc'][1],200)
    time.sleep(0.5)
    pass
def clear(x1,y1,x2,y2):
    for i in range(x1,x2+1):
        for j in range(y1,y2+1):
            map[i][j]['value'] = 0
def sumtt(i,j,x,y):
    res =0
    for x1 in range(i,x+1):
        for y1 in range(j,y+1):
            res+=map[x1][y1]['value']
    return res

for i in map:
    print(i)
change = True
while change == True:  # 循环直到没有可以消除的
    change = False
    for i in range(16):
        for j in range(10):
            flag = False
            row_list = []
            column_list = []
            #横向消除
            count  = map[i][j]['value']
            for k in range(j+1,10):
                count+=map[i][k]['value']
                if count<10:
                    row_list.append(k)
                elif count==10:
                    drag(i,j,i,k)  #移动
                    change = True
                    flag = True
                    break
                else:
                    break
            #         纵向消除
            count = map[i][j]['value']
            for k in range(i+ 1, 16):
                count += map[k][j]['value']
                if count < 10:
                    row_list.append(k)
                elif count == 10:
                    drag(i, j, k, j)  # 移动
                    change = True
                    flag = True
                    break
                else:
                    break
            # 代表横向或纵向已经消除过,斜向就不搞了
            if flag:
                continue
            for x in column_list:
                for y in row_list:
                    res = sumtt(i,j,x,y)
                    if res == 10:
                        drag(i,j,x,y)
                        change=True
                        flag = True
                        break
                if flag:
                    break

for i in map:
    print(i)

  • 7
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值