Class: NEAT::Critter::Genotype::Gene
- Inherits:
-
NeatOb
- Object
- NeatOb
- NEAT::Critter::Genotype::Gene
- Defined in:
- lib/rubyneat/critter.rb
Overview
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
Instance Attribute Summary (collapse)
-
- (Object) enabled
Is this gene enabled?.
-
- (Object) genotype
parent genotype.
-
- (Object) in_neuron
input neuron's name (where our output goes) ouptut neuron's name (neuron to be queried).
-
- (Object) innovation
innovation number.
-
- (Object) out_neuron
input neuron's name (where our output goes) ouptut neuron's name (neuron to be queried).
-
- (Object) weight
weight of the connection.
Attributes inherited from NeatOb
Class Method Summary (collapse)
-
+ (Object) [](genotype, input, output, weight = 0.0, innov = nil)
Create a new Gene and set it up fully.
Instance Method Summary (collapse)
- - (Boolean) disabled?
- - (Boolean) enabled?
-
- (Gene) initialize(genotype, &block)
constructor
A new instance of Gene.
- - (Object) to_s (also: #dump_s)
Methods inherited from NeatOb
Constructor Details
- (Gene) initialize(genotype, &block)
Returns a new instance of Gene
247 248 249 250 251 252 253 254 |
# 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 |
Instance Attribute Details
- (Object) enabled
Is this gene enabled?
245 246 247 |
# File 'lib/rubyneat/critter.rb', line 245 def enabled @enabled end |
- (Object) genotype
parent genotype
233 234 235 |
# File 'lib/rubyneat/critter.rb', line 233 def genotype @genotype end |
- (Object) in_neuron
input neuron's name (where our output goes) ouptut neuron's name (neuron to be queried)
240 241 242 |
# File 'lib/rubyneat/critter.rb', line 240 def in_neuron @in_neuron end |
- (Object) innovation
innovation number
236 237 238 |
# File 'lib/rubyneat/critter.rb', line 236 def innovation @innovation end |
- (Object) out_neuron
input neuron's name (where our output goes) ouptut neuron's name (neuron to be queried)
240 241 242 |
# File 'lib/rubyneat/critter.rb', line 240 def out_neuron @out_neuron end |
- (Object) weight
weight of the connection
243 244 245 |
# File 'lib/rubyneat/critter.rb', line 243 def weight @weight end |
Class Method Details
+ (Object) [](genotype, input, output, weight = 0.0, innov = nil)
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)
265 266 267 268 269 270 271 272 |
# 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 |
Instance Method Details
- (Boolean) disabled?
257 |
# File 'lib/rubyneat/critter.rb', line 257 def disabled? ; not enabled? ; end |
- (Boolean) enabled?
256 |
# File 'lib/rubyneat/critter.rb', line 256 def enabled? ; @enabled ; end |
- (Object) to_s Also known as: dump_s
274 275 276 |
# File 'lib/rubyneat/critter.rb', line 274 def to_s super + "[i%s,w%s,%s]" % [@innovation, @weight, self.enabled?] end |