int num = 100; int maxspeed = 12; int avoidRadius = 40; int tailLength = 2; int runsPerLoop = 3*num; Agent[] agents = new Agent[num]; void setup(){ size(800, 450); background(20); framerate(30); for (int i = 0; i < num; i++) agents[i] = new Agent(); stroke(0,255,0); ellipseMode(CENTER); } void draw(){ agents[0].chaser = true; //fade effect fill(20, 30); noStroke(); rect(0,0,width, height); //Draw the agents for(int i=0; i= num) { for (int iii=0; iii0; jj-=50) ellipse(agents[0].x, agents[0].y, jj, jj); } } class Agent { float x, y; float speed, direction; float[][] tail = new float[tailLength][2]; boolean chaser = false; Agent(){ x= random(width); y= random(height); speed = .2*maxspeed; direction = random(2*PI); for (int i=0; i0 & x0 & y0)) direction = atan((x-agents[i].x)/(y-agents[i].y))+random(.2); else if (!(agents[i].chaser)){ direction = agents[i].direction+random(-PI/20, PI/20); } } } } void chase(){ //Check each agent for(int k=0; k0 & x0 & yheight) y-=height; if (x<0) x+=width; if (x>width) x-=width; constrain(x, 0, width); constrain(y, 0, height); for (int i=1; i