Skip to content

Commit

Permalink
Prevent division by zero in PredPrey example
Browse files Browse the repository at this point in the history
  • Loading branch information
Robadob committed Jun 20, 2024
1 parent 40ef0d8 commit 2a6ba48
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion episodes/files/pred-prey/predprey.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def flock(self, prey_list):
group_centre_count += 1

# Avoidance behaviour
if separation < SAME_SPECIES_AVOIDANCE_RADIUS:
if separation < SAME_SPECIES_AVOIDANCE_RADIUS and separation > 0:
# Was a check for separation > 0 in original - redundant?
avoid_velocity_x += SAME_SPECIES_AVOIDANCE_RADIUS / separation * dx
avoid_velocity_y += SAME_SPECIES_AVOIDANCE_RADIUS / separation * dy
Expand Down

0 comments on commit 2a6ba48

Please sign in to comment.