Vector3D v3d = new Vector3D(); Creature passer; Creature current; final int W = 600; final int H = 600; // screen size final int gridscale = 24; // scale of grid is 1/24 of screen size /*dna needs one vector for every spot on the grid (it's like a pixel array but with vectors instead of colors) */ final int DNASIZE = (W / gridscale) * (H / gridscale); final int lifetime = 200; // how long each generation live // global maxforce and maxspeed float maxspeed = 20.0f; float maxforce = 1.0f; Population popul; // population int lifecycle; // timer for cycle of generation int recordtime; // fastest time to target Vector3D target; // target location Vector3D start; // start location float diam = 10.0f; // size of target; PFont f; // font display ArrayList obstacles; // an array list to keep track of all the obstacles. void setup() { size(W, H, P3D); colorMode(RGB, 255, 255, 255, 100); f = loadFont("ArialMT.vlw"); //***initialize the globals **** // lifecycle = 0; recordtime = lifetime; target = new Vector3D(width-diam, height/2); start = new Vector3D(width/2, height/2); //*create a population with a mutation rate, and population max *// int popmax = 100; float mutationRate = 0.01f; popul = new Population(mutationRate, popmax); //*Create the obstacle course ** // } void draw() { background(255); textFont(f); textAlign(LEFT); textMode(SCREEN); fill(0); text("GENERATION #:" + popul.getGenerations(),120,18); text("Time left:" +(lifetime-lifecycle),120,36); text("Record time: " + recordtime,120,54); // text("FITNESS: " + passer, 120, 78); // println(popul.getFitness()); // * DRAW THE START NAND TARGET * // ellipseMode(CENTER); noStroke(); ellipse(start.x(),start.y(), diam, diam); ellipse(target.x(), target.y(), diam, diam); if(lifecycle < lifetime) { popul.live(obstacles); if((popul.targetReached()) && (lifecycle < recordtime)) { recordtime = lifecycle; } lifecycle++; } else { lifecycle = 0; popul.calcFitness(); popul.naturalSelection(); popul.generate(); } } //DISPLAY SOME INFO // ** MOVE THE TARGET IF WE CLICK THE MOUSE ** // void mousePressed() { if(popul.targetReached()) { // new Creature(Vector3D, passer,passer); } target = new Vector3D (mouseX, mouseY); recordtime = lifetime; }