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

48
LINES

< > BotCompany Repo | #1018323 // Test Bot v4 [with failed rules, Dyn Module]

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

Libraryless. Click here for Pure Java version (24029L/180K).

!7

set flag DynModule.

sclass TestBot extends DynObjectTable<ExecutedRule> {
  InputChooser inputChooser = new(this);
  S source;
  S inputAs = "Input:"; // "Input:" or "Fact:"
  bool unsafeEvals;
  
  start {
    dm_useLocalMechListCopies();
    inputChooser.delay = 1000;
    itemToMap = itemToMap_ExecutedRule();
  }
  
  visualize {
    ret withMargin(northAndCenter(vstackWithSpacing(
      westAndCenter(dm_fieldComboBox('inputAs,
        ll("Input:", "Fact:")),
        wrap(inputChooser)),
      withLabel("Rules mech lists (empty for default rules&facts):",
        onEnter(dm_fieldTextField('source), rThread doIt)),
      jrightalignedline(main.onChange(dm_fieldCheckBox("Allow unsafe evals", 'unsafeEvals), rThread doIt))),
      super.visualize()));
  }
  
  void doIt { update(inputChooser.input()); }
  
  void update { if (inputChooser.update()) update(inputChooser.input()); }
  
  void update(S input) {
    temp enter();
    bool inputAsFact = cic(inputAs, 'fact);
    NLLogicChecker_v2.staticVerbose = true;
    temp tempSetTL(nlLogic_processInputOrFact_withFailed_allowUnsafeEvals, unsafeEvals);
    L<ExecutedRule> l = nlLogic_processInputOrFact_withFailed(input, inputAsFact, 
      or2(trim(source), "<default>"));
      
    // Successful rules first
    sortInPlaceByCalculatedField(l, func(ExecutedRule r) -> Int {
      int n = r.failureLevel();
      ret n == 0 ? 0 : n < 0 ? 1 : Int.MAX_VALUE-n;
    });
    printLength("l=", l);
    setData(l);
  }
}

Author comment

Began life as a copy of #1018272

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: #1018323
Snippet name: Test Bot v4 [with failed rules, Dyn Module]
Eternal ID of this version: #1018323/9
Text MD5: 78b0476ce932910bd510852987a46d1a
Transpilation MD5: fbdf6b5fe12ac1648e8be1b9f4e64cfa
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-19 22:05:34
Source code size: 1530 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 295 / 484
Version history: 8 change(s)
Referenced in: [show references]