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

32
LINES

< > BotCompany Repo | #1007478 // Set originatingUniverse of all AI concepts [WORKS]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (7713L/52K/180K).

1  
!7
2  
3  
p {
4  
  final File file = getProgramFile(#1007478, "my-universe.txt");
5  
  final JTextField tf = jtextfield(trim(loadTextFile(file, aGlobalID())));
6  
  showForm("Choose your universe", tf, r-thread {
7  
    pcall-messagebox {
8  
      S myUniverse = assertPossibleGlobalID(getTextTrim(tf));
9  
      saveTextFile(file, myUniverse);
10  
      RemoteDB db = new RemoteDB(#1006463, true); // auto start AI Concepts
11  
      L<RC> l = db.xlist("AIConcept");
12  
      bool haveUniverse = false;
13  
      print("Found " + n(l, "concepts"));
14  
      for (RC rc : l) {
15  
        S id = rc.getString("globalID");
16  
        if (eq(id, myUniverse)) haveUniverse = true;
17  
        S u = rc.getString("originatingUniverse");
18  
        print(rc.id + ": " + u);
19  
        if (empty(u)) {
20  
          print("  => Adopting to " + myUniverse + "!");
21  
          rc.set(originatingUniverse := myUniverse);
22  
        }
23  
      }
24  
      if (!haveUniverse) {
25  
        print("Making universe concept " + myUniverse);
26  
        db.xnew("AIConcept", globalID := myUniverse, name := "My Universe", comment := "Feel free to rename this.", originatingUniverse := myUniverse);
27  
      }
28  
      db.close();
29  
      print("Done!");
30  
    }
31  
  });
32  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007478
Snippet name: Set originatingUniverse of all AI concepts [WORKS]
Eternal ID of this version: #1007478/17
Text MD5: 19ab07c473eae026241a7cf0b942427d
Transpilation MD5: 504e3cde8733e9230a466aab642b6ed7
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-24 14:21:03
Source code size: 1192 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 546 / 1314
Version history: 16 change(s)
Referenced in: [show references]