Class: NEAT::Neuron

Inherits:
NeatOb show all
Includes:
Math, Graph
Defined in:
lib/rubyneat/neuron.rb

Overview

Neuron – Basis of all Neat Neuron types.

Normally contains primatives which aids in its own expression, but the details of this remains to be worked out.

Constant Summary collapse

@@neuron_types =

List of neuron types defined.

[]

Instance Attribute Summary collapse

Attributes inherited from NeatOb

#controller, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Graph

#<<, #add, #clear_graph, #inputs

Methods inherited from NeatOb

attr_neat, #initialize, log, #log, #to_s

Constructor Details

This class inherits a constructor from NEAT::NeatOb

Instance Attribute Details

#genotypeObject (readonly)

Genotype to which we belong



19
20
21
# File 'lib/rubyneat/neuron.rb', line 19

def genotype
  @genotype
end

#heirarchy_numberObject

(assigned by wire!) Heirarchy number in the Genome / Critter We need this to assure we add genes in the proper order. This will be recalculated every time a new neuron is added.



25
26
27
# File 'lib/rubyneat/neuron.rb', line 25

def heirarchy_number
  @heirarchy_number
end

#outputObject

This is true if this is an output neuron.



28
29
30
# File 'lib/rubyneat/neuron.rb', line 28

def output
  @output
end

#traitObject

Returns the value of attribute trait.



20
21
22
# File 'lib/rubyneat/neuron.rb', line 20

def trait
  @trait
end

Class Method Details

.bias?Boolean

Returns:

  • (Boolean)


43
# File 'lib/rubyneat/neuron.rb', line 43

def self.bias? ; false ; end

.inherited(clazz) ⇒ Object



49
50
51
# File 'lib/rubyneat/neuron.rb', line 49

def self.inherited(clazz)
  @@neuron_types << clazz
end

.input?Boolean

Class is is of Input type?

Returns:

  • (Boolean)


40
# File 'lib/rubyneat/neuron.rb', line 40

def self.input? ; false ; end

.neuron_typesObject

List of distinct neuron types (classes)



54
# File 'lib/rubyneat/neuron.rb', line 54

def self.neuron_types; @@neuron_types ; end

.type_nameObject

Type names must always be unique for Neurons. TODO: Enforce uniqueness in neural type names



35
36
37
# File 'lib/rubyneat/neuron.rb', line 35

def self.type_name
  @type_name ||= self.to_s.split('::').last.split('Neuron').first.downcase
end

Instance Method Details

#bias?Boolean

Returns:

  • (Boolean)


44
# File 'lib/rubyneat/neuron.rb', line 44

def bias? ; self.class.bias? ; end

#express(instance) ⇒ Object

Function must be implemented by subclasses for phenotype generation. Basically, an instance is passed to this function and it will add a function to sum all inputs and a apply an operator to the sum.



60
61
62
# File 'lib/rubyneat/neuron.rb', line 60

def express(instance)
  raise NeatException.new "express() must be implemented by subclass."
end

#input?Boolean

Returns:

  • (Boolean)


41
# File 'lib/rubyneat/neuron.rb', line 41

def input? ; self.class.input? ; end

#output?Boolean

Instantiation is of outout type?

Returns:

  • (Boolean)


47
# File 'lib/rubyneat/neuron.rb', line 47

def output? ; !!@output ; end