Guest User

Untitled

a guest
Jul 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. from AI.base import *
  2. from pygame.math import Vector2 as Vec
  3.  
  4. import random
  5. def Distance(pos1, pos2):
  6. return ( (pos1[0] - pos2[0])**2 + (pos1[1] - pos2[1])**2 ) ** 0.5
  7. def AddVector(a, b):
  8. return a[0] + b[0] , a[1] + b[1]
  9. class TeamAI( BaseAI ):
  10. def __init__( self , helper ):
  11. self.helper = helper
  12. self.skill = [1,1,0,1,1,1,1]
  13.  
  14. def decide( self ):
  15. helper = self.helper
  16. dash_dis=helper.dash_speed*helper.dash_time
  17. hPos = helper.getMyHeadPos()
  18.  
  19. after_dash_Pos_center = helper.getDashPos()
  20. MyDir = helper.getMyDir()
  21. bullet_Pos = helper.getAllPlayerBullet()
  22. cooltime = helper.dash_cool
  23. allBodyPos = helper.getAllBodyPos()
  24. body_lst = helper.getMyBodyPos()
  25. num_body = 0 if body_lst is None else len(body_lst)
  26. # By girls
  27. # Skills
  28.  
  29. score = 0
  30. for i in range(0, 4):
  31. score += helper.getPlayerScore(i)
  32.  
  33. if score == 0 and self.skill[5]:
  34. return AI_ExSpecHarmony
  35.  
  36. if num_body > 5 and self.skill[3]:
  37. return AI_NuclFission
  38.  
  39. if score == 24 and self.skill[6]:
  40. return AI_GravResonance
  41.  
  42. if score / 6 == 1 and self.skill[1]:
  43. return AI_MultiBullet
  44.  
  45. if score / 6 == 2 and self.skill[4]:
  46. return AI_HypSniping
  47.  
  48.  
  49. can_eat = helper.canGetByExplosion(hPos)
  50.  
  51. for i in range(4):
  52. if i == helper.getMyIndex():
  53. continue
  54. if helper.getPlayerBodyPos(i) is None:
  55. continue
  56. for _pos in helper.getPlayerBodyPos(i):
  57. if Distance(_pos, hPos) < helper.explosive_radius:
  58. can_eat += 1
  59.  
  60. if can_eat >= 5 and self.skill[0]:
  61. return AI_Explosion
  62.  
  63. # OAO
  64. wb_radius = helper.getWhiteballRadius()
  65. if helper.getOtherBulletNumInRange(hPos, 10 * wb_radius) > 0:
  66. return AI_MoveWayChange
  67. if not helper.checkMeInGrav():
  68.  
  69. #after_dash_Pos_center[0] += cooltime * MyDir[0]
  70. #after_dash_Pos_center[1] += cooltime * MyDir[1]
  71.  
  72. if after_dash_Pos_center:
  73. after_dash_Pos_center = after_dash_Pos_center[0] + cooltime * MyDir[0], after_dash_Pos_center[1] + cooltime * MyDir[1]
  74.  
  75. for i in bullet_Pos:
  76. if not i[1][0] == after_dash_Pos_center[0] or not i[1][1] == after_dash_Pos_center[1]:
  77. return AI_NothingToDo
  78.  
  79. if hPos[0]>750 or hPos[0]<50 or hPos[1]>750 or hPos[1]<50:
  80. for i in allBodyPos:
  81. if abs(hPos[0]-i[0])<50 and abs(hPos[1]-i[1])<50:
  82. return AI_MoveWayChange
  83. for i in bullet_Pos:
  84. if abs(hPos[0]-i[1][0])<50 and abs(hPos[1]-i[1][1])<50:
  85. return AI_MoveWayChange
  86. else:
  87. return AI_NothingToDo
  88.  
  89. if helper.bodyOnRoute():
  90. body_dis=helper.bodyOnRoute()
  91. for i in body_dis:
  92. dis=(i[0]-hPos[0])*(i[0]-hPos[0])+(i[1]-hPos[1])*(i[1]-hPos[1])
  93. if dis<dash_dis*dash_dis:
  94. return AI_MoveWayChange
  95. if helper.headOnRoute():
  96. head_dis=helper.headOnRoute()
  97. for i in head_dis:
  98. dis=(i[0]-hPos[0])*(i[0]-hPos[0])+(i[1]-hPos[1])*(i[1]-hPos[1])
  99. if dis<dash_dis*dash_dis:
  100. return AI_MoveWayChange
  101. else :
  102. if helper.bodyOnRoute() or helper.headOnRoute():
  103. return AI_MoveWayChange
  104. if helper.checkMeCircling() and helper.canGetBySpin() == 0:
  105. return AI_MoveWayChange
  106. if not helper.checkMeCircling() and helper.canGetBySpin() > 0:
  107. return AI_MoveWayChange
  108. return AI_NothingToDo
Add Comment
Please, Sign In to add comment