Class: Wongi::Engine::AlphaMemory

Inherits:
Object
  • Object
show all
Defined in:
lib/wongi-engine/alpha_memory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template, rete) ⇒ AlphaMemory

Returns a new instance of AlphaMemory.



5
6
7
8
9
10
# File 'lib/wongi-engine/alpha_memory.rb', line 5

def initialize(template, rete)
  @template = template
  @rete = rete
  @betas = []
  @frozen = false
end

Instance Attribute Details

#betasObject (readonly)

Returns the value of attribute betas.



3
4
5
# File 'lib/wongi-engine/alpha_memory.rb', line 3

def betas
  @betas
end

#reteObject (readonly)

Returns the value of attribute rete.



3
4
5
# File 'lib/wongi-engine/alpha_memory.rb', line 3

def rete
  @rete
end

#templateObject (readonly)

Returns the value of attribute template.



3
4
5
# File 'lib/wongi-engine/alpha_memory.rb', line 3

def template
  @template
end

Instance Method Details

#activate(wme) ⇒ Object



12
13
14
15
16
17
# File 'lib/wongi-engine/alpha_memory.rb', line 12

def activate(wme)
  # TODO: it used to activate before adding to the list. mandated by the original thesis. investigate. it appears to create duplicate tokens - needs a remedy in collecting nodes
  betas.each do |beta|
    beta.alpha_activate wme
  end
end

#deactivate(wme) ⇒ Object



19
20
21
22
23
24
# File 'lib/wongi-engine/alpha_memory.rb', line 19

def deactivate(wme)
  # p deactivate: {wme:}
  betas.each do |beta|
    beta.alpha_deactivate wme
  end
end

#inspectObject



26
27
28
# File 'lib/wongi-engine/alpha_memory.rb', line 26

def inspect
  "<Alpha #{__id__} template=#{template}>"
end

#to_sObject



30
31
32
# File 'lib/wongi-engine/alpha_memory.rb', line 30

def to_s
  inspect
end