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

190
LINES

< > BotCompany Repo | #1008131 // Compare Bot 4 [full rule application, dev.]

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

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

1  
!759
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  
  
86  
p-tt {
87  
  centerHigherConsole();
88  
  substance();
89  
  
90  
  // customize parsing and printing
91  
  set hygienicParse1_unquote;
92  
  set hygienicParse1_debug;
93  
  set englishToConceptLanguage_simple_noXYZ;
94  
  set formatXYZ_quotedVars;
95  
  
96  
  // load predefined & learned statements
97  
  useConceptsAndStatements(concepts, facts);
98  
  if (killDB) deleteDB();
99  
  loadMyTruth();
100  
  printLispStatements();
101  
  
102  
  lispStandardEvaluators();
103  
  bot();
104  
}
105  
106  
answer {
107  
  if "lisp" { printLispStatements(); ret "ok"; }
108  
  if "print" { printPrettyFacts(); ret "ok"; }
109  
  if "rule *" { applyRule_all($1); ret "ok"; }
110  
  if "step" { applyAlwaysRules_step(); ret "ok"; }
111  
  if "run" { applyAlwaysRules(defaultMax); ret "ok"; }
112  
  if "force" { force(defaultMax); ret "ok"; }
113  
}
114  
115  
svoid showQuestion() {
116  
  L<Lisp> l = lispTruth1("fxxathfdlfzgmaov");
117  
  if (l(l) > 1) warn("Multiple open questions");
118  
  if (nempty(l)) {
119  
    final Lisp q = first(l).get(0);
120  
    if (eq(currentQuestion, q)) ret;
121  
    currentQuestion = q;
122  
    print("Question: " + q);
123  
    swing {
124  
      showControls2(
125  
        centerAndSouth(
126  
          withBottomMargin(jcenteredBoldLabel(lispToEnglish_prettier(q))),
127  
          jcenteredline(answerButton("Yes"), answerButton("No"), answerButton("I don't know")));
128  
    }
129  
  }
130  
}
131  
132  
svoid runInstruction(S instructionID) {
133  
  Lisp rule = getLispTruth(instructionID);
134  
  if (rule == null) { print("Instruction not found: " + instructionID); ret; }
135  
  runInstruction(rule);
136  
}
137  
  
138  
svoid runInstruction(Lisp rule) {
139  
  print("runInstruction: " + rule);
140  
  if (rule.is("hzmtabxcmkrtffgh", 1)) // Apply X
141  
    applyRule_all(rule.raw(0));
142  
  else if (rule.is("cuutddpitkuswthu", 2)) { // While (X) => (Y)
143  
    while (ping() && matchCondition_simple(rule.get(0)))
144  
      runInstruction(rule.get(1));
145  
  } /*else if (rule.is("houyieutcmfdvgmz", 1))
146  
    execute(rule.get(0));
147  
  /*else if (rule.is("jexyjrtbtilmsmfw", 1)) // setQuestion(X)
148  
    setQuestion(rule.get(0));*/
149  
  else print("Unknown instruction type: " + rule);
150  
}
151  
152  
svoid force(long steps) {
153  
  for (long step = 0; step < steps; step++)
154  
    applyAlwaysRules_step();
155  
}
156  
157  
svoid applyAlwaysRules(long maxSteps) {
158  
  long count = 0, step = 0;
159  
  do {
160  
    count = lispChangeCount();
161  
    applyAlwaysRules_step();
162  
  } while (++step < maxSteps && lispChangeCount() != count);
163  
}
164  
165  
svoid applyAlwaysRules_step() {
166  
  for (Lisp l : lispTruth1("zvknqzxlrmuobnzx"))
167  
    applyRule_all(l.raw(0)); // TODO: not only random application
168  
  for (Lisp l : lispTruth1("chjllkocfhtwcgoj")) { // Remove (X)
169  
    unemit(l);
170  
    unemit(l.get(0));
171  
  }
172  
  for (Lisp l : lispTruth1("hzmtabxcmkrtffgh")) { // Apply X
173  
    unemit(l);
174  
    applyRule_all(l.raw(0));
175  
  }
176  
  showQuestion();
177  
}
178  
179  
static JButton answerButton(fS text) {
180  
  ret jbutton(text, r {
181  
    emit(lisp("pxavyqesoqyqbipb", currentQuestion, englishToLisp(text)), "button");
182  
    applyAlwaysRules(defaultMax);
183  
  });
184  
}
185  
186  
// hygienic parsing
187  
sS englishToConceptLanguage(S s) {
188  
  Lisp l = assertNotNull(hygienicParse1(s));
189  
  ret clUnparse(l);
190  
}

Author comment

Began life as a copy of #1008122

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: #1008131
Snippet name: Compare Bot 4 [full rule application, dev.]
Eternal ID of this version: #1008131/6
Text MD5: 429748ab6f5e07b1445f497b2f69a63d
Transpilation MD5: d4455eb37f0c34e0b35c0aa0a2b10204
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-04-29 14:57:18
Source code size: 6206 bytes / 190 lines
Pitched / IR pitched: No / No
Views / Downloads: 611 / 1285
Version history: 5 change(s)
Referenced in: [show references]