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

161
LINES

< > BotCompany Repo | #1008122 // Compare Bot 3 [shortened]

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

Download Jar. Uses 3874K of libraries. Click here for Pure Java version (12308L/89K).

1  
!7
2  
3  
sbool killDB = false;
4  
static int defaultMax = 1000; // steps to run
5  
6  
sS facts = [[
7  
  We want to find out what is more correct than what.
8  
  
9  
  "not correct" is a candidate.
10  
  "maybe quite correct" is a candidate.
11  
  "really really correct" is a candidate.
12  
  "buggy" is a candidate.
13  
  "total garbage" is a candidate.
14  
  "incorrect" is a candidate.
15  
  "almost correct" is a candidate.
16  
  "absolutely correct" is a candidate.
17  
  "very correct" is a candidate.
18  
  
19  
  [nfhwfngqkgoqtngs] (no question) and (X is a candidate.) and (Y is a candidate.) and (X <> Y) and (There is no answer to (Is X # more correct than Y?).) => (Ask (Is X # more correct than Y?))
20  
  // Note: The # is just a filler for parsing, we'll get rid of that in time. Also, you will be able to write stuff without brackets of course.
21  
  
22  
  Always apply rule nfhwfngqkgoqtngs.
23  
  
24  
  // Interpret answers
25  
  [iprphzfmwithvdfb] (The answer to (Is X # Y than Z?) is (yes).) => (X is Y than Z.)
26  
  Always apply rule iprphzfmwithvdfb.
27  
  [udsmtmbiedmxtxci] (The answer to (Is X # Y than Z?) is (no).) => (Z is Y than X.)
28  
  Always apply rule udsmtmbiedmxtxci.
29  
  
30  
  // Transitivity!
31  
  [pglcuchrtxdmlfvh] (X is AA than Y.) and (Y is AA than Z.) => (X is AA than Z.)
32  
  Always apply rule pglcuchrtxdmlfvh.
33  
  
34  
  [ijziyiplzanfwvqx] (Ask (X)) and (The answer to (X) is (Y).) => (Remove (Ask (X)))
35  
  Always apply rule ijziyiplzanfwvqx.
36  
  
37  
  no question :- There is no statement with operator fxxathfdlfzgmaov.
38  
  
39  
  // Just a pretty-printing statement
40  
  omrvwjslbkffaxoj hszwyiyetuuhcfwz acwmbrxqrlaplyqu
41  
]];
42  
43  
sS concepts = [[
44  
  ufzlismnlhvbjqoj - (X) and (Y) and (Z) and (AA) and (AB) => (AC)
45  
  phkdhqkhzytkwdpb - (X) and (Y) and (Z) and (AA) => (AB)
46  
  txsysipmstxmjhmi - (X) and (Y) => (Z)
47  
  wziyypnyayfphdxs - (X) => (Y)
48  
  xikyminwmeahxiws - There is no answer to (X).
49  
  pxavyqesoqyqbipb - The answer to (X) is (Y).
50  
  cdzttdbxadjreorm - We want to find out what is X than what.
51  
  ogqdgzepqbunuuht - X is a candidate.
52  
  hszwyiyetuuhcfwz - Is X # Y than Z?
53  
  acwmbrxqrlaplyqu - Is "X" Y than "Z"?
54  
  qgxjwufpfzkqvmxb - X is Y than Z.
55  
  ylvaoplzguvhegka - X is not Y than Z.
56  
  zxucpbfzmexohoiv - It is not true that (X).
57  
  buahjsodljsaxvaq - X <> Y
58  
  fxxathfdlfzgmaov - Ask (X)
59  
  chjllkocfhtwcgoj - Remove (X)
60  
  mzdvauejerzefagk - I don't know if (X)
61  
  omrvwjslbkffaxoj - Format operator X as template Y.
62  
  houyieutcmfdvgmz - Execute (X)
63  
  hzmtabxcmkrtffgh - Apply X
64  
  zvknqzxlrmuobnzx - Always apply rule X.
65  
  plprefzezbluijrw - no question
66  
  jexyjrtbtilmsmfw - setQuestion(X)
67  
  cuutddpitkuswthu - While (X) => (Y)
68  
  sicrogpdrtkiptun - X :- Y
69  
  zhoulgsatpswstfa - There is no statement with operator X.
70  
  ltyqczktgtjxrtlf - more correct
71  
  zveeggveflecjwvr - total garbage
72  
  wolealpbqkkqkvqq - not correct
73  
  tomkbzlqlpeiekvu - maybe quite correct
74  
  dnxyynujqydgcxcd - really really correct
75  
  trajdgvqepyhsumb - buggy
76  
  lwikikhkydtewtjc - incorrect
77  
  muxjpepnjiyjghwj - almost correct
78  
  wtnpjovqqiswlyay - absolutely correct
79  
  bmliokweerblfxco - very correct
80  
]];
81  
82  
!include #1008133 // MyTruth etc.
83  
84  
static Lisp currentQuestion;
85  
static Q thinkQ;
86  
  
87  
p-tt {
88  
  centerHigherConsole();
89  
  substance();
90  
  
91  
  thinkQ = new Q(true);
92  
  
93  
  // customize parsing and printing
94  
  set hygienicParse1_unquote;
95  
  set hygienicParse1_debug;
96  
  set englishToConceptLanguage_simple_noXYZ;
97  
  set formatXYZ_quotedVars;
98  
  
99  
  // load predefined & learned statements
100  
  useConceptsAndStatements(concepts, facts);
101  
  if (killDB) deleteDB();
102  
  loadMyTruth();
103  
  printLispStatements();
104  
  
105  
  lispStandardEvaluators();
106  
  bot();
107  
  
108  
  thinkQ.add(r { force(defaultMax) });
109  
}
110  
111  
answer {
112  
  if "lisp" { printLispStatements(); ret "ok"; }
113  
  if "print" { printPrettyFacts(); ret "ok"; }
114  
  if "rule *" { thinkQ.add(r { applyRule_random($1) }); ret "ok"; }
115  
  if "step" { thinkQ.add(f applyAlwaysRules); ret "ok"; }
116  
  if "run" { thinkQ.add(r { applyAlwaysRules(defaultMax) }); ret "ok"; }
117  
  if "force" { thinkQ.add(r { force(defaultMax) }); ret "ok"; }
118  
}
119  
120  
svoid showQuestion() {
121  
  L<Lisp> l = lispTruth1("fxxathfdlfzgmaov");
122  
  if (l(l) > 1) warn("Multiple open questions");
123  
  if (nempty(l)) {
124  
    final Lisp q = first(l).get(0);
125  
    if (eq(currentQuestion, q)) ret;
126  
    currentQuestion = q;
127  
    print("Question: " + q);
128  
    swing {
129  
      showControls2(
130  
        centerAndSouth(
131  
          withBottomMargin(jcenteredBoldLabel(lispToEnglish_prettier(q))),
132  
          jcenteredline(answerButton("Yes"), answerButton("No"), answerButton("I don't know")));
133  
    }
134  
  }
135  
}
136  
137  
svoid force(long steps) {
138  
  for (long step = 0; step < steps; step++)
139  
    applyAlwaysRules_step();
140  
}
141  
142  
/*svoid applyAlwaysRules_step() {
143  
  for (Lisp l : lispTruth1("zvknqzxlrmuobnzx"))
144  
    applyRule_random(l.raw(0)); // TODO: not only random application
145  
  for (Lisp l : lispTruth1("chjllkocfhtwcgoj")) { // Remove (X)
146  
    unemit(l);
147  
    unemit(l.get(0));
148  
  }
149  
  for (Lisp l : lispTruth1("hzmtabxcmkrtffgh")) { // Apply X
150  
    unemit(l);
151  
    applyRule_random(l.raw(0));
152  
  }
153  
  showQuestion();
154  
}*/
155  
156  
static JButton answerButton(fS text) {
157  
  ret jbutton(text, r {
158  
    emit(lisp("pxavyqesoqyqbipb", currentQuestion, englishToLisp(text)), "button");
159  
    thinkQ.add(r { force(defaultMax) });
160  
  });
161  
}

Author comment

Began life as a copy of #1008120

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1008122
Snippet name: Compare Bot 3 [shortened]
Eternal ID of this version: #1008122/17
Text MD5: 799fb83f0cf5f0caed95a6b2cc68bce7
Transpilation MD5: 784a2892655e3e78433a3748e9c50b71
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-13 20:31:38
Source code size: 5299 bytes / 161 lines
Pitched / IR pitched: No / No
Views / Downloads: 818 / 1658
Version history: 16 change(s)
Referenced in: [show references]