function dismissTile(colorNum) {//Find a square that can be eliminated
var webView=className("android.webkit.WebView").findOne(2000);
if(webView) { return false; } var tileName="xiong_mao_"+colorNum+" .jpg"; var imgList=findMultiImgMax(tileName,"xiong_mao_"+colorNum,0.7,30,false,false); tip("Number of squares:"+imgList.length); var indexList=[]; for(var i =0;i<imgList.length;i++) { var imgInfo=imgList[i]; var x=imgInfo.x; var y=imgInfo.y; //tip(i+" anchor x="+x+",y= "+y+",w="+imgInfo.width+",h="+imgInfo.height); uiUtil.addPointAppend(x,y,"#0000ff");//test var linkCount=0; /*
for(var j=0;j<imgList.length;j++) {
if(i==j) {
continue;
}
var nextImgInfo=imgList[j];
var nextX=nextImgInfo.x;
var nextY=nextImgInfo.y;
if(i==0) {
uiUtil.addPointAppend(nextX,nextY,"#00ff00");
}
//tip(j+" x="+nextX+",y="+nextY+",w="+nextImgInfo.width+",h="+nextImgInfo.height);
var isXValid=Math.abs(x-nextX)<imgInfo.width/2&&Math.abs(y-nextY)<imgInfo.height*1.5;//竖排
var isYValid=Math.abs(y-nextY)<imgInfo.height/2&&Math.abs(x-nextX)<imgInfo.width*1.5;//横排
//tip("isXValid="+isXValid+",isYValid="+isYValid);
if(isXValid||isYValid) {//Vertically adjacent, or horizontally adjacent
linkCount++;
}
}*/
if(linkCount>=0) {//There are too few 2, the main reason is that the recognition is not accurate. Click on all
//i squares to eliminate
indexList.push(i);
}else { tip("link="+linkCount); imgList.splice(i ,1);//Delete element i, is this usage? i--; } } if(indexList.length>0) { toast("All squares have been identified:"+indexList.length); sleep(2000); var targetIndex=random(0,indexList.length-1); for(var i=0;i<indexList.length; i++) {
var imgInfo=imgList[i];
var x=imgInfo.x;
var y=imgInfo.y;
//uiUtil.addPointAppend(x,y,"#ffff00");
click(x,y);
if(i%6 ==5) {//click a few times and then
sleep(2000);
//uiUtil.addPoint(x,y);
var openView=findImgOpen();
if(openView) { break; } } sleep(200); } uiUtil.deleteAllPoint(); return true; }else { tip("No reasonable squares that can be eliminated"); return false; } }
Classic Algorithm of Xiaoxiaole Model
Guess you like
Origin blog.csdn.net/yeziyfx/article/details/125055370
Recommended
Ranking