PSystem ps; final int WORLD_SIZE = 300; final int PARTICLE_SIZE = 14; final int DRIFT = 8; final int VALUE_RANGE = 350; final int TRANSPARENCY = 200; final int RATE = 30; final int FENCE = 25; final float WALL_REPEL = 50; final float influence = 0.5; final float LOCALITY_MUTATION_RATE = 0.01; final float LOCALITY_SIZE = 50; final float MUTATION_RATE = 0.001; final float SPEED = 5; boolean MUTATE_LOCALITY = false; boolean rectangle = false; boolean test = false; int numParticles = 150; int numConnectors = ((numParticles*(numParticles-1))/2); int x1; int x2; int y1; int y2; Agent agents[]=new Agent[numParticles]; void setup() { framerate(RATE); size(300,300); ps = (PSystem)loadPlugin("PSystem"); ps.setGravity(0); ps.drag = 0.001; ellipseMode(CENTER_DIAMETER); rectMode(CORNERS); colorMode(HSB, 300); for (int i=0;i width) { velocity[0] = -velocity[0]; } if (pos[1] - PARTICLE_SIZE/2 < 0 || pos[1] + PARTICLE_SIZE/2 > height) { velocity[1] = -velocity[1]; } if (pos[0] - PARTICLE_SIZE/2 < 0) { pos[0] = PARTICLE_SIZE/2 + 1; } if (pos[0] + PARTICLE_SIZE/2 > width) { pos[0] = width - (PARTICLE_SIZE/2 + 1); } if (pos[1] - PARTICLE_SIZE/2 < 0) { pos[1] = PARTICLE_SIZE/2 + 1; } if (pos[1] + PARTICLE_SIZE/2 > height) { pos[1] = height - (PARTICLE_SIZE/2 + 1); } if (rectangle == true){ if (pos[0] > x1 && pos[0] < x2 && pos[1] > y1 && pos[1] < y2) { if (pos[0] - (PARTICLE_SIZE/2 + FENCE) < x1 || pos[0] + (PARTICLE_SIZE/2 + FENCE) > x2 || pos[1] - (PARTICLE_SIZE/2 + FENCE) < y1 || pos[1] + (PARTICLE_SIZE/2 + FENCE) > y2){ velocity[0] = -velocity[0]; velocity[1] = -velocity[1]; } if (abs(pos[0]-x1)