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

45
LINES

< > BotCompany Repo | #1025521 // The AI Can v2 [dev.]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 5909K of libraries. Click here for Pure Java version (9818L/51K).

1  
!7
2  
3  
set flag AllowMetaCode.
4  
5  
standardBot1 TheAICan_v2 {
6  
  allServers {
7  
    static noeq record Procedure(S text) extends HasGlobalID {
8  
    }
9  
    
10  
    static noeq record Entry(S text) extends HasGlobalID {
11  
      new L<Procedure> how;
12  
    }
13  
  }
14  
  
15  
  Map<S, Entry> db = ciMap();
16  
  
17  
  S add(S s) {
18  
    if (!db.containsKey(s)) { db.put(s, new Entry(s)); change(); ret "OK, stored"; }
19  
    ret "I know";
20  
  }
21  
  S remove(S s) { ret db.remove(s) != null ? with(r change, "OK, then not") : "I know"; }
22  
  
23  
  S listWithPattern(S pat) {
24  
    ret or2(lines(mapValuesToList(db, x -> discord_prependGlobalID(x) + format_ellipsis(pat, x.text)
25  
      + appendBracketed(nMethods(x.how))
26  
    )), "nothing");
27  
  }
28  
29  
  sync S processSimplifiedLine(S s, O... _) {
30  
    try answer super.processSimplifiedLine(s, _);
31  
    new Matches m;
32  
    
33  
    meta {
34  
      S program = [[
35  
        The AI can ... = +
36  
        The AI can't actually ... = -
37  
        What can the AI do = listWithPattern("The AI can ...")
38  
      ]];
39  
      ret ai_lineEquationsToMatchX2Statements(jreplace_multi(program,
40  
        "+", "add(\\$1);",
41  
        "-", "remove(\\$1);"));
42  
    }
43  
    null;
44  
  }
45  
}

Author comment

Began life as a copy of #1025493

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1025521
Snippet name: The AI Can v2 [dev.]
Eternal ID of this version: #1025521/7
Text MD5: b75de35ff26eb709962432f07f1558f6
Transpilation MD5: 734325dc0c191861338ec0cf5b4b4e34
Author: stefan
Category: javax / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-01 19:19:46
Source code size: 1173 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 150 / 228
Version history: 6 change(s)
Referenced in: [show references]