def round1(): # 点击主力队2次 Headquarters_1() Delay(1, 2) Headquarters_1() Delay(1, 2) # 补充弹药 CombatWindow.Supply() # 移动到左下机场 pot1_1() # 战斗 Delay(16, 18) CombatWindow.Combat_EndClear() # 部署守家队伍 # 取消选择 CombatWindow.Choose_Cancel() # 点击指挥部 Headquarters_2() Delay(1, 2) # 点击确定,部署梯队 CombatWindow.Deploy_Confirm() # 点击守家队2次 Headquarters_2() Delay(1, 2) Headquarters_2() Delay(1, 2) # 补充弹药 CombatWindow.Supply() # 结束回合 CombatWindow.Round_End() Delay(4, 5) # 检测是否进入下一回合 matching = image.match( 'e:/code/girls_frontline_script/images/round_end.png', image.capture_screen()) # 未进入下一回合 if (matching[0] < 100000000): Delay(22, 23) CombatWindow.Combat_EndClear() Delay(6, 7) # 检测是否进入下一回合 matching = image.match( 'e:/code/girls_frontline_script/images/round_end.png', image.capture_screen()) # 未进入下一回合 if (matching[0] < 100000000): Delay(22, 23) CombatWindow.Combat_EndClear() Delay(6, 7)
def ransac(points1, features1, points2, features2, round_count=1000): ''' computes the transformation matrix from img1 to img2 using ransac algorithm ''' matches = image.match(features1, features2) match_count = len(matches) print(match_count) hypotheses = [] points1 = np.array([[p.pt[0], p.pt[1]] for p in points1]) points2 = np.array([[p.pt[0], p.pt[1]] for p in points2]) for r in trange(round_count): try: indices = np.random.choice(range(match_count), 4, replace=False) print(indices) sample_matches = [matches[i] for i in indices] sample_points1, sample_points2 = zip( *[[points1[first], points2[second]] for first, second, _ in sample_matches]) T = projective(sample_points1, sample_points2) votes = compute_agreement(T, points1, points2) except np.linalg.LinAlgError: pass else: hypotheses.append((T, sample_points1, sample_points2, votes)) return max(hypotheses, key=itemgetter(3))
def round1(): # 主力队补充弹药 Headquarters() Delay(1, 2) Headquarters() Delay(1, 2) CombatWindow.Supply() # 前进 pot1_1() Delay(2, 3) CombatWindow.Choose_Cancel() # 部署守家队并补充弹药 Headquarters() Delay(1, 2) CombatWindow.Deploy_Confirm() Headquarters() Delay(1, 2) Headquarters() Delay(1, 2) CombatWindow.Supply() # 结束回合 CombatWindow.Round_End() Delay(19, 20) # 检测是否进入下一回合 matching = image.match('e:/code/girls_frontline_script/images/round_end.png', image.capture_screen()) # 未进入下一回合 if (matching[0] < 100000000): Delay(15, 16) CombatWindow.Combat_EndClear() Delay(6, 7)
def round4(): # 往上拖动界面 moveTo(randint(1400, 1600), randint(250, 400)) dragRel(randint(-50, 50), randint(400, 500), 0.5) Delay(0, 1) Airport() Delay(1, 2) Airport() Delay(1, 2) CombatWindow.Supply() CombatWindow.PlanMode() pot4_1() Delay(1, 2) CombatWindow.Plan_Confirm() Delay(54, 56) while(1): # 检测是否在战斗中 matching = image.match('e:/code/girls_frontline_script/images/round_end.png', image.capture_screen()) # 战斗中 if (matching[0] < 100000000): Delay(1, 2) else: break CombatWindow.Round_End() Delay(12, 14) CombatWindow.Combat_Animation()
def round2(): # 守家梯队撤退 Headquarters_2() Delay(1, 2) Headquarters_2() Delay(1, 2) CombatWindow.Retreat() # 选择主力队 pot1_2() Delay(1, 2) # 检测小飞机 matching = image.match( 'e:/code/girls_frontline_script/images/Combat/34n_fly.png', image.capture_screen()) if (matching[0] > 20000000): CombatWindow.Fairy_release() pot2_2() Delay(18, 19) CombatWindow.Combat_EndClear() pot2_2() Delay(1, 2) # 检测小飞机 matching = image.match( 'e:/code/girls_frontline_script/images/Combat/34n_fly.png', image.capture_screen()) if (matching[0] > 20000000): CombatWindow.Fairy_release() pot3_2() Delay(18, 19) CombatWindow.Combat_EndClear() pot3_2() Delay(1, 2) # 检测boss matching = image.match( 'e:/code/girls_frontline_script/images/34n_boss.png', image.capture_screen()) # boss出现 if (matching[0] > 20000000): pot4_2() else: pot5_2() Delay(1, 2) pot6_2() Delay(19, 20) CombatWindow.Combat_EndClear() # 撤退 CombatWindow.Combat_Terminate()
def round3(): CombatWindow.Round_End() Delay(21, 22) CombatWindow.Combat_EndClear() Delay(3, 4) # 检测是否进入战斗 matching = image.match('e:/code/girls_frontline_script/images/round_end.png', image.capture_screen()) # 进入战斗 if (matching[0] < 100000000): Delay(11, 12) CombatWindow.Combat_EndClear() Delay(6, 7)
def round2(): # 主力队上前 pot1_1() Delay(1, 2) pot2_1() Delay(2, 3) # 检测是否进入战斗 matching = image.match('e:/code/girls_frontline_script/images/round_end.png', image.capture_screen()) # 进入战斗 if (matching[0] < 100000000): Delay(13, 14) CombatWindow.Combat_EndClear() # 部署狗粮 Headquarters() Delay(1, 2) pot1_1() Delay(2, 3) CombatWindow.Choose_Cancel() Headquarters() Delay(1, 2) CombatWindow.Deploy_Confirm() # 交换 Headquarters() Delay(1, 2) pot1_1() Delay(1, 2) click(randint(685, 861), randint(560, 623)) Delay(2, 3) CombatWindow.Choose_Cancel() CombatWindow.PlanMode() pot2_1() Delay(1, 2) Airport() Delay(1, 2) CombatWindow.Choose_Cancel() pot1_1() Delay(1, 2) pot3_1() Delay(1, 2) CombatWindow.Plan_Confirm() Delay(67, 68)
points2, features2 = image.orb_features(image.to_grayscale(img2), length=1000) ''' plt.subplot(1,2,1) plt.imshow(cv2.cvtColor(img1, cv2.COLOR_BGR2RGB)) plt.scatter([point.pt[0] for point in points1], [point.pt[1] for point in points1], c='r', s=40) plt.subplot(1,2,2) plt.imshow(cv2.cvtColor(img2, cv2.COLOR_BGR2RGB)) plt.scatter([point.pt[0] for point in points2], [point.pt[1] for point in points2], c='r', s=40) plt.show() ''' #T, points1, points2, votes = transform.ransac(points1, features1, points2, features2) #T = transform.change_axis_system(T) matches = image.match(features1, features2) plt.subplot(1, 2, 1) plt.imshow(cv2.cvtColor(img1, cv2.COLOR_BGR2RGB)) plt.scatter([points1[m[0]].pt[0] for m in matches], [points1[m[0]].pt[1] for m in matches], s=40) plt.subplot(1, 2, 2) plt.imshow(cv2.cvtColor(img2, cv2.COLOR_BGR2RGB)) plt.scatter([points2[m[0]].pt[0] for m in matches], [points2[m[1]].pt[1] for m in matches], s=40) plt.show()