// Evolutionary tree example program - (c) axel Kilian 2004 // feel free to use the code as long as you keep the copyrigh note at the top of the code as it is here // // BFont metaBold; float[][] population; float[][] toptenpopulation; int genlength; int popsize; float mapx; float mapy; float rotatepos2; float rotatepos; float targetvol; float weightV; int topten; float weightX; float targetX; float weightY; float targetY; float weightZ; float targetZ; int genomelength; int readsequence; void setup() { colorMode(RGB); mapx = 0.7; mapy = 0.0; popsize = 100; genomelength = 27; topten = (int)(popsize/10); readsequence = 2; population = new float[popsize][genomelength]; toptenpopulation = new float[topten][genomelength]; mapx=0.7; for (int i = 0;i20) && (mouseY<50) && (mouseY>40)) { targetX += (mouseX-pmouseX)*0.1 ; if (targetX<0) targetX=0; } else if ((mouseX<120) && (mouseX>20) && (mouseY<70) && (mouseY>60)) { weightX += (mouseX-pmouseX)*1 ; if (weightX<0) weightX=0; } else if ((mouseX<120) && (mouseX>20) && (mouseY<90) && (mouseY>80)) { targetY += (mouseX-pmouseX)*0.1 ; if (targetY<0) targetY=0; } else if ((mouseX<120) && (mouseX>20) && (mouseY<110) && (mouseY>100)) { weightY += (mouseX-pmouseX)*1 ; if (weightY<0) weightY=0; } else if ((mouseX<120) && (mouseX>20) && (mouseY<130) && (mouseY>120)) { targetZ += (mouseX-pmouseX)*0.1 ; if (targetZ<0) targetZ=0; } else if ((mouseX<120) && (mouseX>20) && (mouseY<150) && (mouseY>140)) { weightZ += (mouseX-pmouseX)*1 ; if (weightZ<0) weightZ=0; } else if ((mouseX<120) && (mouseX>20) && (mouseY<170) && (mouseY>160)) { targetvol += (mouseX-pmouseX)*4 ; if (targetvol<0) targetvol=0; } else if ((mouseX<120) && (mouseX>20) && (mouseY<190) && (mouseY>180)) { weightV += (mouseX-pmouseX)*1 ; if (weightV<0) weightV=0; } else { rotatepos2 += (mouseX-pmouseX); rotatepos -= (mouseY-pmouseY); mapx = (rotatepos/float(height) * TWO_PI); mapy = (rotatepos2/float(height) * TWO_PI); } } void createPop() { for (int i = 0;i first ) && ( compare( hi, mid ) > 0 ) ) --hi; if ( lo <= hi ) { swap( lo, hi ); ++lo; --hi; } } while( lo < hi ); if ( first < hi ) quicksort( first, hi ); if ( lo < last ) quicksort( lo, last ); } } void swap( int ia, int ib ) { float[] temp = new float[genomelength]; for(int i = 0; i omega ) ? 1 : -1; }