The problems are:
- You are not passing in any boid data into your function, just the
indices
element_1
andelement_2
. Socalculate_distance
does not know anything about the boids. - Even if you were passing in boid data you are assigning empty lists to
a
andb
, which means the inside of your loop is never executed.
You want something like:
for element_1 in range(len(boids)):
for element_2 in range(len(boids)):
distance = calculate_distance(boids[element_1],boids[element_2])
and then
def calculate_distance(a,b):
return sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)