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: | 405 / 2014 |
Version history: | 1 change(s) |
Referenced in: | [show references] |