!759 // how many numbers to sort static final int numbers = 10; static int steps = numbers*numbers*10; // execution steps limit !include #1003139 // Assembly Machine sinterface Make { abstract int[] getProgram(int startAddress); } static L pool; static int round; p { pool = new L; new Best best; while (licensed()) { ping(); ++round; updatePool(); new HashMap scores; int[] data = makeData(); int startAddress = l(data); for (Make maker : pool) { ping(); new Grid grid; grid.set(0, data); int[] program = maker.getProgram(startAddress); grid.set(startAddress, program); runProgram_maxSteps = steps; runProgram(grid, startAddress); int score = getScore(grid); scores.put(maker, score); best.put(maker, score); } Make winner = lowest(scores); print(round + " Best score: " + scores.get(winner) + " - " + structure(winner) + ", all time: " + best.score); } } // collects LOWEST score sclass Best { A best; int score; void put(A a, int score) { if (best == null || score < this.score) { best = a; this.score = score; } } A get() { ret best; } } static int getScore(Grid g) { int errors = 0; for (int i = 0; i < numbers-1; i++) if (g.get(i) > g.get(i+1)) ++errors; ret errors; } // makeData static int[] makeData() { int[] data = new int[numbers]; for (int i = 0; i < numbers; i++) data[i] = random(65536); ret data; } //// CONTESTANTS //// static O bubblesort_bot; sclass Bubblesort implements Make { public int[] getProgram(int startAddress) { if (bubblesort_bot == null) bubblesort_bot = hotwire("#1003147"); ret (int[]) call(bubblesort_bot, "getProgram", startAddress); } } // updatePool static void updatePool() { pool.clear(); pool.add(new Bubblesort); }