Create a gist now

Instantly share code, notes, and snippets.

class Chromosome
...
def self.produce_new(chrs)
roulette(chrs)
newchrs = []
chrs.each do |c|
newchrs.push(roulette(chrs))
end
fitnesses(newchrs)
return newchrs
end
...
@msimcoe

The code as written in gistfile1.rb produced 2 errors when I tried to run it using v2.3.0. The first is on line 5. I had to add to_i as follows:
def fitness
@fitness = @bitstring.to_i^0b0101
end

The second is on line 100 which reads: chrs = Chromosome.produce_new(chrs). This had to be changed to: chrs = Chromosome.produceNew(chrs), to match the definition of self.produceNew(chrs).

All in all I really enjoyed the articles. I'm am learning Ruby as a first language (not counting fortran in college) and I want to also learn how to program algorithms. I'm looking forward to your follow on article to Graph Algorithms in Ruby. I think it should be very interesting. Thank you very much for taking the time write the articles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment