Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

34
LINES

< > BotCompany Repo | #1018345 // nlLogic_fillBattleSpace_steppable

JavaX fragment (include)

1  
static Steppable nlLogic_fillBattleSpace_steppable(final NLLogicChecker_v2 c, final Collector<RuleWithParams> battleSpace, final bool debug) {
2  
  ret new SplittableSteppable {
3  
    volatile bool done;
4  
    SplittableSteppable inner;
5  
    
6  
    {
7  
      VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired = voidfunc(IfThen rule, NLLogicChecker_v2.Matching m) {
8  
        if (battleSpace.add(new RuleWithParams(rule, m.matches)))
9  
          set done;
10  
      };
11  
      VF4<IfThen, NLLogicChecker_v2.Matching, L<Exp>, Exp> onRuleFailed = voidfunc(IfThen rule, NLLogicChecker_v2.Matching m, L<Exp> satisfiedConditions, Exp remaining) {
12  
        //print("satisfied conditions: " + satisfiedConditions);
13  
        if (battleSpace.add(new FailedRule(rule, m.matches, cloneListOrNull(nullIfEmpty(satisfiedConditions)), remaining)))
14  
          set done;
15  
      };
16  
      
17  
      print("Iterating over " + n2(c.rules, "rule"));
18  
      applyNLLogicFacts_v4_iterate_steppable_verbose.set(debug);
19  
      inner = applyNLLogicFacts_v4_iterate_steppable(c, onRuleFired, onRuleFailed, c.rules);
20  
    }
21  
    
22  
    public bool step() {
23  
      ret !done && inner.step();
24  
    }
25  
    
26  
    public L<Steppable> split(int n) {
27  
      ret map(inner.split(n), func(final Steppable inner2) -> Steppable {
28  
        ret new Steppable {
29  
          public bool step() { ret !done && inner2.step(); }
30  
        };
31  
      });
32  
    }
33  
  };
34  
}

Author comment

Began life as a copy of #1018337

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018345
Snippet name: nlLogic_fillBattleSpace_steppable
Eternal ID of this version: #1018345/9
Text MD5: a0ba02753d8f53961b12972355f515e5
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-20 06:30:39
Source code size: 1406 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 231 / 275
Version history: 8 change(s)
Referenced in: [show references]