# File lib/libgenetics.rb, line 138
  def crossover(crossover_rate)
    parents = @individuals.dup # genomes that haven't been parents yet
    next_population = Population.new(0)
    while parents.length > 1
      parent1 = parents.delete_at(rand(parents.length))
      parent2 = parents.delete_at(rand(parents.length))
      if rand < crossover_rate        
        child1, child2 = parent1.crossover parent2, rand(parent1.genome.length)
        next_population.individuals << child1 << child2
      else
        next_population.individuals << parent1 << parent2
      end
    end
    next_population += parents # pick up any parents that didn't get a chance to mate
    next_population
  end