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)

static Steppable nlLogic_fillBattleSpace_steppable(final NLLogicChecker_v2 c, final Collector<RuleWithParams> battleSpace, final bool debug) {
  ret new SplittableSteppable {
    volatile bool done;
    SplittableSteppable inner;
    
    {
      VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired = voidfunc(IfThen rule, NLLogicChecker_v2.Matching m) {
        if (battleSpace.add(new RuleWithParams(rule, m.matches)))
          set done;
      };
      VF4<IfThen, NLLogicChecker_v2.Matching, L<Exp>, Exp> onRuleFailed = voidfunc(IfThen rule, NLLogicChecker_v2.Matching m, L<Exp> satisfiedConditions, Exp remaining) {
        //print("satisfied conditions: " + satisfiedConditions);
        if (battleSpace.add(new FailedRule(rule, m.matches, cloneListOrNull(nullIfEmpty(satisfiedConditions)), remaining)))
          set done;
      };
      
      print("Iterating over " + n2(c.rules, "rule"));
      applyNLLogicFacts_v4_iterate_steppable_verbose.set(debug);
      inner = applyNLLogicFacts_v4_iterate_steppable(c, onRuleFired, onRuleFailed, c.rules);
    }
    
    public bool step() {
      ret !done && inner.step();
    }
    
    public L<Steppable> split(int n) {
      ret map(inner.split(n), func(final Steppable inner2) -> Steppable {
        ret new Steppable {
          public bool step() { ret !done && inner2.step(); }
        };
      });
    }
  };
}

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: 226 / 270
Version history: 8 change(s)
Referenced in: [show references]