Transpiled version (1490L) is out of date.
!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<Make> pool; static int round; p { pool = new L; new Best<Make> best; while (licensed()) { ping(); ++round; updatePool(); new HashMap<Make, Number> 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> { 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); }
Began life as a copy of #1003133
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003138 |
Snippet name: | GenOpt 1 (Sorting) |
Eternal ID of this version: | #1003138/1 |
Text MD5: | 7970f21a1ca7ebc6a19d679b8a7363e5 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-05-15 17:58:09 |
Source code size: | 1996 bytes / 94 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 595 / 678 |
Referenced in: | [show references] |