/** Genotype.java *J Scott Cameron *This class contains a bit-vector with the "genes" *and a rating to be determined by the fitness *function of the Genetic Algorithm. * *Note: All the contructors take a Random as a parameter *because when creating a whole slew of Genetypes very quickly *if each Genotype creates its own Random object then there are a lot *of identical Random objects since they're all initialized using the *current time in milliseconds. It takes less than a millisecond to create *a Genotype so the Random objects are initialized with the same time. *This is very bad if you want a population of unique Genotypes. *By including a Random object in the constructor the Genetic Algorithm *sends all the Genotypes a reference to the same Random object. This way *each objects gets the object at a different point in its progression. */ import java.io.*; import java.util.*; public class Genotype { private boolean bits[]; private int rating; private int length; private Random random; public Genotype() { random = new Random(); } /* creates a Random genetoype */ public Genotype(int length, Random r) { random = r; this.length = length; bits = new boolean[length]; for(int i=0;i