Submission
From Physical Programming
Yay! it's that time of the year.
This semester has been rather up and down. With moments of discovery and elation - the introduction to emergence and discovery Perlin noise (which stole a whole weekend of my life), interspersed with sheer frustration at the process of coding. I was elated when I got to the point where I would code something I had in mind and it would run first time with no debugging errors. Rad.
Project Abstract,
Emergence of the Don
The Emergence of the Don is an programmatic emergent social system. The initial behavior was modeled on the perceived interaction of design students on the State Library lawn with respect to a Japanese take away shop, Don Don's. A veritable institution among RMIT students. The visualization is simple, complexity emerging without trendy graphics. The colored dots are representative of individual actors in the system, which have a hunger, represented by their opacity. They move according to a organic Perlin noise function and are attracted and repulsed from Don Don's Dependant on their hunger.
Deliverables
Audio, Problems - Pittsburgh indie band The Girls' (2003)
Program Code
/* 28.05.2008 Julian Faelli - jfaelli@gmail.com Physical Programming, Semester One 2008 RMIT University http://www.openobject.org/physicalprogramming/ ********************************************** Emergence of the Don A social system */ //global variables int pop = 250; int i = 0; int attractindex = 10; //attraction to the don 12 is a good value for this, ensures dieback int erraticindex = 2; //controls how erratic the perlin noise function is int repulseindex = 50; //repulsion from the don when hunger is low Dstudent[] students = new Dstudent[pop]; //Dstudent array to hold all instances of student class, length of the array set by pop varariable void setup(){ size(800, 800); noStroke(); frameRate(30); fill(255); smooth(); //populating the Dstudent array with class instances for (int i = 0; i < pop; i++) { students[i] = new Dstudent(random(0,800),random(0,800),5,5,0,random(0,1),random(0,1),0); } } //processing draw function void draw(){ background(0); //drawing rectangle for dondons fill(255,227,10); rectMode(CENTER); rect (600,600,100,100); fill(255); //calling all the functions in the Dstudent class for (int i = 0; i < pop; i++) { students[i].drawDstudent(); students[i].figgerHeading(); students[i].edgeLawn(); students[i].moreHunger(); students[i].speedHunger(); students[i].grabDon(); } //writing the current framerate to the bottom left of the screen fill (100); rectMode(CORNER); rect(10 , 778, 42, 14); fill(255); PFont fontCourier = loadFont("CourierNew36.vlw"); textFont(fontCourier, 10); textAlign(LEFT); text(frameRate, 10, 788); } //Dstudent class definition class Dstudent{ float xpos, ypos, xvel, yvel; int hunger; float agex; float agey; int dontype; Dstudent(float x, float y, float xv, float yv ,int h, float ay, float ax, int don){ xpos = x; ypos = y; xvel = xv; yvel = yv; hunger = h; agex = ax; agey = ay; dontype = don; } //working out the heading void figgerHeading(){ //tempary vars for calcuation float xpostempa; float ypostempa; float xpostempb; float ypostempb; float xdisttodon; float ydisttodon; //calc dist to the don xdisttodon = 600 - xpos; ydisttodon = 600 - ypos; //movement based on perlin noise function xpostempb = xpos + xvel * (2*(noise(agex))-1); ypostempb = ypos + yvel * (2*(noise(agey))-1); agex = agex + erraticindex; agey = agey + erraticindex; //don don attractivness here if (hunger > 60 && hunger < 100){ xpos = xpostempb + (xdisttodon/attractindex); ypos = ypostempb + (ydisttodon/attractindex); } //die if hunger is over 100 else if (hunger >= 100) { xpos = xpos; ypos = ypos; xvel = 0; yvel = 0; } //don repulsivness here else if (hunger < 40){ xpos = xpostempb - (xdisttodon/repulseindex); ypos = ypostempb - (ydisttodon/repulseindex); } //move normally else { xpos = xpostempb; ypos = ypostempb; } } //testing to see if the dStudent is off the library lawn void edgeLawn() { if (xpos > (width - 10) || xpos < 10) { xvel *= -1; } if (ypos > (height - 10) || ypos < 10) { yvel *= -1; } } //drawing the hunger bugger to the screen void drawDstudent(){ //setting fill colour of the ellipse based on the hunger index and don type if (hunger > 100){ fill(0,0,0,0); } else { if (dontype == 0){ fill(252,15,15,(255-(hunger*2.5))); } else if (dontype == 1){ fill(15,243,252,(255-(hunger*2.5))); } else if (dontype == 2){ fill(252,134,13,(255-(hunger*2.5))); } else { fill(255,93,220,(255-(hunger*2.5))); } } ellipse(xpos ,ypos, 10, 10); //drawing the elipse at the current position } //incrementing the hunger index void moreHunger(){ hunger = hunger +1; } //setting x,y velocity according to the hunger index void speedHunger(){ if (hunger < 99){ xvel = ((7.5 * (sin((hunger/15)+20)+12.5))/2); //very nice trig function to work out velocity based upon hunger index } else { xvel = 0; } if (hunger < 99){ yvel = (7.5 * ((sin((hunger/15)+20)+12.5))/2); } else { yvel = 0; } } //function to reset hunger to zero if dstudent gets to don dons void grabDon(){ if (xpos > 550 && xpos < 650 && ypos < 650 && ypos > 550){ hunger = 0; dontype = int(random(0,4)); println(dontype); } } }


