critter
Class Genome

java.lang.Object
  |
  +--critter.Genome

public class Genome
extends java.lang.Object


Field Summary
 int[] code
           
 int nAlpha
           
protected  java.util.Random rand
           
 
Constructor Summary
Genome(critter.Genome genomeX, critter.Genome genomeY, int crossoverPoint)
          Constructor for a new genome based on two parents.
Genome(int nLength, int nAlphabet, long seed)
          Constructor for generating a new random genome
 
Method Summary
 int crossoverPoint()
          Helper function that calculates a suitable point for crossover
 void mutate(double probability)
          Randomly changes bits in the genetic code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code

public int[] code

rand

protected java.util.Random rand

nAlpha

public int nAlpha
Constructor Detail

Genome

public Genome(int nLength,
              int nAlphabet,
              long seed)
Constructor for generating a new random genome

Parameters:
nLength - the number of bits in the code
nAlphabet - the number of symbols that a bit can be instantiated to
seed - the randomizing seed

Genome

public Genome(critter.Genome genomeX,
              critter.Genome genomeY,
              int crossoverPoint)
Constructor for a new genome based on two parents.

Parameters:
genomeX - the parent x genome
genomeY - the parent y genome
crossoverPoint - the point marking for crossover operation.
Method Detail

crossoverPoint

public int crossoverPoint()
Helper function that calculates a suitable point for crossover

Returns:
int point for crossover

mutate

public void mutate(double probability)
Randomly changes bits in the genetic code.

Parameters:
probability - the probabililty by which a bit is changed.