1 | static new ThreadLocal<Long> ai_search1_stepsTaken; |
2 | static new ThreadLocal<S> ai_search1_resultText; |
3 | |
4 | static O ai_search1(long limit, Iterator iterator, L testers) {
|
5 | infoBox("Iterating with " + n(testers, "tester") + "...");
|
6 | |
7 | long n = 0; |
8 | |
9 | search: while (iterator.hasNext()) {
|
10 | ping(); |
11 | if (++n > limit) {
|
12 | ai_search1_resultText.set(infoBoxAndReturn("Limit of " + limit + " reached, cancelling."));
|
13 | break; |
14 | } |
15 | |
16 | O o = iterator.next(); |
17 | |
18 | for (O tester : testers) |
19 | if (!isTrue(callF(tester, o))) |
20 | continue search; |
21 | |
22 | ai_search1_resultText.set(infoBoxAndReturn("Answer found in step " + n + "!!! >> " + o));
|
23 | ai_search1_stepsTaken.set(n); |
24 | ret o; |
25 | } |
26 | |
27 | ai_search1_stepsTaken.set(limit); |
28 | null; |
29 | } |
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: | #1010222 |
| Snippet name: | ai_search1 - enumerate & test |
| Eternal ID of this version: | #1010222/6 |
| Text MD5: | 72c7df0aca66870cc66d2a497f0e14b9 |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-09-06 21:33:43 |
| Source code size: | 794 bytes / 29 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 662 / 657 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |