Skip to content

Commit

Permalink
Boid: Remove redundant division
Browse files Browse the repository at this point in the history
The division in the boid step is completely redundant, since in the next line the direction_vector will be normalized (to a unit vector) anyway.
  • Loading branch information
EwoutH committed Nov 8, 2023
1 parent 6656bcc commit 50c0cae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/boid_flockers/boid_flockers/boid.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def step(self):
self.cohere(neighbors) * self.cohere_factor
+ self.separate(neighbors) * self.separate_factor
+ self.match_heading(neighbors) * self.match_factor
) / 2
)
self.direction_vector /= np.linalg.norm(self.direction_vector)
new_pos = self.pos + self.direction_vector * self.speed
self.model.space.move_agent(self, new_pos)

0 comments on commit 50c0cae

Please sign in to comment.