Print

Print


On Apr 10, 2012, at 1:08 PM, Ben Stabile wrote:

> In the code below (from GeneVectorIndividual), you are attempting to fill “genome” instead of “newGenome” when the new length is greater than the existing length…
>  
>     public void setGenomeLength(int len)
>         {
>         GeneVectorSpecies s = (GeneVectorSpecies) species;
>         VectorGene[] newGenome = new VectorGene[len];
>         System.arraycopy(genome, 0, newGenome, 0,
>             genome.length < newGenome.length ? genome.length : newGenome.length);
>         for(int x=genome.length; x< newGenome.length; x++)
>             if (genome[x]==null) genome[x] = (VectorGene)(s.genePrototype.clone());  // not reset
>         genome = newGenome;
>         }

Yeah, I think you're right, it should be:

        for(int x=genome.length; x< newGenome.length; x++)
            newGenome.length[x] = (VectorGene)(s.genePrototype.clone());
	genome = newGenome

Sean