!7 sS theRiddle = [[ What did Magnus Carlsen eat for breakfast? ]]; sS theFacts = [[ Magnus Carlsen lives in Norway. In Norway, they eat fish. Jan Gustafsson lives in Germany. John Doe lives in Germany. In Germany, they eat Bratwurst. (Q: What did X eat for breakfast?) and (X lives in Y.) and (In Y, they eat Z.) => (A: Probably Z!) ]]; sS concepts = [[ ["vouwrrhtmajsgaby", "Q: X"], ["nywfcwkkcknzhmdy", "A: X"], ["zlydvmmyckgcyrak", "Magnus Carlsen"], ["verqumbshvchuquw", "Norway"], ["wvqzrhdaqnygqgll", "Fish"], ["bzvabitchqhqkldm", "In X, they eat Y."], ["pizxszvxocdluica", "What did X eat for Y?"], ["fhsukilpoasgkvcs", "X lives in Y."], ["oceicdfeiyftxuwi", "Probably X!"], ["eijdjqhyzheusetj", "(X) and (Y) and (Z) => (AA)"], ]]; svoid createWeb(Web web, Lisp riddle) {} svoid calc(Web web, Lisp riddle) { //print("Vars: " + vars); for (LispStatement ls : lispStatementsByHead("eijdjqhyzheusetj")) { Lisp rule = ls.term; L conditions = dropLast(rule.args); Lisp out = last(rule.args); new Map matches; if (matchConditions(conditions, matches, riddle)) { //print("Yo! " + struct(matches)); web.node(lispReplaceVars(out, matches)); } } } static bool matchConditions(L conditions, Map m, Lisp riddle) { if (empty(conditions)) true; Lisp cond = first(conditions); for (Lisp fact : concatLists(ll(riddle), facts)) { Map m2 = cloneMap(m); if (lispMatchIC_sub(cond, fact, vars, m2)) { if (matchConditions(dropFirst(conditions), m2, riddle)) { m.putAll(m2); true; } } } false; } sS getAnswer(Web web) { Lisp l = web_nodeByHead(web, "nywfcwkkcknzhmdy"); if (l != null) ret crazyEnglishFixing(conceptLanguageToEnglish_rec(l.get(0))); null; } p { setConsoleInput(firstLineFullTrim(theRiddle)); pConsoleThoughtMachine(); } !include #1007815 // Console Thought Machine