Example #1
0
/** Rule for the predator to chase a random bird.
 ** @param p Pointer to the predator
 ** @return The velocity vector towards the random bird
 **/
vector pursue(Boid* p){
  List boids = flock->getBoids();
  vector v;
  int idx = rand()%(boids.size()+1)-1;
  It itb = boids.begin();
  for (int i = 0; i< idx; i++) itb++;
  v = Diff(itb->getPos(), p->getPos());
  v = Mult(Normalize(v), 5.0);
  return v;
}