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);
}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: | #1006914 |
| Snippet name: | ExternalAI + loadWinnerAI |
| Eternal ID of this version: | #1006914/1 |
| Text MD5: | c254b95501d6b34d796545a3b42ace0a |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-02-15 08:36:43 |
| Source code size: | 944 bytes / 37 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 932 / 924 |
| Referenced in: | [show references] |