Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def compute_alignment(self):
- v = Point(0,0)
- if len(self.align_list) == 0:
- return v
- for fish in self.align_list:
- v += fish.velocity
- v /= len(self.align_list)
- v.restrain(0.212)
- return v
- def compute_attraction(self):
- v = Point(0,0)
- if len(self.attract_list) == 0:
- return v
- for fish in self.attract_list:
- v += fish.position - self.position
- v /= len(self.attract_list)
- v.restrain(0.50)
- return v
- def compute_repulsion(self):
- v = Point(0,0)
- if len(self.repulse_list) == 0:
- return v
- for fish in self.repulse_list:
- w = (self.position - fish.position)
- w.normalize(1)
- v += (w/self.distance_from(fish))*28
- v /= len(self.repulse_list)
- return v
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement