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

51
LINES

< > BotCompany Repo | #1018348 // Test Bot v5 [steppable, Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (24222L/182K).

1  
!7
2  
3  
set flag DynModule.
4  
5  
sclass TestBot extends DynObjectTable<ExecutedRule> {
6  
  InputChooser inputChooser = new(this);
7  
  S source;
8  
  S inputAs = "Input:"; // "Input:" or "Fact:"
9  
  bool unsafeEvals;
10  
  
11  
  start {
12  
    dm_useLocalMechListCopies();
13  
    inputChooser.delay = 1000;
14  
    itemToMap = itemToMap_ExecutedRule();
15  
  }
16  
  
17  
  visualize {
18  
    ret withMargin(northAndCenter(vstackWithSpacing(
19  
      westAndCenter(dm_fieldComboBox('inputAs,
20  
        ll("Input:", "Fact:")),
21  
        wrap(inputChooser)),
22  
      withLabel("Rules mech lists (empty for default rules&facts):",
23  
        onEnter(dm_fieldTextField('source), rThread doIt)),
24  
      jrightalignedline(main.onChange(dm_fieldCheckBox("Allow unsafe evals", 'unsafeEvals), rThread doIt))),
25  
      super.visualize()));
26  
  }
27  
  
28  
  void doIt { update(inputChooser.input()); }
29  
  
30  
  void update { if (inputChooser.update()) update(inputChooser.input()); }
31  
  
32  
  void update(S input) {
33  
    temp enter();
34  
    bool inputAsFact = cic(inputAs, 'fact);
35  
    NLLogicChecker_v2.staticVerbose = true;
36  
    temp tempSetTL(nlLogic_processInputOrFact_steppable_allowUnsafeEvals, unsafeEvals);
37  
    final MultiMap<Int, ExecutedRule> mm = treeMultiMap();
38  
    Steppable steppable = nlLogic_processInputOrFact_steppable(input, inputAsFact, 
39  
      or2(trim(source), "<default>"), new Collector<ExecutedRule>() {
40  
        bool add(ExecutedRule r) {
41  
          mm.put(ai_executedRuleScorer().get(r), r);
42  
          true;
43  
        }
44  
      });
45  
    stepAllWithStats_multiThreaded(steppable);
46  
      
47  
    L<ExecutedRule> l = mm.allValues();
48  
    printLength("l=", l);
49  
    setData(l);
50  
  }
51  
}

Author comment

Began life as a copy of #1018323

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: #1018348
Snippet name: Test Bot v5 [steppable, Dyn Module]
Eternal ID of this version: #1018348/7
Text MD5: c15cc6def6e5448daf46b95fedc03be0
Transpilation MD5: f923d496ec5ed761160e16a533e5000b
Author: stefan
Category: javax / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-20 05:53:15
Source code size: 1646 bytes / 51 lines
Pitched / IR pitched: No / No
Views / Downloads: 385 / 4895
Version history: 6 change(s)
Referenced in: [show references]