android怎么实现数独游戏机器人
发表于:2025-11-12 作者:千家信息网编辑
千家信息网最后更新 2025年11月12日,本篇内容介绍了"android怎么实现数独游戏机器人"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!针
千家信息网最后更新 2025年11月12日android怎么实现数独游戏机器人
本篇内容介绍了"android怎么实现数独游戏机器人"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
针对该应用的数独机器人

填答案逻辑未完成,主要原因在于游戏响应触屏事件参数有待调整,简单的使用input tap,界面响应不正常。
import sys posinfo0={(0,0):8, (2,1):3,(3,1):6, (1,2):7,(4,2):9,(6,2):2, (1,3):5,(5,3):7, (4,4):4,(5,4):5,(6,4):7, (3,5):1,(7,5):3, (2,6):1,(7,6):6,(8,6):8, (2,7):8,(3,7):5,(7,7):1, (1,8):9,(6,8):4, }maskmap={1535553906:5,2441400:7,305175776:1,2746585781:6,1577050781:9,2756722681:8,1586816406:9,2756351406:6,2993066431:2,2758694531:3,1535569531:5,2756738306:8,1528222656:9,1525882656:6,2942285181:2,1535944531:5,1232906556:4,2709863281:3,1525882031:6,2707910181:8,1535960156:5,1477441406:9,2944238306:2,1525878901:1,2707910156:3,1477050781:6,2758691406:3,3002832056:2,2705941436:8,1242672181:4,1535647656:5,2705957686:8,1479394531:9,1487191406:3,2707894556:8,502832031:2,2705941431:8,} def ocr(img): global posinfo0, maskmap posinfo0={} for x in xrange(0,9): for y in xrange(0,9): x0=(x/3)*(257-26)+(x%3)*(96-26)+26 y0=(y/3)*(432-179)+(y%3)*(255-179)+179 x1=x0+(88-26) y1=y0+(240-179) dig=img.crop((x0,y0,x1,y1)) throd=100 res=0 for marg_left in xrange(0,dig.size[0]/2+2): for t in xrange(0,dig.size[1]): if dig.getpixel((marg_left, t))[0]=marg_right: #print "(%d,%d):%d"%(x,y,res) continue mask=0 bitcnt=1 dig=dig.crop((marg_left,marg_top,marg_right,marg_bottom)) olddirect=0 direct=0 for digy in xrange(dig.size[1]/8,dig.size[1], dig.size[1]/8): cnt=0 for digx in xrange(0,dig.size[0]-1): if dig.getpixel((digx, digy))[0]>throd and dig.getpixel((digx+1, digy))[0]<=throd: cnt+=1 mask+=cnt*bitcnt bitcnt*=5 for digx in xrange(dig.size[0]/6,dig.size[0], dig.size[0]/6): cnt=0 for digy in xrange(0,dig.size[1]-1): if dig.getpixel((digx, digy))[0]>throd and dig.getpixel((digx, digy+1))[0]<=throd: cnt+=1 mask+=cnt*bitcnt bitcnt*=5 if mask not in maskmap: dig.save("tmp/%d_%d_%d.png"%(mask,x,y)) val=raw_input("%d:"%mask) maskmap[mask]=int(val) if mask in maskmap: #print "(%d,%d):%d"%(x,y,maskmap[mask]) posinfo0[(x,y)]=maskmap[mask] #484 677 def scan(): os.system("adb shell screencap /mnt/sdcard/shudu.png") os.system("adb pull /mnt/sdcard/shudu.png") img=Image.open("shudu.png") ocr(img) from copy import deepcopyfrom time import clock posb0={} def init(posb, posinfo): for i in xrange(0,9): for j in xrange(0,9): if (i,j) not in posinfo: posb[(i,j)]=[n for n in xrange(1,10)] for pos in posinfo: cleanother(0,pos[0],pos[1],posinfo[pos],posb,posinfo) def checkpos(posb, posinfo): posb1=posb.copy() posinfo1=posinfo.copy() ret=0 for pos in posb: if len(posb1[(pos[0],pos[1])])==1: addinfo(pos[0],pos[1],posb1[(pos[0],pos[1])][0],posb1,posinfo1) ret=1 break elif len(posb1[(pos[0],pos[1])])==0: ret=2 break posb=posb1 posinfo=posinfo1 return ret def cleanother(mod,x,y,v,posb,posinfo): posb1=posb.copy() x0=x/3*3 y0=y/3*3 for ii in xrange(0,3): for jj in xrange(0,3): if (x0+ii,y0+jj) in posb: if v in posb1[(x0+ii,y0+jj)]: posb1[(x0+ii,y0+jj)].remove(v) for ii in xrange(0,9): if (ii,y) in posb: if v in posb1[(ii,y)]: posb1[(ii,y)].remove(v) for jj in xrange(0,9): if (x,jj) in posb: if v in posb1[(x,jj)]: posb1[(x,jj)].remove(v) ret=0 if posb1!=posb: ret = checkpos(posb1,posinfo) posb=posb1 return ret def findmin(posb): minv=9 minpos=(0,0) for key,val in posb.items(): if minv>len(val): minv=len(val) minpos=key return (minv,minpos) def outputInfo(posinfo): print "\n %s"%" ".join(str(v) for v in xrange(0,9)) print "-----------"*2 for i in xrange(0,9): print "%d|"%i, for j in xrange(0,9): if (j,i) in posinfo: print posinfo[(j,i)], else: print " ", print print "==========="*2 def addinfo(x,y,v,posb,posinfo): if (x,y) in posinfo:return #print "addinfo",x,y,v if (x,y) in posb: del posb[(x,y)] posinfo[(x,y)]=v clearallinfo(posb,posinfo) #outputInfo(posinfo) def clearallinfo(newposb, newposinfo): newposinfo2=newposinfo.copy() for pos in newposinfo: cleanother(0,pos[0],pos[1],newposinfo[pos],newposb,newposinfo2) if newposinfo2==newposinfo: return newposinfo=newposinfo2 #print "newposinfo" #outputInfo(newposinfo) clearallinfo(newposb, newposinfo) def clickscreen(pos0, lastpos): for i in xrange(0,9): print "%d|"%i, for j in xrange(0,9): if (j,i) in lastpos and (j,i) not in pos0: print lastpos[(j,i)], x0=(j/3)*(257-26)+(j%3)*(96-26)+26 y0=(i/3)*(432-179)+(i%3)*(255-179)+179 x1=x0+(88-26)/2 y1=y0+(240-179)/2 #os.system("adb shell input tap %d %d"%(x1,y1)) #raw_input("press...") #time.sleep(0.1) #os.system("adb shell input tap %d %d"%(lastpos[(j,i)]*80-40,980)) #time.sleep(0.1) #raw_input("press...") else: print " ", print def tryonestep(minpos, posb, posinfo, layer): global tic for posbv in posb[minpos]: newposb=deepcopy(posb) newposinfo=posinfo.copy() addinfo(minpos[0],minpos[1],posbv,newposb,newposinfo) minv2,minpos2=findmin(newposb) if minv2==0: #print "impossible!!!", layer continue if len(newposb)==0: print "Got it!!!" outputInfo(newposinfo) clickscreen(posinfo0, newposinfo) exit(0) tryonestep(minpos2, newposb, newposinfo, layer+1) scan() init(posb0, posinfo0) minv,minpos=findmin(posb0) print "start===>"outputInfo(posinfo0)newposb=posb0.copy()newposinfo=posinfo0.copy()tryonestep(minpos, newposb, newposinfo, 0)print "No answer!!" "android怎么实现数独游戏机器人"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!
机器
机器人
内容
更多
知识
实用
学有所成
接下来
事件
原因
参数
困境
实际
情况
文章
案例
界面
编带
网站
行业
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
vb的ftp服务器
java初级数据库面试题
中国讯牛网络技术有限公司
文件服务器有病毒吗
湘潭互联网科技公司排名
windows服务器模式
互联网科技新型犯罪手段
数据库的详细工作流程
徐州电子网络技术收费
数据库设计数据存储
国际网络安全厂商
网络安全专业能上班吗
数据库转换线
深圳市商帮网络技术有限公司
北京erp软件开发机构
服务器行业组装平台
网络安全管理和运维
济源市衷网络技术有限公司
淮安智能刀片服务器价格
云服务器应用提供商
数据库文件锁定
高科技与互联网专业
日照联想服务器代理测评
与国际软件开发工具比较
酷米数据库
艾尔登法环 服务器通用吗
饥荒 专用服务器 保存
计算机三级网络安全考试题型
罗克韦尔软件开发
各个数据库的收录范围及特点