!7 replace Submission with BackgroundPlus. module BoxFinder > DynImageSurface { int nBoxes = 1; transient RGBImage original; transient new Best best; transient Thread recognizerThread; start { onNewImage = voidfunc(BufferedImage image) { startRecognition(image) }; setImage(whiteImage(50, 50)); // so we can paste... } double scoreImage(RGBImage image) { ret 100*(1.0-rgbDistance(image, original)); } void startRecognition(final BufferedImage image) { cancelThread(recognizerThread); recognizerThread = startThread(r { final int w = image.getWidth(), h = image.getHeight(); original = RGBImage(image); new AIStrategy_RandomWithVariation strategy; strategy.best = best; strategy.submit = func(Submission s) -> double { scoreImage(rgbRenderRenderable(w, h, s)) }; strategy.random = func -> Submission { randomBackgroundPlusBoxes(w, h, nBoxes) }; strategy.vary = func(Submission s) -> Submission { varyBackgroundPlusBoxes(s, w, h) }; runStrategyWhileImprovement(best, strategy); }); } visualize { ret jvsplit(super.visualize(), dm_printLogComponent()); } }