Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

37
LINES

< > BotCompany Repo | #1007134 // ExternalTextAI + loadWinnerTextAI

JavaX fragment (include)

1  
sclass ExternalTextAI {
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  
    S submitted;
13  
  
14  
    S submit(S text) {
15  
      submitted = text;
16  
      null;
17  
    }
18  
  }
19  
20  
  S 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 ExternalTextAI loadWinnerTextAI(S progID) {
36  
  ret new ExternalTextAI(progID);
37  
}

Author comment

Began life as a copy of #1006914

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: #1007134
Snippet name: ExternalTextAI + loadWinnerTextAI
Eternal ID of this version: #1007134/1
Text MD5: b2fdf52c725b6a7f2fce6482b2327e34
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-05 23:38:55
Source code size: 938 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 447 / 478
Referenced in: [show references]