Module: RandomSelection

Defined in:
lib/charlie/selection.rb

Overview

Random selection. May be useful in benchmarks, but otherwise useless.

Instance Method Summary collapse

Instance Method Details

#next_generation(population) ⇒ Object



6
7
8
9
10
11
# File 'lib/charlie/selection.rb', line 6

def next_generation(population)
  new_pop = []
  new_pop += yield(population.at_rand,population.at_rand) while new_pop.size < population.size
  new_pop.pop until new_pop.size == population.size
  new_pop
end