手机网站首页怎么做教育类网站 前置审批
手机网站首页怎么做,教育类网站 前置审批,PHP+Ajax网站开发典型实例,网上学电脑培训中心#-*- coding: utf-8 -*- 思路 核心#xff1a;每次落稳之后截图#xff0c;根据截图算出棋子的坐标和下一个块顶面的中点坐标#xff0c;根据两个点的距离乘以一个时间系数获得长按的时间识别棋子#xff1a;靠棋子的颜色来识别位置#xff0c;通过截图…#-*- coding: utf-8 -*- 思路 核心每次落稳之后截图根据截图算出棋子的坐标和下一个块顶面的中点坐标根据两个点的距离乘以一个时间系数获得长按的时间识别棋子靠棋子的颜色来识别位置通过截图发现最下面一行大概是一条直线就从上往下一行一行遍历比较颜色(颜色用了一个区间来比较)找到最下面的那一行的所有点然后求个中点求好之后再让 Y 轴坐标减小棋子底盘的一半高度从而得到中心点的坐标识别棋盘靠底色和方块的色差来做从分数之下的位置开始一行一行扫描由于圆形的块最顶上是一条线方形的上面大概是一个点所以就用类似识别棋子的做法多识别了几个点求中点这时候得到了块中点的 X轴坐标这时候假设现在棋子在当前块的中心根据一个通过截图获取的固定的角度来推出中点的 Y 坐标最后根据两点的坐标算距离乘以系数来获取长按时间(似乎可以直接用 X 轴距离)from __future__ importprint_function, divisionimportosimportsysimporttimeimportmathimportrandomfrom PIL importImageimportsubprocess#分数y坐标under_game_score_y 300#长按的时间系数请自己根据实际情况调节press_coefficient 1.392#二分之一的棋子底座高度可能要调节piece_base_height_1_2 20#棋子的宽度比截图中量到的稍微大一点比较安全可能要调节piece_body_width 70defset_button_position(im):将 swipe 设置为 再来一局 按钮的位置globalswipe_x1, swipe_y1, swipe_x2, swipe_y2w, him.sizeleft int(w / 2)top int(1584 * (h / 1920.0))left int(random.uniform(left-50, left50))top int(random.uniform(top-10, top10)) #随机防 banswipe_x1, swipe_y1, swipe_x2, swipe_y2 left, top, left, topdefjump(distance):跳跃一定的距离press_time distance *press_coefficientpress_time max(press_time, 200) #设置 200ms 是最小的按压时间press_time int(press_time)cmd adb shell input swipe {x1} {y1} {x2} {y2} {duration}.format(x1swipe_x1,y1swipe_y1,x2swipe_x2,y2swipe_y2,durationpress_time)print(cmd)os.system(cmd)returnpress_timedeffind_piece_and_board(im):寻找关键坐标w, him.sizepiece_x_sum0piece_x_c0piece_y_max0board_x0board_y0scan_x_border int(w / 8) #扫描棋子时的左右边界scan_start_y 0 #扫描的起始 y 坐标im_pixel im.load()#以 50px 步长尝试探测 scan_start_yfor i in range(int(h / 3), int(h*2 / 3), 50):last_pixelim_pixel[0, i]for j in range(1, w):pixelim_pixel[j, i]#不是纯色的线则记录 scan_start_y 的值准备跳出循环if pixel !last_pixel:scan_start_y i - 50breakifscan_start_y:breakprint(scan_start_y: {}.format(scan_start_y))#从 scan_start_y 开始往下扫描棋子应位于屏幕上半部分这里暂定不超过 2/3for i in range(scan_start_y, int(h * 2 / 3)):#横坐标方面也减少了一部分扫描开销for j in range(scan_x_border, w -scan_x_border):pixelim_pixel[j, i]#根据棋子的最低行的颜色判断找最后一行那些点的平均值这个颜#色这样应该 OK暂时不提出来if (50 pixel[0] 60) \and (53 pixel[1] 63) \and (95 pixel[2] 110):piece_x_sumjpiece_x_c 1piece_y_maxmax(i, piece_y_max)if notall((piece_x_sum, piece_x_c)):return0, 0, 0, 0piece_x int(piece_x_sum /piece_x_c)piece_y piece_y_max - piece_base_height_1_2 #上移棋子底盘高度的一半#限制棋盘扫描的横坐标避免音符 bugif piece_x w/2:board_x_startpiece_xboard_x_endwelse:board_x_start0board_x_endpiece_xfor i in range(int(h / 3), int(h * 2 / 3)):last_pixelim_pixel[0, i]if board_x orboard_y:breakboard_x_sum0board_x_c0for j inrange(int(board_x_start), int(board_x_end)):pixelim_pixel[j, i]#修掉脑袋比下一个小格子还高的情况的 bugif abs(j - piece_x) #修掉圆顶的时候一条线导致的小 bug这个颜色判断应该 OK暂时不提出来if abs(pixel[0] -last_pixel[0]) \ abs(pixel[1] - last_pixel[1]) \ abs(pixel[2] - last_pixel[2]) 10:board_x_sumjboard_x_c 1ifboard_x_sum:board_x board_x_sum /board_x_clast_pixelim_pixel[board_x, i]#从上顶点往下 274 的位置开始向上找颜色与上顶点一样的点为下顶点#该方法对所有纯色平面和部分非纯色平面有效对高尔夫草坪面、木纹桌面、#药瓶和非菱形的碟机(好像是)会判断错误for k in range(i274, i, -1): #274 取开局时最大的方块的上下顶点距离pixel im_pixel[board_x, k]if abs(pixel[0] -last_pixel[0]) \ abs(pixel[1] - last_pixel[1]) \ abs(pixel[2] - last_pixel[2]) 10:breakboard_y int((ik) / 2)#如果上一跳命中中间则下个目标中心会出现 r245 g245 b245 的点利用这个#属性弥补上一段代码可能存在的判断错误#若上一跳由于某种原因没有跳到正中间而下一跳恰好有无法正确识别花纹则有#可能游戏失败由于花纹面积通常比较大失败概率较低for j in range(i, i200):pixelim_pixel[board_x, j]if abs(pixel[0] - 245) abs(pixel[1] - 245) abs(pixel[2] - 245) 0:board_y j 10breakif notall((board_x, board_y)):return0, 0, 0, 0returnpiece_x, piece_y, board_x, board_ydefpull_screenshot():os.system(adb shell screencap -p /sdcard/1.png)os.system(adb pull /sdcard/1.png .)defcheck_screenshot():#检查获取截图的方式if os.path.isfile(1.png):os.remove(1.png)pull_screenshot()Image.open(./1.png).load()defmain():check_screenshot()i, next_rest, next_rest_time (0, random.randrange(3, 10),random.randrange(5, 10))whileTrue:pull_screenshot()im Image.open(./1.png)#获取棋子和 board 的位置piece_x, piece_y, board_x, board_y find_piece_and_board(im)tsint(time.time())print(ts, piece_x, piece_y, board_x, board_y)set_button_position(im)jump(math.sqrt((board_x- piece_x) ** 2 (board_y - piece_y) ** 2))im.close()i 1if i next_rest:print(已经连续打了 {} 下休息 {}s.format(i, next_rest_time))for j inrange(next_rest_time):sys.stdout.write(\r程序将在 {}s 后继续.format(next_rest_time -j))sys.stdout.flush()time.sleep(1)print(\n继续)i, next_rest, next_rest_time (0, random.randrange(30, 100),random.randrange(10, 60))#为了保证截图的时候应落稳了多延迟一会儿随机值防 bantime.sleep(random.uniform(0.9, 1.2))if __name__ __main__:main()
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/89699.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!