int GA_POPSIZE= 300; // GA population size int GA_MAXITER= 200; // maximum iterations float GA_ELITRATE= 0.10; // elitism rate float GA_MUTATION= 0.25; // mutation rate String [] population = new String[GA_POPSIZE]; // array to hold possible solutions int [] population_fitness = new int[GA_POPSIZE]; // array to hold the fitness value String [] buffer = new String[GA_POPSIZE]; // a copy of population int [] buffer_fitness = new int[GA_POPSIZE]; // a copy of fitness values int esize = (int)( GA_POPSIZE * GA_ELITRATE); //elitism size String character = ""; // a dummy String used to create words int w = 30; //side of the bitmap (30x30) int tsize = w*w; // the size (length) of the target String int iter = 0; void setup(){ size(200,200); // initialize the population: creates a number of randomom Strings for(int i=0; i< GA_POPSIZE; i++){ character = ""; population_fitness[i] = 0; for(int j=0; j< tsize; j++) // for tsize characters character += str(int(random(2))); //create a random String population[i] = character; } } void draw(){ background(255); int i=0; for(int x=0; x