Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from AI.base import *
- from pygame.math import Vector2 as Vec
- import random
- def Distance(pos1, pos2):
- return ( (pos1[0] - pos2[0])**2 + (pos1[1] - pos2[1])**2 ) ** 0.5
- def AddVector(a, b):
- return a[0] + b[0] , a[1] + b[1]
- class TeamAI( BaseAI ):
- def __init__( self , helper ):
- self.helper = helper
- self.skill = [1,1,0,1,1,1,1]
- def decide( self ):
- helper = self.helper
- dash_dis=helper.dash_speed*helper.dash_time
- hPos = helper.getMyHeadPos()
- after_dash_Pos_center = helper.getDashPos()
- MyDir = helper.getMyDir()
- bullet_Pos = helper.getAllPlayerBullet()
- cooltime = helper.dash_cool
- allBodyPos = helper.getAllBodyPos()
- body_lst = helper.getMyBodyPos()
- num_body = 0 if body_lst is None else len(body_lst)
- # By girls
- # Skills
- score = 0
- for i in range(0, 4):
- score += helper.getPlayerScore(i)
- if score == 0 and self.skill[5]:
- return AI_ExSpecHarmony
- if num_body > 5 and self.skill[3]:
- return AI_NuclFission
- if score == 24 and self.skill[6]:
- return AI_GravResonance
- if score / 6 == 1 and self.skill[1]:
- return AI_MultiBullet
- if score / 6 == 2 and self.skill[4]:
- return AI_HypSniping
- can_eat = helper.canGetByExplosion(hPos)
- for i in range(4):
- if i == helper.getMyIndex():
- continue
- if helper.getPlayerBodyPos(i) is None:
- continue
- for _pos in helper.getPlayerBodyPos(i):
- if Distance(_pos, hPos) < helper.explosive_radius:
- can_eat += 1
- if can_eat >= 5 and self.skill[0]:
- return AI_Explosion
- # OAO
- wb_radius = helper.getWhiteballRadius()
- if helper.getOtherBulletNumInRange(hPos, 10 * wb_radius) > 0:
- return AI_MoveWayChange
- if not helper.checkMeInGrav():
- #after_dash_Pos_center[0] += cooltime * MyDir[0]
- #after_dash_Pos_center[1] += cooltime * MyDir[1]
- if after_dash_Pos_center:
- after_dash_Pos_center = after_dash_Pos_center[0] + cooltime * MyDir[0], after_dash_Pos_center[1] + cooltime * MyDir[1]
- for i in bullet_Pos:
- if not i[1][0] == after_dash_Pos_center[0] or not i[1][1] == after_dash_Pos_center[1]:
- return AI_NothingToDo
- if hPos[0]>750 or hPos[0]<50 or hPos[1]>750 or hPos[1]<50:
- for i in allBodyPos:
- if abs(hPos[0]-i[0])<50 and abs(hPos[1]-i[1])<50:
- return AI_MoveWayChange
- for i in bullet_Pos:
- if abs(hPos[0]-i[1][0])<50 and abs(hPos[1]-i[1][1])<50:
- return AI_MoveWayChange
- else:
- return AI_NothingToDo
- if helper.bodyOnRoute():
- body_dis=helper.bodyOnRoute()
- for i in body_dis:
- dis=(i[0]-hPos[0])*(i[0]-hPos[0])+(i[1]-hPos[1])*(i[1]-hPos[1])
- if dis<dash_dis*dash_dis:
- return AI_MoveWayChange
- if helper.headOnRoute():
- head_dis=helper.headOnRoute()
- for i in head_dis:
- dis=(i[0]-hPos[0])*(i[0]-hPos[0])+(i[1]-hPos[1])*(i[1]-hPos[1])
- if dis<dash_dis*dash_dis:
- return AI_MoveWayChange
- else :
- if helper.bodyOnRoute() or helper.headOnRoute():
- return AI_MoveWayChange
- if helper.checkMeCircling() and helper.canGetBySpin() == 0:
- return AI_MoveWayChange
- if not helper.checkMeCircling() and helper.canGetBySpin() > 0:
- return AI_MoveWayChange
- return AI_NothingToDo
Add Comment
Please, Sign In to add comment