Uses 13052K of libraries. Click here for Pure Java version (5954L/41K/135K).
1 | !752 |
2 | |
3 | !include #1004972 // Text AI Include |
4 | |
5 | concepts. |
6 | |
7 | concept Question extends Interpretation {} |
8 | |
9 | concept HowManyMonthsInYear extends Question { |
10 | int year; |
11 | } |
12 | |
13 | concept NumberOfMonthsInYear { |
14 | new Ref question; |
15 | int year, months; |
16 | } |
17 | |
18 | static Concept answerQuestion(Question q) { |
19 | if (q instanceof HowManyMonthsInYear) { |
20 | sleepSeconds(1); |
21 | new NumberOfMonthsInYear a; |
22 | a.question.set(q); |
23 | copyFields(q, a, "year"); |
24 | a.months = 12; // The answer! |
25 | change(); |
26 | ret a; |
27 | } |
28 | null; // unknown question |
29 | } |
30 | |
31 | static S renderAnswer(Concept a) { |
32 | if (a instanceof NumberOfMonthsInYear) { |
33 | NumberOfMonthsInYear aa = cast a; |
34 | ret "There are " + n(aa.months, "month") + " in the year " + aa.year + "."; |
35 | } |
36 | null; |
37 | } |
38 | |
39 | static S dbName; |
40 | |
41 | p { |
42 | dbName = fsI(programID()); |
43 | loadAndAutoSaveConcepts(); |
44 | makeBot("Calendar AI 1."); |
45 | methodsBot(dbName, listPlus(exposedDBMethods, "xfindLine")); |
46 | initConsole(); |
47 | print("AI ready to rock. Go \"Admin\" to see my commands."); |
48 | //kevin("Hello"); |
49 | print(); |
50 | } |
51 | |
52 | static S answerInterpreted(S s, Interpretation ip) { |
53 | if (ip instanceof Question) { |
54 | Concept a = answerQuestion((Question) ip); |
55 | if (a == null) |
56 | ret "No idea"; |
57 | else { |
58 | S text = renderAnswer(a); |
59 | if (nempty(text)) ret text; |
60 | ret "I have an answer, but don't know how to tell you unfortunately"; |
61 | } |
62 | } |
63 | |
64 | null; |
65 | } |
66 | |
67 | svoid admin {} |
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: | #1005031 |
Snippet name: | Calendar AI [dev.] |
Eternal ID of this version: | #1005031/1 |
Text MD5: | dd58ab3d2637c623ea6393bcacd098b6 |
Transpilation MD5: | 1922f44777a91f9facf27becebf9706c |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-09-29 19:49:04 |
Source code size: | 1447 bytes / 67 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 492 / 552 |
Referenced in: | [show references] |