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

61
LINES

< > BotCompany Repo | #1004664 // Test Waking The Sucker (WORKS)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (3425L/23K/77K).

1  
!752
2  
3  
sS suckerID = "#1004654", algoID = "#1004663";
4  
5  
sclass Desc {
6  
  S progID, params;
7  
}
8  
9  
p {
10  
  load("algoID");
11  
  if (args.length != 0) algoID = args[0];
12  
  if (args.length > 1) suckerID = args[1];
13  
  
14  
  if (isAWT()) {
15  
    final JTextField tf = new JTextField(algoID);
16  
    showForm("Algorithm to feed (ID):", tf, r {
17  
      algoID = trim(tf.getText());
18  
      save("algoID");
19  
      thread { wakeSucker(suckerID, algoID); }
20  
    });
21  
  } else
22  
    wakeSucker(suckerID, algoID);
23  
}
24  
25  
static void wakeSucker(S suckerID, S algoID) {
26  
  ping();
27  
  algoID = fsI(algoID);
28  
29  
  print("Waking...");
30  
  O sucker = run(suckerID);
31  
  print("Loading...");
32  
  final O algo = hotwire(algoID);
33  
  print("Feeding...");
34  
  
35  
  Class intrface = getClass(sucker, "main$Algorithm");
36  
  assertNotNull("main$Algorithm", intrface);
37  
  O proxy = java.lang.reflect.Proxy.newProxyInstance(intrface.getClassLoader(),
38  
     new Class[] { intrface },
39  
     new InvocationHandler {
40  
       public O invoke(O proxy, Method method, O[] args) {
41  
         assertEquals(method.getName(), "recognizeWord");
42  
         ret call(algo, method.getName(),
43  
           quickExport(args[0], algo),
44  
           quickExport(args[1], algo));
45  
       }
46  
     });
47  
     
48  
  bool rep = hasMethodNamed(algo, "prepareNext");
49  
  int count = 1;
50  
  while (licensed() &&
51  
    (rep ? isTrue(call(algo, "prepareNext")) : (count-- > 0))) {
52  
    S desc = algoID;
53  
    S params = cast callOpt(algo, "getParams");
54  
    if (nempty(params)) desc += " " + params;
55  
    O result = callOpt(sucker, "suck", desc, proxy);
56  
    print("Suck Result: " + struct(result));
57  
  } 
58  
  
59  
  cleanUp(algo);
60  
  cleanUp(sucker);
61  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004664
Snippet name: Test Waking The Sucker (WORKS)
Eternal ID of this version: #1004664/1
Text MD5: d8a0434e06f0d632ecc089fb957399cc
Transpilation MD5: edffe36a641bbe3a31c6000d3473174e
Author: stefan
Category: javax / a.i.
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-08-25 19:37:04
Source code size: 1666 bytes / 61 lines
Pitched / IR pitched: No / No
Views / Downloads: 511 / 730
Referenced in: [show references]