Esempio n. 1
0
    def move(self):
        #update position based on new heading
        ### we now have a property in "energy" that determines how far the bird can travel (in behavioral space) each time step
        ### we might understand this as 'enthusiasm', or 'behavioral engagement in workplace culture'
        self.position = Point3d.Add(self.position, self.heading * self.energy)

        ### leave points behind for later analysis if the bird is feeling welcome or unwelcome
        if self.inclusion > .25:
            self.inclusiveTrail.append(self.position)
        else:
            self.exclusiveTrail.append(self.position)
Esempio n. 2
0
 def cohere(self, others):
     #find average point of all other Boids
     centerPoint = others.pop(0).position
     for other in others:
         centerPoint = Point3d.Add(centerPoint, other.position)
     centerPoint = Point3d.Divide(centerPoint, numBoids - 1)
     #find direction from Boid to average point of all other Boids
     direction = Point3d.Subtract(centerPoint, self.position)
     #remove magnitude from average-seeking vector
     direction = Vector3d.Divide(direction, direction.Length)
     #adapt heading to new direction
     self.heading = Vector3d.Add(direction, self.heading)
Esempio n. 3
0
 def move(self):
     self.position = Point3d.Add(self.position, self.velocity)
     self.trail.append(self.position)
     self.trail = self.trail[-5:]