static new ThreadLocal ai_search1_stepsTaken; static new ThreadLocal ai_search1_resultText; static O ai_search1(long limit, Iterator iterator, L testers) { infoBox("Iterating with " + n(testers, "tester") + "..."); long n = 0; search: while (iterator.hasNext()) { ping(); if (++n > limit) { ai_search1_resultText.set(infoBoxAndReturn("Limit of " + limit + " reached, cancelling.")); break; } O o = iterator.next(); for (O tester : testers) if (!isTrue(callF(tester, o))) continue search; ai_search1_resultText.set(infoBoxAndReturn("Answer found in step " + n + "!!! >> " + o)); ai_search1_stepsTaken.set(n); ret o; } ai_search1_stepsTaken.set(limit); null; }