Sha256: cbb940a1783346ad62a1d181fa7ab22e0b1d0d4cddab90a1ca19903b6c45e97a

Contents?: true

Size: 455 Bytes

Versions: 4

Compression:

Stored size: 455 Bytes

Contents

module Brainz
  class Synapse
    attr_reader :from, :to, :weight
    attr_accessor :change

    def initialize(from, to)
      @weight = Kernel.rand(0.4) - 0.2
      @change = 0
      @from, @to = from, to
    end

    def adjust(diff)
      @weight += diff
    end

    def self.link(from, to)
      synapse = Synapse.new(from, to)
      to.dendrites.push(synapse)
      from.axon_synapses.push(synapse)
    end
    Kernel.srand(Time.now.to_i)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
brainz-0.2.0 lib/brainz/synapse.rb
brainz-0.1.3 lib/brainz/synapse.rb
brainz-0.1.2 lib/brainz/synapse.rb
brainz-0.1.1 lib/brainz/synapse.rb