Created
October 28, 2010 15:32
-
-
Save trek/651599 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
class DoBlendingCrossover < Machine | |
def initialize | |
@number_to_create = 1 | |
end | |
def create (n) | |
@number_to_create = n | |
end | |
def process_answers | |
created = [] | |
answers_keyed_by_language.each do |language, group| | |
group.shuffle!.each_slice(2) do |a, b| | |
b = a unless b | |
blueprint_a = a.blueprint | |
blueprint_b = b.blueprint | |
@number_to_create.times do | |
new_blueprint = blueprint_a.blending_crossover(blueprint_b) | |
created << make_answer(new_blueprint, a, b) | |
end | |
end | |
end | |
label parents: answers | |
label created: created | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment