From 50c0cae4c35a1cae59731abcb02f504596673978 Mon Sep 17 00:00:00 2001 From: Ewout ter Hoeven Date: Wed, 8 Nov 2023 12:21:38 +0100 Subject: [PATCH] Boid: Remove redundant division 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. --- examples/boid_flockers/boid_flockers/boid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/boid_flockers/boid_flockers/boid.py b/examples/boid_flockers/boid_flockers/boid.py index d02d395d..2390ff1d 100644 --- a/examples/boid_flockers/boid_flockers/boid.py +++ b/examples/boid_flockers/boid_flockers/boid.py @@ -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)