Module: Evolvable::Gene

Included in:
CountGene, RigidCountGene
Defined in:
lib/evolvable/gene.rb

Overview

For evolution to be effective, an evolvable's genes must be able to influence its behavior. Evolvable instances are composed of genes which can be used to implement simple functions or orchestrate complex interactions.

Defining gene classes requires encapsulating some "sample space" and returning a sample outcome when a gene attribute is accessed. For evolution to proceed in a non-random way, the same sample outcome should be returned every time a particular gene is accessed with a particular set of parameters. Memoization is a useful technique for doing just this. Check out the memo_wise gem.

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#evolvableObject

Returns the value of attribute evolvable.


45
46
47
# File 'lib/evolvable/gene.rb', line 45

def evolvable
  @evolvable
end

Class Method Details

.included(base) ⇒ Object


18
19
20
# File 'lib/evolvable/gene.rb', line 18

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#keyObject


47
48
49
# File 'lib/evolvable/gene.rb', line 47

def key
  self.class.key
end