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