def processAI(self): if self.leader.dead == True: pass elif self.leader.active and self.leader != self: tempVelocity = vector.vector2d(self.leader.velocity[0], self.leader.velocity[1]) targetPoint = self.leader.position - (tempVelocity.makeNormal()) * vector.vector2d(150,150) aitools.goToPoint(self, targetPoint) else: if not self.changeDirection: self.target = vector.vector2d((random.random() * (SCREEN_WIDTH + 200)) - 100, (random.random() * (SCREEN_HEIGHT + 200)) - 100) self.changeDirection = 30 self.changeDirection -= 1 aitools.arcToPoint(self, self.target)
def standardBehavior(self): if not self.changeDirection: self.targetPoint = vector.vector2d( random.randint( int(self.target.position[0] - 300), int(self.target.position[0] + 300)), random.randint( int(self.target.position[1] - 300), int(self.target.position[1] + 300))) self.changeDirection = 30 self.changeDirection -= 1 aitools.arcToPoint(self, self.targetPoint,0.5)
def process_AI(self): if self.leaveScreen: pass elif self.myPosition != 1: flockChart = [False,False,False,False,False] for member in self.myFlock: if member.active: if member.myPosition == self.myPosition and member != self and self.myPosition < 5: member.myPosition += 1 flockChart[member.myPosition - 1] = True if member.myPosition == 1: self.leader = member positionNumber = 0 for element in flockChart: positionNumber += 1 if positionNumber < self.myPosition and element == False: self.myPosition = positionNumber if self.myPosition == 1: self.leader = self self.speed = 14.2 leaderVelocity = vector.vector2d(self.leader.velocity[0], self.leader.velocity[1]) leaderPerpendicular = self.leader.velocity.getPerpendicular() if self.myPosition % 2: offset = -50 else: offset = 50 targetPoint = self.leader.position - (leaderVelocity.makeNormal() * (100) * int(self.myPosition / 2)) + (leaderPerpendicular.makeNormal() * offset * int(self.myPosition / 2)) if (targetPoint - self.position).getMagnitude() < self.speed: aitools.goToPoint(self,targetPoint) else: aitools.arcToPoint(self, targetPoint, 3) else: for element in self.myFlock: if element != self and element.myPosition == self.myPosition: element.myPosition += 1 self.speed = 11 if not self.changeDirection: self.target = vector.vector2d((random.random() * (SCREEN_WIDTH + 200)) - 100, (random.random() * (SCREEN_HEIGHT + 200)) - 100) self.changeDirection = 30 self.changeDirection -= 1 aitools.arcToPoint(self, self.target)
def processAI(self): if self.leaveScreen: pass else: self.target = aitools.getClosest(self, self.powerupGroup) if self.target != self and self.target.active: aitools.goToTarget(self, self.target) self.changeDirection = 0 else: if not self.changeDirection: self.targetPoint = vector.vector2d((random.random() * (SCREEN_WIDTH + 200)) - 100, (random.random() * (SCREEN_HEIGHT + 200)) - 100) self.changeDirection = 30 self.changeDirection -= 1 aitools.arcToPoint(self, self.targetPoint)
def processAI(self): aitools.arcToPoint(self, self.target.position, 2)