int side = 4; int maxi = 30000; int env = 10; cellule[] celluleListe; int[][][] concentrations; int[][] celluleMap; color[][] output; int c,result,cycle,totale,cellule,FPS,prevT,i; PFont infosFont; void setup(){ size(470,300,P3D); //500,400 infosFont = loadFont("ArialMT-14.vlw"); textFont(infosFont, 14); begginScare(); } ///////////////////////////////////////////////// void draw(){ if(totale < maxi){ //updateConcentrations(); showConcentrations(); lowerConcentrations(5); showCellules(); updateAll(); //updateNext(); output(); cycle++; showInfos(); }else{ framerate(8); } if(mousePressed == true){ begginScare(); } } ///////////////////////////////////////////////// class cellule{ int Xpos, Ypos, lifeTime; color Cme,Cother,Cempty; cellule(){ } void update(){ //------------------------------- TEST VERSION !! //cellleMap : 0 = red // 1 = green // 9 = empty // 5 = dead if(lifeTime < 999){ celluleMap[Xpos][Ypos] = 9; Xpos += random(-2,3); Ypos += random(-2,3); if(Xpos > width-1){Xpos = width-1;} if(Xpos < 0){Xpos = 0;} if(Ypos > height-1){Ypos = height-1;} if(Ypos < 0){Ypos = 0;} if(Cme == color(255,0,0)){ celluleMap[Xpos][Ypos] = 0; }else{ celluleMap[Xpos][Ypos] = 1; } updateLocalConcentrations(Xpos,Ypos); //if(random(20) < 1){changeColor();} if(totale < maxi){divideFree(Xpos, Ypos, Cme);} }else{ celluleMap[Xpos][Ypos] = 5; } } int arounding(int zone, color type){ int around = 0; for(int x=-zone; x= totale){ cellule = 0; } } //----------------------------------------------- UPDATE ALL * void updateAll(){ int temp_totale = totale; for(int c=0; c 0 && xn < width && yn > 0 && yn < height){ result = env-abs(sqrt(sq(x-xn)+sq(y-yn))); if(result > 0){concentrations[0][xn][yn] += result;} } } } } else if(celluleMap[x][y] == 1){ for(int xn=x-env; xn 0 && xn < width && yn > 0 && yn < height){ result = env-abs(sqrt(sq(x-xn)+sq(y-yn))); if(result > 0){concentrations[1][xn][yn] += result;} } } } } } } } //----------------------------------------------- UPDATE LOCAL CONCENTRATIONS * void updateLocalConcentrations(int x, int y){ float result; if(celluleMap[x][y] == 0){ for(int xn=x-env; xn 0 && xn < width && yn > 0 && yn < height){ result = env-abs(sqrt(sq(x-xn)+sq(y-yn))); if(result > 0){concentrations[0][xn][yn] += result;} } } } } else if(celluleMap[x][y] == 1){ for(int xn=x-env; xn 0 && xn < width && yn > 0 && yn < height){ result = env-abs(sqrt(sq(x-xn)+sq(y-yn))); if(result > 0){concentrations[1][xn][yn] += result;} } } } } } //----------------------------------------------- LOWER CONCENTRATIONS * void lowerConcentrations(int amount){ for(int x=0; x 0){concentrations[0][x][y] -= amount;} if(concentrations[1][x][y] > 0){concentrations[1][x][y] -= amount;} } } } //----------------------------------------------- SHOW CONCENTRATIONS * void showConcentrations(){ for(int x=0; x0 || concentrations[1][x][y]>0){ //get faster output[x][y] = color(concentrations[0][x][y],concentrations[1][x][y],0); } } } } //----------------------------------------------- SHOW CELLULES * void showCellules(){ for(int x=0; x= 0 && xn < width && yn >= 0 && yn < height){ if(celluleMap[xn][yn] == 9){ freeX[i] = xn; freeY[i] = yn; i++; } } } } if(i > 0){ int val = int(random(i)); totale ++; celluleListe[totale].init(freeX[val], freeY[val], c); } } //----------------------------------------------- OUTPUT * void output(){ loadPixels(); for(int x=0; x