static <A> void runStrategyWhileImprovement(Best<A> best, Steppable strategy, O... _) { double score = best.score(); optPar int plateauLength = 1000; long sameScoreSince = 0; Double minRuntimeUnless100 = cast optPar minRuntimeUnless100(_); // run for this many seconds unless score = 100 % long start = sysNow(); while licensed { if (strategy.step()) ret; ++sameScoreSince; if (best.score() != score) { print("Improvement after " + n2(sameScoreSince, "round") + ": " + callStringifier(optParam(_, 'printer), best)); sameScoreSince = 0; score = best.score(); } else if (sameScoreSince >= plateauLength && (minRuntimeUnless100 == null || elapsedSeconds(start) >= minRuntimeUnless100)) ret; } } static <A> Best<A> runStrategyWhileImprovement(AIStrategy strategy, O... _) { runStrategyWhileImprovement(strategy.best, strategy, _); ret strategy.best; }
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: | 355 / 404 |
Version history: | 12 change(s) |
Referenced in: | [show references] |