!7 p { ExternalAI findDice = loadWinnerAI(#1006908); ExternalAI findCloseIcon = loadWinnerAI(#1006901); MouseMover mover = new MouseMover().enable(); while (!mover.hasInterference()) { BufferedImage img = shootScreen2(); Pt p = findCloseIcon.call(img); if (p != null) mover.click(p); else { p = findDice.call(img); if (p == null) infoMessage("No dice!"); else mover.click(p); } sleepSeconds(1); } } sclass ExternalAI { O ai; *(S progID) { S code = loadProgramTextFile(progID, "winner.text"); if (empty(code)) fail("No winner in program, please run it first: " + progID); O program = hotwire(progID); ai = unstructureInRealm(code, program); } Pt call(BufferedImage img) { new Game game; pcall { O rgbImage = nuForeignObject(ai, "main$RGBImage", img); O exportedGame = proxy(_getClass(ai, "main$GameForAI"), game); set(ai, "game", exportedGame); set(ai, "image", rgbImage); callOpt(ai, "go"); print("Point: " + game.submitted); } ret game.submitted; } } sclass Game { Pt submitted; L submit(O point) { submitted = (Pt) quickImport(point); null; } } static ExternalAI loadWinnerAI(S progID) { ret new ExternalAI(progID); }