sclass AI_ThoughtSpace implements AI_PostHandler, AI_CacheChecker { int limit; // 0 = no limit new TripleIndex index; *() {} *(int *limit) {} // existence of triple has already been checked public S postTriple(T3 t) { if (limitReached()) fail("Thought space limit reached"); TripleWeb w = tripleWeb(t); index.addTriple(w); ret w.globalID(); } void addWeb(Web web) { postTriple(webToTriple(web)); } public bool hasTriple(S a, S b, S c) { L webs = ai_withoutInvalidWebs(nodesToWebs(shortestList3( index.get(a), index.get(b), index.get(c)))); ret webs_search_noVar_bool(webFromTriples(a, b, c), webs); } bool limitReached() { ret limit > 0 && size() >= limit; } L indexedNodes_rawLookup(S s) { ret index.get(ai_shortenForIndex(s)); } int numWebs() { ret l(websByID); } int size() { ret numWebs(); } }