Class: Darwinning::Organism

Inherits:
Object
  • Object
show all
Includes:
ClassLevelInheritableAttributes
Defined in:
lib/darwinning/organism.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassLevelInheritableAttributes

included

Constructor Details

#initialize(genotypes = {}) ⇒ Organism

Returns a new instance of Organism.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/darwinning/organism.rb', line 37

def initialize(genotypes = {})
  if genotypes == {}
    # fill genotypes with expressed Genes
    @genotypes = {}
    genes.each do |g|
      # make genotypes a hash with gene objects as keys
      @genotypes[g] = g.express
    end
  else
    @genotypes = genotypes
  end

  @fitness = nil
end

Instance Attribute Details

#fitnessObject

Returns the value of attribute fitness.



32
33
34
# File 'lib/darwinning/organism.rb', line 32

def fitness
  @fitness
end

#genesObject

Returns the value of attribute genes.



32
33
34
# File 'lib/darwinning/organism.rb', line 32

def genes
  @genes
end

#genotypesObject

Returns the value of attribute genotypes.



32
33
34
# File 'lib/darwinning/organism.rb', line 32

def genotypes
  @genotypes
end

#nameObject

Returns the value of attribute name.



32
33
34
# File 'lib/darwinning/organism.rb', line 32

def name
  @name
end