Class: Evolvable::RigidCountGene
- Inherits:
-
Object
- Object
- Evolvable::RigidCountGene
- Includes:
- Gene
- Defined in:
- lib/evolvable/rigid_count_gene.rb
Overview
This class manages fixed gene counts in evolvable instances.
Unlike the CountGene, the RigidCountGene maintains a constant number of genes
that doesn't change during evolution. This is used when a gene is defined
with a fixed integer for count:
(e.g., count: 5
).
Instance Attribute Summary collapse
-
#count ⇒ Integer
readonly
The fixed number of genes to create.
Attributes included from Gene
Class Method Summary collapse
-
.combine(gene_a, _gene_b) ⇒ RigidCountGene
Combines two rigid count genes by always returning the first one.
Instance Method Summary collapse
-
#initialize(count) ⇒ RigidCountGene
constructor
Initializes a new RigidCountGene with a fixed count.
Methods included from Gene
Constructor Details
#initialize(count) ⇒ RigidCountGene
Initializes a new RigidCountGene with a fixed count.
42 43 44 |
# File 'lib/evolvable/rigid_count_gene.rb', line 42 def initialize(count) @count = count end |
Instance Attribute Details
#count ⇒ Integer (readonly)
The fixed number of genes to create.
51 52 53 |
# File 'lib/evolvable/rigid_count_gene.rb', line 51 def count @count end |
Class Method Details
.combine(gene_a, _gene_b) ⇒ RigidCountGene
Combines two rigid count genes by always returning the first one. This ensures the count remains constant during evolution.
33 34 35 |
# File 'lib/evolvable/rigid_count_gene.rb', line 33 def self.combine(gene_a, _gene_b) gene_a end |