static void runStrategyWhileImprovement(Best 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 Best runStrategyWhileImprovement(AIStrategy strategy, O... _) { runStrategyWhileImprovement(strategy.best, strategy, _); ret strategy.best; }