dorkrawk/darwinning — pull request #3 by camertron (2014-12-01 04:34:50+00:00)
Title: Add evolution types

I thought it'd be cool to be able to specify different types of evolutions, i.e. mutation, reproduction, etc. With this PR, now you can do:

```ruby
class Triple < Darwinning::Organism
@name = "Triple"
@genes = [
Darwinning::Gene.new(name: "first digit", value_range: (0..9)),
Darwinning::Gene.new(name: "second digit", value_range: (0..9)),
Darwinning::Gene.new(name: "third digit", value_range: (0..9))
]

def fitness
# Try to get the sum of the 3 digits to add up to 15
(genotypes.inject { |sum, x| sum + x } - 15).abs
end
end

p1 = Darwinning::Population.new(
organism: Triple, population_size: 10,
fitness_goal: 0, generations_limit: 100
evolution_types: [
Darwinning::EvolutionTypes::Reproduction.new,
Darwinning::EvolutionTypes::Mutation.new(mutation_rate: 0.10)
]
)
```

In other words, you can now define and add different evolution types to the population.