1 | sclass ExternalAI { |
2 | O ai; |
3 | |
4 | *(S progID) { |
5 | S code = loadProgramTextFile(progID, "winner.text"); |
6 | if (empty(code)) fail("No winner in program, please run it first: " + progID); |
7 | O program = hotwire(progID); |
8 | ai = unstructureInRealm(code, program); |
9 | } |
10 | |
11 | sclass Game { |
12 | Pt submitted; |
13 | |
14 | L submit(O point) { |
15 | submitted = (Pt) quickImport(point); |
16 | null; |
17 | } |
18 | } |
19 | |
20 | Pt call(BufferedImage img) { |
21 | new Game game; |
22 | pcall { |
23 | O rgbImage = nuForeignObject(ai, "main$RGBImage", img); |
24 | O exportedGame = proxy(_getClass(ai, "main$GameForAI"), game); |
25 | set(ai, "game", exportedGame); |
26 | set(ai, "image", rgbImage); |
27 | callOpt(ai, "go"); |
28 | if (game.submitted != null) |
29 | print("AI " + shortClassName(ai) + " returned: " + game.submitted); |
30 | } |
31 | ret game.submitted; |
32 | } |
33 | } |
34 | |
35 | static ExternalAI loadWinnerAI(S progID) { |
36 | ret new ExternalAI(progID); |
37 | } |
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: | 491 / 503 |
Referenced in: | [show references] |