//Boredom bots float E = 2.71828182845904523536; bot [] yay = new bot[100]; void setup(){ size(600,400); background(200,10,10); for (int i = 0; i < 100; i++){ yay[i] = new bot (i * 10, i * 10, (i>>1)+1, int(random(12)), i * 3); } smooth(); framerate(30); noStroke(); } void loop(){ //background(0); for (int i = 0; i < 100; i++){ move(i); } if (mousePressed) { restart(); } } void move(int t){ yay[t].move(); float tt = 16.0 - yay[t].speed[yay[t].dir].xlvl; if (t != 99) { fill(t*2); }else{ fill ((tt*10)+20,10,10); } ellipse(yay[t].x - tt, yay[t].y - tt, tt*2, tt*2); } void restart(){ for (int i = 0; i < 100; i++){ for (int ii = 0; ii < 12; ii++){ yay[i].speed[ii].i = 0; yay[i].speed[ii].phase = 1; } } } class bot{ float x, y; int dec, dir, fli, f; boredom [] speed = new boredom[12]; bot (float xt, float yt, int dect, int dirt, int flit){ f=0; x = xt; y= yt; dec = dect; dir = dirt; fli = flit; for (int i = 0; i<12; i++){ speed[i] = new boredom (dec, 15); } }//constructor; void move(){ float theta = (TWO_PI / 12) * dir; x = fwrap (x+(cos(theta) * speed[dir].xlvl), width); y = fwrap (y+(sin(theta) * speed[dir].xlvl), height); speed[dir].plus(); if (f < fli){ f++; }else{ f = 0; dir = int (random(12)); } }//move; }//class; class boredom { float xlvl; int i; int irata; float xmax; int phase; boredom (int iratat, float xmaxt){ i = 0; phase = 1; irata = iratat; xmax = xmaxt; }//constructor; void plus(){ float x = (6.0 / irata) * i; xlvl = (xmax / nDist(0,1,0)) * nDist(x,phase,3); //i = (i + 1)%irata; if (i < irata){ i++; }else{ i = 0; phase++; } }//plus; }//class; float nDist (float xx, float sigma, float mu){ return pow(E,-(sq((xx-mu))) / (2 * sq(sigma))) / (sigma*sqrt(TWO_PI)); }//where sigma is the scale of the graph & mu shifts the location of the graph along x float fwrap (float fvalu, float flimi){ float fcar=fvalu; if (fcar>flimi){ fcar=(fcar)%flimi; } if (fcar<0){ fcar=flimi-fcar; fcar=(fcar)%flimi; fcar=flimi-fcar; } return fcar; }//fwrap;