Uses 16925K of libraries. Click here for Pure Java version (9865L/68K/237K).
!752 !include #1004972 // Text AI Include static Map<Class, S> initialLines() { ret lithashmap( ShowWindow.class, "Show the window!", HideWindow.class, "Hide the window!", IsShowing.class, "Is the window showing?", Praise.class, "Nicely done, AI.", Hello.class, "Hello AI!", NotForMe.class, "[Statement not meant for me]", Unclear.class, "[Unclear statement]"); } // the application (show/hide window) sconcept ShowWindow extends Interpretation {} sconcept HideWindow extends Interpretation {} sconcept IsShowing extends Interpretation { new Ref answerModulator; // optional } sconcept TheFlag { bool set; } static JFrame frame; p-substance { //useDataDirOf("#1004930"); //loadAndAutoSaveConcepts(); mainConcepts = new Concepts { RC xfindLine(S text) { ret main.xfindLine(text); } }; mainConcepts.persist(); initialUnaryConcepts(initialLines()); mainConcepts.quietSave = true; frame = getFrame(showImage("#1002235", "Eleu walks")); onFrameClose(frame, r { print("> Window closed by user."); setFlag(false); }); updateVisibility(); print("Lines: " + l(conceptsOfType("Line"))); makeBot("Boolean Flag Test."); methodsBot2("Boolean Flag DB.", mainConcepts, listPlus( exposedDBMethods, "xfindLine"), mainConcepts.lock); initConsole(); print("AI ready to rock. Go \"Admin\" to see my commands."); print("Or try \"show window\" and \"hide window\"."); kevin("Hello"); print(); } static TheFlag getFlag() { ret uniq(TheFlag.class); } static S answerInterpreted(S s, Interpretation ip) { if (ip instanceof Praise) ret kevin("Thank you :)"); if (ip instanceof Hello) ret kevin("Hello! :)"); if (ip instanceof NotForMe) ret kevin("Talk to the hand"); if (ip instanceof Unclear) ret "[Unclear statement]"; TheFlag flag = getFlag(); if (ip instanceof IsShowing) ret kevin(flag.set ? "Window is showing." : "Window is not showing."); if (ip instanceof ShowWindow) { if (flag.set) ret "Window already showing!"; setFlag(true); updateVisibility(); kevin("showing"); ret "OK, showing window."; } if (ip instanceof HideWindow) { if (!flag.set) ret "Window already hidden!"; setFlag(false); updateVisibility(); kevin("hiding"); ret "OK, hiding window."; } null; } svoid updateVisibility { awt { frame.setVisible(getFlag().set); swingLater(200, r { consoleFrame().toFront(); }); //focusConsole(); } } svoid admin { runInNewThread("#1007333"); } svoid setFlag(bool flag) { cset(getFlag(), set := flag); }
Began life as a copy of #1004930
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xhsrmoityime
No comments. add comment
Snippet ID: | #1004973 |
Snippet name: | Fixing Admin - Refactored New AI [Show / Hide Window / Learns Any Language!] |
Eternal ID of this version: | #1004973/11 |
Text MD5: | 1c6cbc01e7825aa69f74e155b7ce4133 |
Transpilation MD5: | f2d47c873900350c06e86236e69a6921 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-03-15 14:58:20 |
Source code size: | 2728 bytes / 109 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 607 / 702 |
Version history: | 10 change(s) |
Referenced in: | [show references] |