Class: Wongi::Engine::NccPartner

Inherits:
BetaNode
  • Object
show all
Defined in:
lib/wongi-engine/beta/ncc_partner.rb

Instance Attribute Summary collapse

Attributes inherited from BetaNode

#children, #parent, #rete

Instance Method Summary collapse

Methods inherited from BetaNode

#beta_memory, #depth, #filter_node, #join_node, #ncc_node, #neg_node, #network, #optional_node, #update_above

Methods included from CoreExt

included

Constructor Details

#initialize(parent) ⇒ NccPartner

Returns a new instance of NccPartner.



10
11
12
13
14
# File 'lib/wongi-engine/beta/ncc_partner.rb', line 10

def initialize parent
  super
  #    @conjuncts = 0
  @tokens = []
end

Instance Attribute Details

#divergentObject

Returns the value of attribute divergent.



8
9
10
# File 'lib/wongi-engine/beta/ncc_partner.rb', line 8

def divergent
  @divergent
end

#nccObject

attr_accessor :conjuncts



7
8
9
# File 'lib/wongi-engine/beta/ncc_partner.rb', line 7

def ncc
  @ncc
end

#tokensObject (readonly)

Returns the value of attribute tokens.



5
6
7
# File 'lib/wongi-engine/beta/ncc_partner.rb', line 5

def tokens
  @tokens
end

Instance Method Details

#left_activate(token) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/wongi-engine/beta/ncc_partner.rb', line 16

def left_activate token
  t = Token.new token, nil, {}
  t.node = self
  #    owners_t = t
  #  #  owners_w = t.wme
  #    conjuncts.times do
  #  #    owners_w = owners_t.wme
  #      owners_t = owners_t.parent
  #    end
  owner = nil
  ncc.tokens.each do |ncc_token|
    # if ncc_token.parent == owners_t
    if ncc_token.parent.node == divergent
      owner = ncc_token
      break
    end
  end
  if owner
    owner.ncc_results << t
    t.owner = owner
    owner.delete_children
  else
    tokens << t
  end
end