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

62
LINES

< > BotCompany Repo | #1026381 // DynPhilosophyBotTextArea

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (20297L/149K).

1  
abstract sclass DynPhilosophyBotTextArea extends DynTextArea {
2  
  S output, logicRules, factsOut;
3  
  int nFacts;
4  
  bool enabled = true;
5  
  
6  
  transient PhilosophyBot1 bot;
7  
  transient ReliableSingleThread rstRunProgram = dm_rst(this, r runProgram);
8  
  transient JLabel lblStatus;
9  
  transient ReliableSingleThread rstLogicRules = dm_rst(this, r showLogicRules);
10  
  transient ReliableSingleThread rstFactsOut = dm_rst(this, r showFactsDeduced);
11  
  
12  
  visual jvsplit(
13  
    jCenteredSection("Program", super),
14  
    centerAndSouth(
15  
      jhsplit(
16  
        jCenteredSection("Output", dm_textArea_scrollDown_readOnly output()),
17  
        jCenteredLiveValueSection(dm_calculatedLiveValue(S,
18  
          () -> "Facts deduced (" + nFacts + ")"), dm_textArea_scrollDown_readOnly factsOut())
19  
      ),
20  
      withLeftRightAndBottomMargin(centerAndEastWithMargin(
21  
        jline(dm_checkBox enabled(), jThreadedButton("Save as test case", r saveAsTestCase)),
22  
        lblStatus = jRightAlignedLabel()))));
23  
  
24  
  start {
25  
    grabInterval = 1.0;
26  
    dm_watchField text(rstRunProgram);
27  
    dm_watchFieldAndNow enabled(rstRunProgram);
28  
  }
29  
  
30  
  void runProgram {
31  
    if (!enabled) ret;
32  
    temp tempMiniLoadingAnim();
33  
    time {
34  
      setField(output := hijackPrint(r {
35  
        pcall {
36  
          bot = new PhilosophyBot1(text);
37  
          bot.printFactsAfterThinking = false;
38  
          bot.onLogicRuleAdded.add(rule -> rstLogicRules.run());
39  
          bot.onFactAdded.add(f -> rstFactsOut.run());
40  
          pb_allStandardFeatures(bot);
41  
          bot.run();
42  
          bot.checkExpectations();
43  
        }
44  
      }));
45  
    }
46  
    main setText(lblStatus, lastTiming_formatted());
47  
  }
48  
  
49  
  void showLogicRules {
50  
    setField(logicRules := joinWithEmptyLines(allToString(cloneList(bot.logicRules))));
51  
  }
52  
  
53  
  void showFactsDeduced {
54  
    Cl<S> facts = bot.factsDeduced();
55  
    setField(nFacts := l(facts));
56  
    setField(factsOut := lines(facts));
57  
  }
58  
  
59  
  void saveAsTestCase enter {
60  
    dm_call(dm_aiMusingsCRUD(), 'storeMusing, getText());
61  
  }
62  
}

Author comment

Began life as a copy of #1026373

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1026381
Snippet name: DynPhilosophyBotTextArea
Eternal ID of this version: #1026381/17
Text MD5: e80c0dd92093021e26d06bfa3eea4401
Transpilation MD5: 51d6f475714e3ecc9287161cd5b57bc4
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-20 16:24:29
Source code size: 2059 bytes / 62 lines
Pitched / IR pitched: No / No
Views / Downloads: 250 / 647
Version history: 16 change(s)
Referenced in: [show references]