class Population{ int champIndex=0; float sumOfFitness; Dot[] dots; //constructor Population(int size){ dots=new Dot[size]; for(int i=0; ibig){ big=dots[i].fitness; champIndex=i; } } return dots[champIndex]; } //get a perfect parent based on their fitness Dot getAParent(){ float rand=random(sumOfFitness); float sum=0; for(int i=0; irand){ return dots[i]; } } //shouldn't get here return null; } //natural selection void naturalSelection(){ Dot[] nextGen=new Dot[dots.length]; calcFitness(); nextGen[0]=getChampion().getChild(); nextGen[0].champ=true; for(int i=1; i