Class: Wongi::Engine::BetaMemory
- Inherits:
-
BetaNode
- Object
- BetaNode
- Wongi::Engine::BetaMemory
show all
- Includes:
- TokenContainer
- Defined in:
- lib/wongi-engine/beta/beta_memory.rb
Instance Attribute Summary
Attributes inherited from BetaNode
#children, #parent, #rete
Instance Method Summary
collapse
Methods inherited from BetaNode
#assignment_node, #depth, #initialize, #refresh, #root?
Methods included from CoreExt
included
Instance Method Details
#beta_activate(token) ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/wongi-engine/beta/beta_memory.rb', line 19
def beta_activate token
existing = tokens.find { |et| et.duplicate? token }
return if existing token.overlay.add_token(token, self)
children.each do |child|
child.beta_activate token
end
token
end
|
#beta_deactivate(token) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/wongi-engine/beta/beta_memory.rb', line 29
def beta_deactivate token
return nil unless tokens.find token
token.overlay.remove_token(token, self)
token.deleted!
if token.parent
token.parent.children.delete token end
children.each do |child|
child.beta_deactivate token
end
token
end
|
#refresh_child(child) ⇒ Object
42
43
44
45
46
|
# File 'lib/wongi-engine/beta/beta_memory.rb', line 42
def refresh_child child
tokens.each do |token|
child.beta_activate token
end
end
|
#seed(assignments = {}) ⇒ Object
6
7
8
9
10
|
# File 'lib/wongi-engine/beta/beta_memory.rb', line 6
def seed assignments = {}
@seed = assignments
t = Token.new( self, nil, nil, assignments )
rete.default_overlay.add_token(t, self)
end
|
#subst(valuations) ⇒ Object
12
13
14
15
16
17
|
# File 'lib/wongi-engine/beta/beta_memory.rb', line 12
def subst valuations
beta_deactivate(tokens.first)
token = Token.new( self, nil, nil, @seed )
valuations.each { |variable, value| token.subst variable, value }
beta_activate(token)
end
|