!include #1007689 // Web v2 static int saveInterval = 60000; sbool clearWeb = true; // clear every time? static volatile new Web web; static L<Lisp> facts; static L<S> vars; static long lastSave, sizeSaved; extend Web { volatile transient bool cancelled, calculating; } svoid pConsoleThoughtMachine { tt(); setConsoleTitle(programTitle()); load("web"); lastSave = sysNow(); setFrameHeight(consoleFrame(), 400); centerConsole(); //magellan(); //graphite(); //mistAqua(); //moderateTheme(); sahara(); swing { if (!englishToConceptLanguage_xyz_debug) clearConsole(); consoleAddAskButton(); focusConsole(); final JLabel lblBrainSize = jRightAlignedLabel(); addToConsole2(withMargin(centerAndEast(lblBrainSize, withLeftMargin(jbutton("Reset", "reset"))))); awtEvery(lblBrainSize, 1000, r { lblBrainSize.setText("Brain Size: " + toM(fileSize(programFile("web.structure")), 1) + " MB"); }); awtCalcEvery(lblBrainSize, 1000, 1000, r { if (web.calculating) ret; int webSize = web.count(); if (shouldSave(webSize, false)) saveWeb(webSize); }); } aiEnhancements(); aiConcepts_noAutoClear(); useConceptsDump(concepts); set englishToConceptLanguage_useBrackets; vars = ll(); facts = clParse(linesToCLWithVars(theFacts, vars)); print(theFacts); useFacts_cl(clUnparse(facts)); //printNumberedLines(facts); firstRiddle(); makeBotQuietly(); //print("Type more questions if you like.\n"); notDoneQuietly(); } svoid firstRiddle { print(); for (S rid : toLinesFullTrim(theRiddle)) { print("? " + rid); print(" " + answer(rid)); } print(); } static int webSize() { ret web.count(); } sbool shouldSave(int webSize, bool checkInterval) { ret webSize != sizeSaved && (!checkInterval || sysNow() >= lastSave+saveInterval); } svoid saveWeb(int webSize) { save("web"); sizeSaved = webSize; lastSave = sysNow(); } static S answer(S rid) { web.calculating = true; try { ret answerImpl(rid); } finally { web.calculating = false; } } static S answerImpl(S rid) { if (match("facts", rid)) { printNumberedLines(facts); ret "OK"; } if (match("web", rid)) { print(web); ret "OK"; } if (match("visualize", rid)) { webToCAL(web).show(); ret "OK"; } Web web = main.web; rid = addPrefix("Q: ", rid); Lisp riddle = clParse(englishToConceptLanguage(rid)); //print("# " + riddle); // Create web if (clearWeb) web = new Web; createWeb(web, riddle); web.relations(facts); int webSize = web.count(); int cursor = 0; while licensed { if (web.cancelled) ret "cancelled"; //print("Web size: " + webSize); if (shouldSave(webSize, true)) { printWithoutNL("S"); saveWeb(webSize); } else printWithoutNL("."); if ((++cursor % 60) == 0) print(); CriticalAction action = beginCriticalAction("Web Update"); try { calc(web, riddle); } finally { action.done(); } int n = web.count(); if (n == webSize) break; webSize = n; } print(); // print question again if (cursor / 60 >= 10) print("? " + rid); // Answer question S s = getAnswer(web); s = or2(s, "I don't know"); ret s; } svoid cleanMeUp { while (criticalActionsInFlight()) sleep(5); if (sizeSaved != web.count()) save("web"); } svoid reset { if (!confirmOKCancel("Really clear the brain?")) ret; web.cancelled = true; CriticalAction action = beginCriticalAction("Resetting Brain"); try { web = new Web; sizeSaved = 0; save("web"); } finally { action.done(); } clearConsole(); firstRiddle(); }
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: | #1007815 |
Snippet name: | Console Thought Machine [Include] |
Eternal ID of this version: | #1007815/22 |
Text MD5: | 7f16bf5e608ceda3a3a247ee19bbfc76 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-04-13 17:27:27 |
Source code size: | 3816 bytes / 158 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 539 / 1136 |
Version history: | 21 change(s) |
Referenced in: | #1007814 - Magnus Carlsen's Breakfast [WORKS] #1007881 - Testing new englishToConceptLanguage_xyz [dev.] #1008140 - Magnus Carlsens Frühstück [translation of #1007814] |