!7 sS theRiddle = [[ X is the first word in my text. Is my text a letter or a program? ]]; sS theFacts = [[ "!" is a typical first word in a program. "Hello" is a typical first word in a letter. cdtwmxtqspigpyap confirms mibnjwgfxnetaxyz. ]]; sS concepts = [[ ["zcprevyllqdmyvcn", "Is X a Y or a Z?"], ["kjuwvfidiwmbjsuc", "program"], ["xzhtvnqwzuuzixci", "letter"], ["mibnjwgfxnetaxyz", "X is the first word in Y."], ["cdtwmxtqspigpyap", "X is a typical first word in a Y."], ["kdpoqkaoypqenusd", "X confirms Y."] ]]; static JTextArea ta; static new L facts; static ReliableSingleThread computer = new ReliableSingleThread(f think); p-substance { aiEnhancements(); // Use only concepts defined in the program useConceptsDump(concepts); facts = clParse(linesToCL(theFacts)); ta = showText(""); onChangeAndNow(ta, r { computer.go() }); hideConsole(); } svoid think { time { S text = getText(ta); S w = firstWord2(text); S riddle = formatXYZ(theRiddle, quote(w)); //print(riddle); L localFacts = concatLists(facts, clParse(sentencesToCL(riddle))); S answer = solveRiddle(localFacts); S type = conceptToName(answer); print("Answer: " + or2(type, "?")); titleStatus_trailing(ta, empty(type) ? null : "Writing a " + type); } } // returns concept ID or null static S solveRiddle(L facts) { // Find the question Lisp q = findHead(facts, "zcprevyllqdmyvcn"); if (q == null) fail("No question found"); S pivot = q.s(0); L candidates = ll(q.s(1), q.s(2)); ret web_candidateWithMostConfirms(facts, pivot, candidates); }