Uses 16925K of libraries. Click here for Pure Java version (9865L/68K/237K).
1 | !752 |
2 | |
3 | !include #1004972 // Text AI Include |
4 | |
5 | static Map<Class, S> initialLines() { |
6 | ret lithashmap( |
7 | ShowWindow.class, "Show the window!", |
8 | HideWindow.class, "Hide the window!", |
9 | IsShowing.class, "Is the window showing?", |
10 | Praise.class, "Nicely done, AI.", |
11 | Hello.class, "Hello AI!", |
12 | NotForMe.class, "[Statement not meant for me]", |
13 | Unclear.class, "[Unclear statement]"); |
14 | } |
15 | |
16 | // the application (show/hide window) |
17 | sconcept ShowWindow extends Interpretation {} |
18 | sconcept HideWindow extends Interpretation {} |
19 | sconcept IsShowing extends Interpretation { |
20 | new Ref answerModulator; // optional |
21 | } |
22 | |
23 | sconcept TheFlag { |
24 | bool set; |
25 | } |
26 | |
27 | static JFrame frame; |
28 | |
29 | p-substance { |
30 | //useDataDirOf("#1004930"); |
31 | |
32 | //loadAndAutoSaveConcepts(); |
33 | mainConcepts = new Concepts { |
34 | RC xfindLine(S text) { |
35 | ret main.xfindLine(text); |
36 | } |
37 | }; |
38 | mainConcepts.persist(); |
39 | |
40 | initialUnaryConcepts(initialLines()); |
41 | mainConcepts.quietSave = true; |
42 | |
43 | frame = getFrame(showImage("#1002235", "Eleu walks")); |
44 | onFrameClose(frame, r { |
45 | print("> Window closed by user."); |
46 | setFlag(false); |
47 | }); |
48 | updateVisibility(); |
49 | print("Lines: " + l(conceptsOfType("Line"))); |
50 | makeBot("Boolean Flag Test."); |
51 | methodsBot2("Boolean Flag DB.", mainConcepts, listPlus( |
52 | exposedDBMethods, "xfindLine"), mainConcepts.lock); |
53 | initConsole(); |
54 | print("AI ready to rock. Go \"Admin\" to see my commands."); |
55 | print("Or try \"show window\" and \"hide window\"."); |
56 | kevin("Hello"); |
57 | print(); |
58 | } |
59 | |
60 | static TheFlag getFlag() { |
61 | ret uniq(TheFlag.class); |
62 | } |
63 | |
64 | static S answerInterpreted(S s, Interpretation ip) { |
65 | if (ip instanceof Praise) ret kevin("Thank you :)"); |
66 | if (ip instanceof Hello) ret kevin("Hello! :)"); |
67 | if (ip instanceof NotForMe) ret kevin("Talk to the hand"); |
68 | if (ip instanceof Unclear) ret "[Unclear statement]"; |
69 | |
70 | TheFlag flag = getFlag(); |
71 | if (ip instanceof IsShowing) |
72 | ret kevin(flag.set |
73 | ? "Window is showing." |
74 | : "Window is not showing."); |
75 | |
76 | if (ip instanceof ShowWindow) { |
77 | if (flag.set) ret "Window already showing!"; |
78 | setFlag(true); updateVisibility(); |
79 | kevin("showing"); |
80 | ret "OK, showing window."; |
81 | } |
82 | |
83 | if (ip instanceof HideWindow) { |
84 | if (!flag.set) ret "Window already hidden!"; |
85 | setFlag(false); updateVisibility(); |
86 | kevin("hiding"); |
87 | ret "OK, hiding window."; |
88 | } |
89 | |
90 | null; |
91 | } |
92 | |
93 | svoid updateVisibility { |
94 | awt { |
95 | frame.setVisible(getFlag().set); |
96 | swingLater(200, r { |
97 | consoleFrame().toFront(); |
98 | }); |
99 | //focusConsole(); |
100 | } |
101 | } |
102 | |
103 | svoid admin { |
104 | runInNewThread("#1007333"); |
105 | } |
106 | |
107 | svoid setFlag(bool flag) { |
108 | cset(getFlag(), set := flag); |
109 | } |
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: | 608 / 704 |
Version history: | 10 change(s) |
Referenced in: | [show references] |