1 | static <A> void runStrategyWhileImprovement(Best<A> best, Steppable strategy, O... _) { |
2 | double score = best.score(); |
3 | optPar int plateauLength = 1000; |
4 | long sameScoreSince = 0; |
5 | Double minRuntimeUnless100 = cast optPar minRuntimeUnless100(_); // run for this many seconds unless score = 100 % |
6 | long start = sysNow(); |
7 | while licensed { |
8 | if (strategy.step()) ret; |
9 | ++sameScoreSince; |
10 | if (best.score() != score) { |
11 | print("Improvement after " + n2(sameScoreSince, "round") + ": " + callStringifier(optParam(_, 'printer), best)); |
12 | sameScoreSince = 0; |
13 | score = best.score(); |
14 | } else if (sameScoreSince >= plateauLength && |
15 | (minRuntimeUnless100 == null || elapsedSeconds(start) >= minRuntimeUnless100)) ret; |
16 | } |
17 | } |
18 | |
19 | static <A> Best<A> runStrategyWhileImprovement(AIStrategy strategy, O... _) { |
20 | runStrategyWhileImprovement(strategy.best, strategy, _); |
21 | ret strategy.best; |
22 | } |
download show line numbers debug dex old transpilations
Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019253 |
Snippet name: | runStrategyWhileImprovement - run until there is no more improvement for 1000 rounds |
Eternal ID of this version: | #1019253/13 |
Text MD5: | b11533288c61d21233a8566a33c2f8f2 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-05-05 19:51:06 |
Source code size: | 927 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 357 / 407 |
Version history: | 12 change(s) |
Referenced in: | [show references] |