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).

!752

sS suckerID = "#1004654", algoID = "#1004663";

sclass Desc {
  S progID, params;
}

p {
  load("algoID");
  if (args.length != 0) algoID = args[0];
  if (args.length > 1) suckerID = args[1];
  
  if (isAWT()) {
    final JTextField tf = new JTextField(algoID);
    showForm("Algorithm to feed (ID):", tf, r {
      algoID = trim(tf.getText());
      save("algoID");
      thread { wakeSucker(suckerID, algoID); }
    });
  } else
    wakeSucker(suckerID, algoID);
}

static void wakeSucker(S suckerID, S algoID) {
  ping();
  algoID = fsI(algoID);

  print("Waking...");
  O sucker = run(suckerID);
  print("Loading...");
  final O algo = hotwire(algoID);
  print("Feeding...");
  
  Class intrface = getClass(sucker, "main$Algorithm");
  assertNotNull("main$Algorithm", intrface);
  O proxy = java.lang.reflect.Proxy.newProxyInstance(intrface.getClassLoader(),
     new Class[] { intrface },
     new InvocationHandler {
       public O invoke(O proxy, Method method, O[] args) {
         assertEquals(method.getName(), "recognizeWord");
         ret call(algo, method.getName(),
           quickExport(args[0], algo),
           quickExport(args[1], algo));
       }
     });
     
  bool rep = hasMethodNamed(algo, "prepareNext");
  int count = 1;
  while (licensed() &&
    (rep ? isTrue(call(algo, "prepareNext")) : (count-- > 0))) {
    S desc = algoID;
    S params = cast callOpt(algo, "getParams");
    if (nempty(params)) desc += " " + params;
    O result = callOpt(sucker, "suck", desc, proxy);
    print("Suck Result: " + struct(result));
  } 
  
  cleanUp(algo);
  cleanUp(sucker);
}

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: 512 / 730
Referenced in: #1004699 - Feed Text Predict Sucker