Created
August 5, 2014 12:03
-
-
Save mirontoli/6b35d4e9bfe4b7997ab8 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
#!/usr/bin/env ruby | |
target = "METHINKS IT IS LIKE A WEASEL" | |
@gene_pool = ("A".."Z").to_a << " " | |
litter_size = 100 | |
mutation_rate = 0.04 | |
def rand_gene | |
@random = rand(@gene_pool.count) | |
@gene_pool.at( @random ) | |
end | |
weasel = (1 .. target.length).map { rand_gene } | |
puts "1: #{weasel.join('')}\n" | |
generation = 2 | |
begin | |
generation += 1 | |
puts "#{generation}: #{weasel.join('')}\n" | |
end while generation < 100 | |
def score(weasel) | |
1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment