boolean evo_step() { int vc; Circle old_c, new_c; float ol, x, y; // choose a random circle vc = int(random(n_circles)); old_c = circles[vc]; // make new circle with radius and color of old one x = old_c.r + random((width-2*old_c.r)); y = old_c.r + random((height-2*old_c.r)); new_c = new Circle(x, y, old_c.r, old_c.c); circles[vc] = new_c; // calculate new overlap values ol = overlap(); if (ol >= last_overlap) { // switch back circles[vc] = old_c; return false; } // keep changes last_overlap = ol; println(ol); return true; } // calculate overlap-value (sum) float overlap() { float o, sum_o = 0.0; Circle a, b; for (int i = 0; i < n_circles; i++) { a = circles[i]; for (int j = i+1; j < n_circles; j++) { b = circles[j]; o = additional_distance + a.r + b.r - dist(a.x, a.y, b.x, b.y); if (o > 0.0) sum_o += o; } } return sum_o; }