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

35
LINES

< > BotCompany Repo | #1025493 // The AI Should [LIVE]

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

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

!7

set flag AllowMetaCode. set flag Reparse. meta-transformNow { tok_standardBot }

standard bot TheAIShould {
  allServers {
    static noeq record Entry(S text) extends HasGlobalID {}
  }
  
  Map<S, Entry> db = ciMap();
  
  S add(S s) {
    if (!db.containsKey(s)) { db.put(s, new Entry(s)); change(); ret "OK, stored"; }
    ret "I know";
  }
  S remove(S s) { ret db.remove(s) != null ? with(r change, "OK, then not") : "I know"; }
  S listWithPattern(S pat) { ret or2(lines(mapValuesToList(db, x -> discord_prependGlobalID(x) + format_ellipsis(pat, x.text))), "nothing"); }

  sync S processSimplifiedLine(S s, O... _) {
    try answer super.processSimplifiedLine(s, _);
    new Matches m;
    
    meta {
      S program = [[
        The AI should ... = +
        The AI doesn't have to ... = -
        What should the AI do = listWithPattern("The AI should ...")
      ]];
      ret ai_lineEquationsToMatchX2Statements(jreplace_multi(program,
        "+", "add(\\$1);",
        "-", "remove(\\$1);"));
    }
    null;
  }
}

Author comment

Began life as a copy of #1025387

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1025493
Snippet name: The AI Should [LIVE]
Eternal ID of this version: #1025493/19
Text MD5: 768becbb75cec43ae27d23178ba1d4ca
Transpilation MD5: d7ae74e4457e5463209582c4353c021c
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 14:51:16
Source code size: 1067 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 261 / 5702
Version history: 18 change(s)
Referenced in: #1025497 - DynListBot [discord bot that manages a list with custom cmds]
#1025499 - The AI Can [dev.]
#1025521 - The AI Can v2 [dev.]