# File lib/libgenetics.rb, line 29 def mutate(mutation_probability = 0.05) new_genome = Genome.new(@genome.length) (0...@genome.length).each do |i| if rand(1) < mutation_probability if @genome[i] == 0 new_genome.genome[i] = 1 else new_genome.genome[i] = 0 end else new_genome.genome[i] = @genome[i] end end new_genome end