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

42
LINES

< > BotCompany Repo | #1014957 // AI_Racer

JavaX fragment (include)

AI > AI_Racer {
  bool verbose;
  AI_RandomWithVariation leader, overtaker;
  new Best<Submission> leadersBest;
  int discardEvery = 5000;
  int roundsSinceChange;
  
  AI_RandomWithVariation newAI() { ret new AI_RandomWithVariation; }
  
  void go {
    if (round() == 1 && leadersBest.has()) // TODO: automate this
      submit(leadersBest.get());
    else if (tossACoin()) {
      if (leader == null) leader = newAI();
      initSubAI(leader);
      Submission guess = leader.guess();
      double score = submit(guess);
      leader.updateBest(guess, score);
      leadersBest.put(guess, score);
    } else {
      if (overtaker == null) overtaker = newAI();
      initSubAI(overtaker);
      Submission guess = overtaker.guess();
      double score = submit(guess);
      overtaker.updateBest(guess, score);
      if (score > leadersBest.score()) {
        // displace leader!
        if (verbose)
          print("Overtake at " + formatScore(overtaker.best.score()) + " vs " + formatScore(leadersBest.score()));
        leader = overtaker;
        overtaker = null;
        roundsSinceChange = 0;
      } else if (roundsSinceChange++ >= discardEvery) {
        // make new overtaker
        if (verbose)
          print("Discarding overtaker at " + formatScore(overtaker.best.score()) + " vs " + formatScore(leadersBest.score()));
        overtaker = null;
        roundsSinceChange = 0;
      }
    }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1014957
Snippet name: AI_Racer
Eternal ID of this version: #1014957/2
Text MD5: 8ceaf98209eb91301cc6f936b6ddd8f6
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-07 14:27:23
Source code size: 1454 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 406 / 2016
Version history: 1 change(s)
Referenced in: #1014939 - A. I. Game 8 / Colored Boxes [OK]
#1014965 - A. I. Game 8.2 / Colored Quads [OK]
#1014979 - A. I. Game 8.3 / Colored Polys [OK]
#1014980 - A. I. Game 8.4 / Circles [OK]
#1014991 - A. I. Game 8.5 / Circles Near Center [OK]
#1014997 - A. I. Game 8.6 / Single Color [OK, if rather simple :)]
#1015005 - A. I. Game 8.7 / Rounded Boxes [OK]
#1015011 - A. I. Game 8.7 / Rounded Boxes Near Center [OK]
#1015013 - A. I. Game 8.8 / Lines with colors [OK]
#1015046 - Headless Racer AI to find lines in image - see #1015013 [OK]
#1019339 - A. I. Game 8 / Colored Boxes [showing actual boxes, OK]