Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
# Creates a selector using tournament selection def EvolutionaryAlgorithm.make_tournament_selector(tournamentSize, getFitness) return Proc.new { |pop, count| newPop = [] while newPop.length < count do pool = pop.random_elements(tournamentSize) fitnesses = pool.collect { |i| getFitness.call(i) } newPop.push(pool[fitnesses.max_index()]) end newPop } end
This paste will be private.
From the Design Piracy series on my blog: