Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #1019836 // runStrategyForever - or until optimum score reached

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2290L/15K).

svoid <A> runStrategyForever(AIStrategy strategy, O... _) {
  runStrategyForever(strategy.best, strategy, _);
}

static <A> void runStrategyForever(Best<A> best, Steppable strategy, O... _) {
  optPar Double optimumValue;
  double score = best.score();
  long sameScoreSince = 0;
  while licensed {
    if (strategy.step()) ret;
    ++sameScoreSince;
    if (best.score() != score) {
      print("Improvement after " + n2(sameScoreSince, "round") + ": " + best);
      sameScoreSince = 0;
      score = best.score();
      if (optimumValue != null && eq(score, optimumValue)) ret;
    }
  }
}

Author comment

Began life as a copy of #1019253

download  show line numbers  debug dex  old transpilations   

Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019836
Snippet name: runStrategyForever - or until optimum score reached
Eternal ID of this version: #1019836/9
Text MD5: 64336017ed64c944db9ba9f917e0f674
Transpilation MD5: 36dd31fe228014d40da3c398ebd6f1d1
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-24 23:13:29
Source code size: 610 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 357 / 452
Version history: 8 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1020202 - runStrategy