Download Jar. Uses 4489K of libraries. Click here for Pure Java version (13287L/95K).
!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<Lisp> conditions = dropLast(rule.args); Lisp out = last(rule.args); new Map<S, Lisp> matches; if (matchConditions(conditions, matches, riddle)) { //print("Yo! " + struct(matches)); web.node(lispReplaceVars(out, matches)); } } } static bool matchConditions(L<Lisp> conditions, Map<S, Lisp> m, Lisp riddle) { if (empty(conditions)) true; Lisp cond = first(conditions); for (Lisp fact : concatLists(ll(riddle), facts)) { Map<S, Lisp> 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
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: | #1007814 |
Snippet name: | Magnus Carlsen's Breakfast [WORKS] |
Eternal ID of this version: | #1007814/34 |
Text MD5: | bd8a2564a60b9055288a97c43ad5ddea |
Transpilation MD5: | 44805287a53718dee9b2e20ce2cda445 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-04-13 17:40:00 |
Source code size: | 2034 bytes / 74 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 958 / 4616 |
Version history: | 33 change(s) |
Referenced in: | #1007510 - Intelligence Machine [no longer live] #1007881 - Testing new englishToConceptLanguage_xyz [dev.] #1008005 - Intelligence Machine [LIVE at ai1.lol/wiki] backup #1008140 - Magnus Carlsens Frühstück [translation of #1007814] |