mutateGene abstract method

G mutateGene(
  1. G gene,
  2. num strength
)

Takes gene and returns a new one, mutated by strength.

For example, if the phenotype is encoded by genes that are integers in the range 0 to 100, and gene equals 50, then:

  • If strength is 0.0 (minimum), then no mutation takes place, and the returned value is 50.
  • If strength is 1.0 (maximum), then the returned value should be completely random and independent from the given gene. In our case, the returned value will be anything between 0 and 100.
  • If strength is anything between those values, the mutation should interpolate between the two extremes. The returned value will be somewhat similar to the original gene.

By default, GenerationBreeder calls this method with strength of 1.0. Unless you're doing something special, you may be able to ignore strength altogether and just return a random gene every time.

Implementation

G mutateGene(G gene, num strength);