Skip to content

Instantly share code, notes, and snippets.

@mirontoli
Created August 5, 2014 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirontoli/6b35d4e9bfe4b7997ab8 to your computer and use it in GitHub Desktop.
Save mirontoli/6b35d4e9bfe4b7997ab8 to your computer and use it in GitHub Desktop.
#!/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
#print
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