Libraryless. Click here for Pure Java version (20297L/149K).
abstract sclass DynPhilosophyBotTextArea extends DynTextArea { S output, logicRules, factsOut; int nFacts; bool enabled = true; transient PhilosophyBot1 bot; transient ReliableSingleThread rstRunProgram = dm_rst(this, r runProgram); transient JLabel lblStatus; transient ReliableSingleThread rstLogicRules = dm_rst(this, r showLogicRules); transient ReliableSingleThread rstFactsOut = dm_rst(this, r showFactsDeduced); visual jvsplit( jCenteredSection("Program", super), centerAndSouth( jhsplit( jCenteredSection("Output", dm_textArea_scrollDown_readOnly output()), jCenteredLiveValueSection(dm_calculatedLiveValue(S, () -> "Facts deduced (" + nFacts + ")"), dm_textArea_scrollDown_readOnly factsOut()) ), withLeftRightAndBottomMargin(centerAndEastWithMargin( jline(dm_checkBox enabled(), jThreadedButton("Save as test case", r saveAsTestCase)), lblStatus = jRightAlignedLabel())))); start { grabInterval = 1.0; dm_watchField text(rstRunProgram); dm_watchFieldAndNow enabled(rstRunProgram); } void runProgram { if (!enabled) ret; temp tempMiniLoadingAnim(); time { setField(output := hijackPrint(r { pcall { bot = new PhilosophyBot1(text); bot.printFactsAfterThinking = false; bot.onLogicRuleAdded.add(rule -> rstLogicRules.run()); bot.onFactAdded.add(f -> rstFactsOut.run()); pb_allStandardFeatures(bot); bot.run(); bot.checkExpectations(); } })); } main setText(lblStatus, lastTiming_formatted()); } void showLogicRules { setField(logicRules := joinWithEmptyLines(allToString(cloneList(bot.logicRules)))); } void showFactsDeduced { Cl<S> facts = bot.factsDeduced(); setField(nFacts := l(facts)); setField(factsOut := lines(facts)); } void saveAsTestCase enter { dm_call(dm_aiMusingsCRUD(), 'storeMusing, getText()); } }
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: | 251 / 647 |
Version history: | 16 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |