Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 25 lines (20 sloc) 0.427 kB
package goga
import "math/rand"
type Mutator interface {
Mutate(*Individual)
}
type SimpleMutator struct {
chance float64
}
func NewSimpleMutator(chance float64) Mutator {
return &SimpleMutator{ chance }
}
func (sm *SimpleMutator) Mutate(individual *Individual) {
genes := individual.Genes // []Gene
for i := 0; i < len(genes); i++ {
drawn := rand.Float64()
if (drawn < sm.chance) {
genes[i].Mutate()
}
}
}
Jump to Line
Something went wrong with that request. Please try again.