Libraryless. Click here for Pure Java version (4623L/30K/100K).
!752 static BWImage bw; static Thread producer; static Reproducing rp; static ImageSurface imageSurface; !include #1004562 // column prediction p { rp = new Reproducing; bw = loadBWImage("#1004541"); //bw = makeTriangle(); imageSurface = showBWImage(bw); rp.bw = bw; //rp.imageSurfaceToUpdateWithBest = showImage(bw.getBufferedImage()); //rp.startProduction = r { produce() }; //rp.search(); //showColumnErrors("LookLeft(width=8)"); produce(); while licensed { S desc = grabFromQueue(rp.newProducts); Predictor p = makePredictor(desc); float[][] cols = rp.getCols(); double score = testColumnRange(p, cols, 0, 15, l(cols)); print(desc); print(" " + score); imageSurface.setImage(renderPrediction(desc, cols)); } } static void produce() { cancelThread(producer); producer = new Thread(r { // STRATEGY! rp.push("RepeatColumn"); rp.push("ShiftDown"); rp.push("LookLeft(width=7)"); rp.push("LookLeft(width=8)"); rp.push("LookLeft(width=9)"); rp.push("LookLeft(width=10)"); }, "Producer"); producer.start(); } sclass RepeatColumn extends Predictor { float[] nextColumn(float[] x) { ret x; } } sclass ShiftDown extends Predictor { float[] nextColumn(float[] f) { if (f == null) null; float[] g = copyColumn(f); for (int i = 1; i < l(f); i++) g[i] = f[i-1]; ret g; } } sclass LookLeft extends Predictor { int width; // how far to look left float[][] buf; int x; float[] nextColumn(float[] f) { if (f == null) null; if (buf == null) buf = new float[width][]; // exchange with data in rotating buffer // (will return null until buffer is filled) float[] g = buf[x]; buf[x] = f; x = (x+1) % width; ret g; } } static BWImage makeTriangle() { int w = 30, h = w; BWImage img = new BWImage(w, h); for y to h: for x to w: img.setPixel(x, y, x < y ? 1 : 0); ret img; }
Began life as a copy of #1004557
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004563 |
Snippet name: | Try Column Prediction |
Eternal ID of this version: | #1004563/1 |
Text MD5: | 58453f505b4167539312981bf707b68b |
Transpilation MD5: | 137f953a4b0f3610bb7559aaf22788e0 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-21 16:22:54 |
Source code size: | 2048 bytes / 90 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 542 / 676 |
Referenced in: | #1004567 - Try Column Prediction 2 (with actual text) |