{"action":"opened","issue":{"url":"https://api.github.com/repos/dorkrawk/darwinning/issues/5","labels_url":"https://api.github.com/repos/dorkrawk/darwinning/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/dorkrawk/darwinning/issues/5/comments","events_url":"https://api.github.com/repos/dorkrawk/darwinning/issues/5/events","html_url":"https://github.com/dorkrawk/darwinning/issues/5","id":74628830,"number":5,"title":"Basic usage","user":{"login":"GilesBathgate","id":444143,"avatar_url":"https://avatars.githubusercontent.com/u/444143?v=3","gravatar_id":"","url":"https://api.github.com/users/GilesBathgate","html_url":"https://github.com/GilesBathgate","followers_url":"https://api.github.com/users/GilesBathgate/followers","following_url":"https://api.github.com/users/GilesBathgate/following{/other_user}","gists_url":"https://api.github.com/users/GilesBathgate/gists{/gist_id}","starred_url":"https://api.github.com/users/GilesBathgate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GilesBathgate/subscriptions","organizations_url":"https://api.github.com/users/GilesBathgate/orgs","repos_url":"https://api.github.com/users/GilesBathgate/repos","events_url":"https://api.github.com/users/GilesBathgate/events{/privacy}","received_events_url":"https://api.github.com/users/GilesBathgate/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-09T09:03:03Z","updated_at":"2015-05-09T09:03:03Z","closed_at":null,"body":"So I am trying to use this library to do the most basic thing other than the trivial examples provided:\r\n\r\n```ruby\r\n#!/usr/bin/env ruby\r\n\r\nrequire 'darwinning'\r\n\r\nclass Vehicle < Darwinning::Organism\r\n   @name = \"Car\"\r\n\r\n   @wheels = Darwinning::Gene.new(name: \"Wheels\", value_range: (0..4))\r\n   @cylinders = Darwinning::Gene.new(name: \"Cylinders\", value_range: (1..16))\r\n   @tank_size = Darwinning::Gene.new(name: \"Tank Size\", value_range: (1..16))\r\n\r\n   @genes = [ @wheels, @cylinders, @tank_size ]\r\n\r\n\r\n   def fitness\r\n       return ((@wheels.value - 4) + (@cylinders.value / @tank_size.value)).abs\r\n   end\r\nend\r\n\r\np = Darwinning::Population.new(\r\n    organism: Vehicle, population_size: 10,\r\n    fitness_goal: 0, generations_limit: 100\r\n)\r\np.evolve!\r\n\r\np.best_member.nice_print\r\n```\r\n\r\nHowever this doesn't work because ```Gene.value``` doesn't get set (its always nil)\r\n\r\nI had to do the following to get things to work.\r\n\r\n```ruby\r\n#!/usr/bin/env ruby\r\n\r\nrequire 'darwinning'\r\n\r\nclass Vehicle < Darwinning::Organism\r\n   @name = \"Car\"\r\n\r\n   @wheels = Darwinning::Gene.new(name: \"Wheels\", value_range: (0..4))\r\n   @cylinders = Darwinning::Gene.new(name: \"Cylinders\", value_range: (1..16))\r\n   @tank_size = Darwinning::Gene.new(name: \"Tank Size\", value_range: (1..16))\r\n\r\n   @genes = [ @wheels, @cylinders, @tank_size ]\r\n\r\n   def find(name)\r\n       genotypes[self.class.genes.index{ |g| g.name == name}]\r\n   end\r\n\r\n   def fitness\r\n       wheels = find(\"Wheels\")\r\n       cylinders = find(\"Cylinders\")\r\n       tank_size = find(\"Tank Size\")\r\n\r\n       return ((wheels - 4) + (cylinders / tank_size)).abs\r\n   end\r\nend\r\n\r\np = Darwinning::Population.new(\r\n    organism: Vehicle, population_size: 10,\r\n    fitness_goal: 0, generations_limit: 100\r\n)\r\np.evolve!\r\n\r\np.best_member.nice_print\r\n``` "}}