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); } sclass Game { Pt submitted; L submit(O point) { submitted = (Pt) quickImport(point); null; } } 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"); if (game.submitted != null) print("AI " + shortClassName(ai) + " returned: " + game.submitted); } ret game.submitted; } } static ExternalAI loadWinnerAI(S progID) { ret new ExternalAI(progID); }