Skip to content

Commit c5b4ea4

Browse files
committed
Rely on genome for gene retrieval
1 parent a673e28 commit c5b4ea4

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

lib/evolvable.rb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,14 @@ def after_evolution(population); end
299299

300300
def after_initialize_evolvable; end
301301

302-
def find_gene(name)
303-
return nil if @genome.nil?
304-
305-
genes = @genome[name]&.dig(:genes)
306-
return nil if genes.nil? || genes.empty?
302+
attr_accessor :fitness
307303

308-
genes.first
304+
def find_gene(name)
305+
@genome&.find_gene(name)
309306
end
310307

311308
def find_genes(name)
312-
return [] if @genome.nil?
313-
314-
@genome[name]&.dig(:genes) || []
309+
@genome&.find_genes(name) || []
315310
end
316311

317312
attr_reader :population,

0 commit comments

Comments
 (0)