Class: Wongi::Engine::BetaMemory
- Defined in:
- lib/wongi-engine/beta/beta_memory.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#last_token ⇒ Object
readonly
Returns the value of attribute last_token.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Attributes inherited from BetaNode
Instance Method Summary collapse
-
#initialize(parent) ⇒ BetaMemory
constructor
A new instance of BetaMemory.
- #left_activate(token, wme, assignments) ⇒ Object
- #seed(assignments = {}) ⇒ Object
- #subst(valuations) ⇒ Object
Methods inherited from BetaNode
#beta_memory, #depth, #filter_node, #join_node, #ncc_node, #neg_node, #network, #optional_node, #update_above
Methods included from CoreExt
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
#last_token ⇒ Object (readonly)
Returns the value of attribute last_token.
4 5 6 |
# File 'lib/wongi-engine/beta/beta_memory.rb', line 4 def last_token @last_token end |
#tokens ⇒ Object (readonly)
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
#left_activate(token, wme, assignments) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/wongi-engine/beta/beta_memory.rb', line 26 def left_activate token, wme, assignments # puts "MEMORY #{@id} left-activated with #{wme}" t = Token.new( token, wme, assignments) t.node = self @last_token = t @tokens << t self.children.each do |child| if child.kind_of? BetaMemory child.left_activate t, nil, {} else child.left_activate t end end end |
#seed(assignments = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/wongi-engine/beta/beta_memory.rb', line 11 def seed assignments = {} t = Token.new( nil, nil, assignments ) t.node = self @tokens << t end |
#subst(valuations) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/wongi-engine/beta/beta_memory.rb', line 17 def subst valuations token = @tokens.first token.delete true valuations.each { |variable, value| token.subst variable, value } self.children.each do |child| child.left_activate token end end |