Class: Wongi::Engine::BetaMemory
Instance Attribute Summary collapse
Attributes inherited from BetaNode
#children, #parent, #rete
Instance Method Summary
collapse
Methods inherited from BetaNode
#assignment_node, #beta_memory, #depth, #filter_node, #join_node, #ncc_node, #neg_node, #network, #optional_node, #refresh
Methods included from CoreExt
included
Constructor Details
#initialize(parent) ⇒ BetaMemory
Returns a new instance of BetaMemory.
6
7
8
9
|
# File 'lib/wongi-engine/beta/beta_memory.rb', line 6
def initialize parent
super
@tokens = []
end
|
Instance Attribute Details
#tokens ⇒ Object
Returns the value of attribute tokens.
4
5
6
|
# File 'lib/wongi-engine/beta/beta_memory.rb', line 4
def tokens
@tokens
end
|
Instance Method Details
#beta_activate(token, wme, assignments) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/wongi-engine/beta/beta_memory.rb', line 31
def beta_activate token, wme, assignments
t = Token.new( token, wme, assignments)
t.node = self
@tokens << t
self.children.each do |child|
if child.kind_of? BetaMemory
child.beta_activate t, nil, {}
else
child.beta_activate t
end
end
end
|
#delete_token(token) ⇒ Object
56
57
58
|
# File 'lib/wongi-engine/beta/beta_memory.rb', line 56
def delete_token token
tokens.delete token
end
|
#refresh_child(child) ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/wongi-engine/beta/beta_memory.rb', line 45
def refresh_child child
tokens.each do |token|
case child
when BetaMemory, NegNode
child.beta_activate token, nil, {}
else
child.beta_activate token
end
end
end
|
#seed(assignments = {}) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/wongi-engine/beta/beta_memory.rb', line 11
def seed assignments = {}
@seed = assignments
t = Token.new( nil, nil, assignments )
t.node = self
@tokens << t
end
|
#subst(valuations) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/wongi-engine/beta/beta_memory.rb', line 18
def subst valuations
@tokens.first.delete
token = Token.new( nil, nil, @seed )
token.node = self
@tokens << token
valuations.each { |variable, value| token.subst variable, value }
self.children.each do |child|
child.beta_activate token
end
end
|