def closest_neighbors(self): """Find the average position of the closest neighbors. @rtype: C{tuple} of C{(x, y)}. """ hood = (self.x, self.y, self.personal_radius) n = collide_single(hood, self.others) return n
def neighbors(self): """Find the other boids in my neighborhood. @rtype: C{list} of L{Boid}s. """ hood = (self.x, self.y, self.neighborhood_radius) # neighborhood n = collide_single(hood, self.others) return n
def test_sanity(self): self.assertEqual(c.collide_single((0,0,10), [(15,0,10), (20,20,1)]), [(15,0,10)])
def test_adjacent(self): self.assertEqual(c.collide_single((20,0,5), [(0,0,15)]), [(0,0,15)]) self.assertEqual(c.collide_single((0,0,15), [(20,0,5)]), [(20,0,5)])