class NEAT::Critter::Genotype::Gene
Gene Specification¶ ↑
The Gene specifices a singlular input and output neuron, which represents a connection between them, along with the weight of that connection, which may be positive, negative, or zero. There is also the enabled flag
Attributes
enabled[RW]
Is this gene enabled?
genotype[RW]
parent genotype
in_neuron[RW]
input neuron's name (where our output goes) ouptut neuron's name (neuron to be queried)
innovation[RW]
innovation number
out_neuron[RW]
input neuron's name (where our output goes) ouptut neuron's name (neuron to be queried)
weight[RW]
weight of the connection
Public Class Methods
[](genotype, input, output, weight = 0.0, innov = nil)
click to toggle source
Create a new Gene and set it up fully.
genotype -- genotype input -- name of input neuron connection output -- name of output neuron connection weight -- weight to give neuron (optional) innov -- innovation number of gene (optional)
# File lib/rubyneat/critter.rb, line 265 def self.[](genotype, input, output, weight = 0.0, innov = nil) g = Gene.new genotype g.in_neuron = (input.kind_of? Symbol) ? input : input.name g.out_neuron = (output.kind_of? Symbol) ? output : output.name g.weight = weight g.innovation = innov unless innov.nil? return g end
new(genotype, &block)
click to toggle source
Calls superclass method
# File lib/rubyneat/critter.rb, line 247 def initialize(genotype, &block) super genotype.controller @genotype = genotype @enabled = true @innovation = NEAT::new_innovation @in_neuron = @out_neuron = nil block.(self) unless block.nil? end
Public Instance Methods
disabled?()
click to toggle source
# File lib/rubyneat/critter.rb, line 257 def disabled? ; not enabled? ; end
enabled?()
click to toggle source
# File lib/rubyneat/critter.rb, line 256 def enabled? ; @enabled ; end
to_s()
click to toggle source
Calls superclass method
# File lib/rubyneat/critter.rb, line 274 def to_s super + "[i%s,w%s,%s]" % [@innovation, @weight, self.enabled?] end
Also aliased as: dump_s