def check_jjc_prepare(img): btn = cat_img(img, 959, 1009, 241, 53) if (classify_hist_with_split(btn, jjcPrepareBtn) > 0.5): #竞技场准备 jjcArr = [[1469, 600], [959, 600], [449, 600]] #jjcArr = [[449,600]] for arr in jjcArr: target = cat_img(img, arr[0], arr[1], 100, 100) if (classify_hist_with_split(target, jjcHuozhadanImg) > 0.5): print("遇到火炸弹,点炸弹") #遇到火炸弹,点炸弹 m.click(arr[0], 600) time.sleep(0.2) return True #未遇到火炸弹,点最左 print("未遇到火炸弹,点中") m.click(jjcArr[1][0], 900) time.sleep(0.25) return True else: return False
def check_prepare(img): curPrepareBtn = cat_img(img, 952, 1010, 200, 50) if (classify_hist_with_split(curPrepareBtn, prepareBtn) > 0.5): #准备中 #重置敌方数组 reset_right_list() print("检查到准备中") #点击继续 m.click(1002, 1020) time.sleep(0.25) return True else: print("未检查到准备中") return False
def check_PVP(img): curRefreshBtn = cat_img(img, 960, 1010, 368, 96) rate = classify_hist_with_split(curRefreshBtn, refreshBtn) print("classify_hist_with_split(curRefreshBtn,refreshBtn)", rate) if (rate > 0.8): #识别到PVP #重置敌方数组 reset_right_list() print("检查到PVP") #点击继续 m.click(960, 540) time.sleep(0.25) return True else: print("未检查到PVP") return False
def check64(img, hArr, vArr): global uncheckedNum colorArr = [([0] * 8) for i in range(8)] imgSize = 76 for xIndex, xCenter in enumerate(hArr): for yIndex, yCenter in enumerate(vArr): imgPart = cat_img(img, xCenter, yCenter, imgSize, imgSize) # imgArr[yIndex][xIndex] = imgPart color = compare_color(imgPart) colorArr[yIndex][xIndex] = color if (not color) and (uncheckedNum < 5): uncheckedNum += 1 print(yIndex, xIndex, "未识别") return False # cv2.imwrite(str(yIndex)+str(xIndex)+".bmp",imgPart) # plt.imshow(imgPart) # plt.show() # print(yIndex,xIndex) # plt.imshow(imgArr[0][0]) # plt.show() print(colorArr) return colorArr
wImgPath = "base\\white.jpg" gImgPath = "base\\green.jpg" bImgPath = "base\\blue.jpg" pImgPath = "base\\purple.jpg" yImgPath = "base\\yellow.jpg" nImgPath = "base\\brown.jpg" rImg = cv2.imread(rImgPath) wImg = cv2.imread(wImgPath) gImg = cv2.imread(gImgPath) bImg = cv2.imread(bImgPath) pImg = cv2.imread(pImgPath) yImg = cv2.imread(yImgPath) nImg = cv2.imread(nImgPath) rImg = cat_img(rImg, 60, 60, 76, 76) wImg = cat_img(wImg, 60, 60, 76, 76) gImg = cat_img(gImg, 60, 60, 76, 76) bImg = cat_img(bImg, 60, 60, 76, 76) pImg = cat_img(pImg, 60, 60, 76, 76) yImg = cat_img(yImg, 60, 60, 76, 76) nImg = cat_img(nImg, 60, 60, 76, 76) #三消算法=============================================================================================== #查找最佳可消点 lastBombPoint = [[-1, -1], [-2, -2], [-3, -3]] def find_can_bomb_point(colorArr, weightMap={ 'w': 5,
def is_all_right_dead(img): centerImg = cat_img(img, 960, 540, 80, 80) return (classify_hist_with_split(centerImg, overImg) > 0.5)
#游戏内容相关方法 # import the module import cv2 import time from common.img_process import classify_hist_with_split, cat_img from pymouse import PyMouse m = PyMouse() #操作系统桌面 windowsImgPath = "base\\windows.png" windowsImg = cv2.imread(windowsImgPath) windowsImg = cat_img(windowsImg, 20, 1060, 40, 40) #主界面 mainPath = "base\\main.png" mainImg = cv2.imread(mainPath) #探索 准备界面 prepareImgPath = "base\\prepare.png" prepareImg = cv2.imread(prepareImgPath) prepareBtn = cat_img(prepareImg, 952, 1010, 200, 50) #pvp 休闲战 准备界面 jjcPrepareImgPath = "base\\jjc-prepare.png" #pvp 排位战 准备界面 realJjcPrepareImgPath = "base\\real-jjc-prepare.png" jjcPrepareImg = cv2.imread(realJjcPrepareImgPath) jjcPrepareBtn = cat_img(jjcPrepareImg, 959, 1009, 241, 53)