static int ai_solveQuestionInSubSpace_limit = 10000; static bool ai_solveQuestionInSubSpace_saveIfSuccessful = true; static S ai_solveQuestionInSubSpace_noTimeOut(L> seeds, L> lookingFor) { ret pairB(ai_solveQuestionInSubSpace_noTimeOut2(seeds, lookingFor)); } static Pair ai_solveQuestionInSubSpace_noTimeOut2(L> seeds, L> lookingFor) { ret ai_solveQuestionInSubSpace_noTimeOut2(seeds, lookingFor, f ai_solveQuestionInSubSpace_defaultStep); } static Pair ai_solveQuestionInSubSpace_noTimeOut2(L> seeds, L> lookingFor, O stepFunction) { AI_SubSpace subSpace = new(ai_solveQuestionInSubSpace_limit); ai_setSubSpace(subSpace); try { for (T3 seed : seeds) subSpace.postTriple(seed); // force it to be posted in SubSpace even if it exists already in main space for (T3 t : lookingFor) subSpace.postTriple(t3("_goal", "is", ai_renderTriple(t))); int step = 0; while (!subSpace.limitReached()) { ++step; int n = l(subSpace.webs); print("Solving question: " + allToString(lookingFor) + " (step " + step + ", " + n + "/" + subSpace.limit + ")"); pcall-short { callF(stepFunction); } L newWebs = cloneSubList(subSpace.webs, n); ai_spec_possiblyToActually(newWebs); for (T3 t : lookingFor) { S a = ai_text(t); if (a != null) { if (ai_solveQuestionInSubSpace_saveIfSuccessful) saveGZStructure(countTillNewFile(programFile("logged-subspaces/subspace"), ".gz"), subSpace); ret pair(subSpace, a); } } if (l(subSpace.webs) == n) { print("Got " + nWeb(n) + ". No new webs made"); break; } } if (subSpace.limitReached()) print("Subspace limit reached"); ret pair(subSpace, null); } finally { ai_setSubSpace(null); } } static Pair ai_solveQuestionInSubSpace_noTimeOut2(S q) { Pair>> p = ai_solveQuestion_seedAndLookingFor(q); ret ai_solveQuestionInSubSpace_noTimeOut2(p.a, p.b); } svoid ai_solveQuestionInSubSpace_defaultStep { AI_SubSpace subSpace = ai_currentSubSpace(); for (S term : concatLists(keys(subSpace.index), allToString(keys(subSpace.websByID)))) ai_speculate(term); // Random stuff! ai_spec_answerPattern(); ai_spec_daysOld(); }