int displgen = 1; //display generations on main page int g = 2, generation=0; // int t = 60; // population size int showone = -1; //display one tree boolean displ_rules = false; boolean displ_gen = false; int boxw; int fillparent = 0; boolean run = true; boolean automatic = false; //manual or automatic int counter = 0; int p = 0; // parents for manual mode int pp, pmax, top; // parents for automatic mode int maxparents = int(t/2); int[] parentlist; int[] ranking; tree[] forrest; tree[] parents; float survivalrate = 0.1; // top percent, seeds for new generation float untouched = 0.05; // top percent that are meant to live without alteration float prob_crossover = 0.5; float prob_mutation = 0.8; float f_best = 0, f_av = 0, f_worst = 0; PFont trebuchet16, lucida, trebuchet12, trebuchet10, pixelfont,trebuchet48; Menu menu; boolean mouseleft, mouseright; boolean fitness_checker = false, randomizer = false, oldparents = false, displfitness=false; boolean evolve_lowercase = false, repeat_first = false; char[] abc = { 'r','b','j','F','A','J','C','R','K','+','-' }; //char[] abc = { 'F','A','R'}; String fitness_display = ""; int frame = 120; // top frame int distance = 12; Button bt_switch, bt_run, bt_randomize, bt_reproduce, bt_measure, bt_select, bt_clear; Button bt_fitness[], bt_back, bt_replay, bt_plants; hslider sl_survrate, sl_parentrate, sl_crossrate, sl_mutrate; hsteps display_generation, display_number; boolean bt_f_length=true, bt_f_ratio=true, bt_f_maxh=false, bt_f_maxw=false; boolean bt_f_growh=false, bt_f_dim200=false, bt_f_dim500=false, bt_f_dim1000=false; boolean bt_f_linesp=false, bt_f_linesn=false, bt_f_arc=false, bt_f_push=false; boolean bt_f_circle=false, bt_f_jump=false, bt_f_rotmax=false, bt_f_rot=false; boolean bt_f_notdraw=false, bt_f_draw=false; color bgnd = color(240,0,0), topc = color(150,0,0); color tc0 = color(100,100,250), tc1 = color(220,220,255), tc2 = color(190,190,250); color bc0 = color(20,50,200), bc1 = color(10,10,200); color mc0 = color(150,0,0), mc1 = color(150,0,0); color redc = color(255,0,0), white = color(255,255,255), black = color(0,0,0); color markc2 = color(255,110,30); color markc = color(255,200,0); void setup() { //size(screen.width,screen.height); size(800,700); frameRate(50); lucida = loadFont("lucida.vlw"); //trebuchet10 = loadFont("Trebuchet10.vlw"); trebuchet16 = loadFont("Trebuchet.vlw"); pixelfont = loadFont("Standard8.vlw"); trebuchet48 = loadFont("Trebuchet48.vlw"); textFont(trebuchet16, 16); menu = new Menu(); init_top(); calc_size(); int placex = boxw; int placey = frame+boxw; ranking = new int[t]; forrest = new tree[t]; for(int i=0; i width - displgen*boxw) { placex = boxw; placey += boxw+distance; } } pp = int(t * survivalrate); top = int(t * untouched); println("survival = "+pp+" untouched = "+top); pmax = (automatic) ? pp : p; println(pmax); parentlist = new int[Math.max(pp,maxparents)]; for(int i=0; i",330, 260+i*24); text(forrest[showone].substitute[i],360,260+i*24); } bt_back.check(); bt_back.draw(); } else if(displ_gen) { textFont(trebuchet16, 16); fill(white); noStroke(); int transx = 200; for(int i=0; iheight-200) break; } bt_back.check(); bt_back.draw(); } else if(showone==-1) { if(randomizer) { randomize(); randomizer = false; } for(int i=0; i width - displgen*boxw) { placex = boxw; placey += boxw+distance; } } }