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).

1  
svoid <A> runStrategyForever(AIStrategy strategy, O... _) {
2  
  runStrategyForever(strategy.best, strategy, _);
3  
}
4  
5  
static <A> void runStrategyForever(Best<A> best, Steppable strategy, O... _) {
6  
  optPar Double optimumValue;
7  
  double score = best.score();
8  
  long sameScoreSince = 0;
9  
  while licensed {
10  
    if (strategy.step()) ret;
11  
    ++sameScoreSince;
12  
    if (best.score() != score) {
13  
      print("Improvement after " + n2(sameScoreSince, "round") + ": " + best);
14  
      sameScoreSince = 0;
15  
      score = best.score();
16  
      if (optimumValue != null && eq(score, optimumValue)) ret;
17  
    }
18  
  }
19  
}

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: 358 / 454
Version history: 8 change(s)
Referenced in: [show references]