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).

!7

sbool killDB = false;
static int defaultMax = 1000; // steps to run

sS facts = [[
  We want to find out what is more correct than what.
  
  "not correct" is a candidate.
  "maybe quite correct" is a candidate.
  "really really correct" is a candidate.
  "buggy" is a candidate.
  "total garbage" is a candidate.
  "incorrect" is a candidate.
  "almost correct" is a candidate.
  "absolutely correct" is a candidate.
  "very correct" is a candidate.
  
  [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?))
  // 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.
  
  Always apply rule nfhwfngqkgoqtngs.
  
  // Interpret answers
  [iprphzfmwithvdfb] (The answer to (Is X # Y than Z?) is (yes).) => (X is Y than Z.)
  Always apply rule iprphzfmwithvdfb.
  [udsmtmbiedmxtxci] (The answer to (Is X # Y than Z?) is (no).) => (Z is Y than X.)
  Always apply rule udsmtmbiedmxtxci.
  
  // Transitivity!
  [pglcuchrtxdmlfvh] (X is AA than Y.) and (Y is AA than Z.) => (X is AA than Z.)
  Always apply rule pglcuchrtxdmlfvh.
  
  [ijziyiplzanfwvqx] (Ask (X)) and (The answer to (X) is (Y).) => (Remove (Ask (X)))
  Always apply rule ijziyiplzanfwvqx.
  
  no question :- There is no statement with operator fxxathfdlfzgmaov.
  
  // Just a pretty-printing statement
  omrvwjslbkffaxoj hszwyiyetuuhcfwz acwmbrxqrlaplyqu
]];

sS concepts = [[
  ufzlismnlhvbjqoj - (X) and (Y) and (Z) and (AA) and (AB) => (AC)
  phkdhqkhzytkwdpb - (X) and (Y) and (Z) and (AA) => (AB)
  txsysipmstxmjhmi - (X) and (Y) => (Z)
  wziyypnyayfphdxs - (X) => (Y)
  xikyminwmeahxiws - There is no answer to (X).
  pxavyqesoqyqbipb - The answer to (X) is (Y).
  cdzttdbxadjreorm - We want to find out what is X than what.
  ogqdgzepqbunuuht - X is a candidate.
  hszwyiyetuuhcfwz - Is X # Y than Z?
  acwmbrxqrlaplyqu - Is "X" Y than "Z"?
  qgxjwufpfzkqvmxb - X is Y than Z.
  ylvaoplzguvhegka - X is not Y than Z.
  zxucpbfzmexohoiv - It is not true that (X).
  buahjsodljsaxvaq - X <> Y
  fxxathfdlfzgmaov - Ask (X)
  chjllkocfhtwcgoj - Remove (X)
  mzdvauejerzefagk - I don't know if (X)
  omrvwjslbkffaxoj - Format operator X as template Y.
  houyieutcmfdvgmz - Execute (X)
  hzmtabxcmkrtffgh - Apply X
  zvknqzxlrmuobnzx - Always apply rule X.
  plprefzezbluijrw - no question
  jexyjrtbtilmsmfw - setQuestion(X)
  cuutddpitkuswthu - While (X) => (Y)
  sicrogpdrtkiptun - X :- Y
  zhoulgsatpswstfa - There is no statement with operator X.
  ltyqczktgtjxrtlf - more correct
  zveeggveflecjwvr - total garbage
  wolealpbqkkqkvqq - not correct
  tomkbzlqlpeiekvu - maybe quite correct
  dnxyynujqydgcxcd - really really correct
  trajdgvqepyhsumb - buggy
  lwikikhkydtewtjc - incorrect
  muxjpepnjiyjghwj - almost correct
  wtnpjovqqiswlyay - absolutely correct
  bmliokweerblfxco - very correct
]];

!include #1008133 // MyTruth etc.

static Lisp currentQuestion;
static Q thinkQ;
  
p-tt {
  centerHigherConsole();
  substance();
  
  thinkQ = new Q(true);
  
  // customize parsing and printing
  set hygienicParse1_unquote;
  set hygienicParse1_debug;
  set englishToConceptLanguage_simple_noXYZ;
  set formatXYZ_quotedVars;
  
  // load predefined & learned statements
  useConceptsAndStatements(concepts, facts);
  if (killDB) deleteDB();
  loadMyTruth();
  printLispStatements();
  
  lispStandardEvaluators();
  bot();
  
  thinkQ.add(r { force(defaultMax) });
}

answer {
  if "lisp" { printLispStatements(); ret "ok"; }
  if "print" { printPrettyFacts(); ret "ok"; }
  if "rule *" { thinkQ.add(r { applyRule_random($1) }); ret "ok"; }
  if "step" { thinkQ.add(f applyAlwaysRules); ret "ok"; }
  if "run" { thinkQ.add(r { applyAlwaysRules(defaultMax) }); ret "ok"; }
  if "force" { thinkQ.add(r { force(defaultMax) }); ret "ok"; }
}

svoid showQuestion() {
  L<Lisp> l = lispTruth1("fxxathfdlfzgmaov");
  if (l(l) > 1) warn("Multiple open questions");
  if (nempty(l)) {
    final Lisp q = first(l).get(0);
    if (eq(currentQuestion, q)) ret;
    currentQuestion = q;
    print("Question: " + q);
    swing {
      showControls2(
        centerAndSouth(
          withBottomMargin(jcenteredBoldLabel(lispToEnglish_prettier(q))),
          jcenteredline(answerButton("Yes"), answerButton("No"), answerButton("I don't know")));
    }
  }
}

svoid force(long steps) {
  for (long step = 0; step < steps; step++)
    applyAlwaysRules_step();
}

/*svoid applyAlwaysRules_step() {
  for (Lisp l : lispTruth1("zvknqzxlrmuobnzx"))
    applyRule_random(l.raw(0)); // TODO: not only random application
  for (Lisp l : lispTruth1("chjllkocfhtwcgoj")) { // Remove (X)
    unemit(l);
    unemit(l.get(0));
  }
  for (Lisp l : lispTruth1("hzmtabxcmkrtffgh")) { // Apply X
    unemit(l);
    applyRule_random(l.raw(0));
  }
  showQuestion();
}*/

static JButton answerButton(fS text) {
  ret jbutton(text, r {
    emit(lisp("pxavyqesoqyqbipb", currentQuestion, englishToLisp(text)), "button");
    thinkQ.add(r { force(defaultMax) });
  });
}

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: 817 / 1653
Version history: 16 change(s)
Referenced in: #1008123 - Use External Editor For Snippet Editing [dev.]
#1008131 - Compare Bot 4 [full rule application, dev.]