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

36
LINES

< > BotCompany Repo | #1007580 // Agent (class for logic agents)

JavaX fragment (include)

1  
abstract sclass Agent {
2  
  Collection<AIConcept> concepts;  // input
3  
  new LinkedHashSet<S> statements; // output
4  
  int duplicates; // number of already known statements emitted
5  
6  
  abstract void impl();
7  
  
8  
  void emit(Lisp l) { emit(clUnparse(l)); }
9  
  
10  
  void emit(S s) {
11  
    if (!isTruth(s) && statements.add(s))
12  
      print("> " + s + " - " + conceptLanguageToEnglish(s));
13  
    else ++duplicates;
14  
  }
15  
  
16  
  void runLive(bool doIt) {
17  
    concepts = aiConcepts();
18  
    statements.clear();
19  
    impl();
20  
    S s = "Have " + n(statements, "statements") + " to add";
21  
    if (duplicates != 0)
22  
      s += " (+" + n(duplicates, "duplicate") + ")";
23  
    print(s);
24  
    if (doIt) {
25  
      print("ADDING.");
26  
      addTruth(statements);
27  
    }
28  
  }
29  
  
30  
  void doIt { runLive(true); }
31  
  void testRun { runLive(false); }
32  
  
33  
  void runLive(S[] args) {
34  
    runLive(eqic(get(args, 0), "doit"));
35  
  }
36  
}

Author comment

Began life as a copy of #1007566

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: #1007580
Snippet name: Agent (class for logic agents)
Eternal ID of this version: #1007580/15
Text MD5: 3f9d9d0858457c8eb7c2787c74b52cd3
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-05 18:24:33
Source code size: 908 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 612 / 1216
Version history: 14 change(s)
Referenced in: [show references]