1 | static int ai_solveQuestionInSubSpace_limit = 10000; |
2 | static bool ai_solveQuestionInSubSpace_saveIfSuccessful = true; |
3 | |
4 | static S ai_solveQuestionInSubSpace_noTimeOut(L<T3<S>> seeds, L<T3<S>> lookingFor) { |
5 | ret pairB(ai_solveQuestionInSubSpace_noTimeOut2(seeds, lookingFor)); |
6 | } |
7 | |
8 | static Pair<AI_SubSpace, S> ai_solveQuestionInSubSpace_noTimeOut2(L<T3<S>> seeds, L<T3<S>> lookingFor) { |
9 | ret ai_solveQuestionInSubSpace_noTimeOut2(seeds, lookingFor, f ai_solveQuestionInSubSpace_defaultStep); |
10 | } |
11 | |
12 | static Pair<AI_SubSpace, S> ai_solveQuestionInSubSpace_noTimeOut2(L<T3<S>> seeds, L<T3<S>> lookingFor, O stepFunction) { |
13 | AI_SubSpace subSpace = new(ai_solveQuestionInSubSpace_limit); |
14 | ai_setSubSpace(subSpace); |
15 | try { |
16 | for (T3<S> seed : seeds) |
17 | subSpace.postTriple(seed); // force it to be posted in SubSpace even if it exists already in main space |
18 | for (T3<S> t : lookingFor) |
19 | subSpace.postTriple(t3("_goal", "is", ai_renderTriple(t))); |
20 | |
21 | int step = 0; |
22 | while (!subSpace.limitReached()) { |
23 | ++step; |
24 | int n = l(subSpace.webs); |
25 | print("Solving question: " + allToString(lookingFor) + " (step " + step + ", " + n + "/" + subSpace.limit + ")"); |
26 | |
27 | pcall-short { |
28 | callF(stepFunction); |
29 | } |
30 | |
31 | L<Web> newWebs = cloneSubList(subSpace.webs, n); |
32 | ai_spec_possiblyToActually(newWebs); |
33 | |
34 | for (T3<S> t : lookingFor) { |
35 | S a = ai_text(t); |
36 | if (a != null) { |
37 | if (ai_solveQuestionInSubSpace_saveIfSuccessful) |
38 | saveGZStructure(countTillNewFile(programFile("logged-subspaces/subspace"), ".gz"), subSpace); |
39 | ret pair(subSpace, a); |
40 | } |
41 | } |
42 | |
43 | if (l(subSpace.webs) == n) { |
44 | print("Got " + nWeb(n) + ". No new webs made"); |
45 | break; |
46 | } |
47 | } |
48 | |
49 | if (subSpace.limitReached()) print("Subspace limit reached"); |
50 | ret pair(subSpace, null); |
51 | } finally { |
52 | ai_setSubSpace(null); |
53 | } |
54 | } |
55 | |
56 | static Pair<AI_SubSpace, S> ai_solveQuestionInSubSpace_noTimeOut2(S q) { |
57 | Pair<L<T3<S>>> p = ai_solveQuestion_seedAndLookingFor(q); |
58 | ret ai_solveQuestionInSubSpace_noTimeOut2(p.a, p.b); |
59 | } |
60 | |
61 | svoid ai_solveQuestionInSubSpace_defaultStep { |
62 | AI_SubSpace subSpace = ai_currentSubSpace(); |
63 | for (S term : concatLists(keys(subSpace.index), allToString(keys(subSpace.websByID)))) |
64 | ai_speculate(term); |
65 | |
66 | // Random stuff! |
67 | |
68 | ai_spec_answerPattern(); |
69 | ai_spec_daysOld(); |
70 | } |
Began life as a copy of #1012064
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: | #1012068 |
Snippet name: | ai_solveQuestionInSubSpace_noTimeOut |
Eternal ID of this version: | #1012068/29 |
Text MD5: | db9e68d205fa7023c316d7baeac3b87e |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-12-13 01:47:15 |
Source code size: | 2466 bytes / 70 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 547 / 551 |
Version history: | 28 change(s) |
Referenced in: | [show references] |