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

47
LINES

< > BotCompany Repo | #1000387 // Empty Box learner (developing)

JavaX source code - run with: x30.jar

// These end up inside the main class

static class LEmptyBox extends LearnerImpl {
  static boolean debug;
  Learner inputLearner;
  char c;
  
  *(Learner *inputLearner) {}
  
  public void tryAgain() {
    inputLearner.tryAgain();
  }
  
  public void processInOut(Object in, Object _out) {
    String out = (String) _out;
    L<S> l = toLines(out);
    int w = l.get(1).length(), h = l.size()-1;
    String input = w + "*" + h;
    if (debug)
      System.out.println("LEmptyBox: Feeding to input learner: " + in + " => " + input);
    inputLearner.processInOut(in, input);
    if (debug)
      System.out.println("Input learner: " + structure(inputLearner));
    c = l.get(1).charAt(0);
    if (debug)
      System.out.println("LEmptyBox: c=" + c);
  }
  
  public Object processIn(Object in) {
    String input = (String) inputLearner.processIn(in);
    if (debug)
      System.out.println("LEmptyBox: in=" + in + ", input=" + input);
    String[] split = input.split("\\*");
    int w = Integer.parseInt(split[0]), h = Integer.parseInt(split[1]);
    new StringBuilder buf;
    buf.append("\n");
    buf.append(main.repeat(c, w) + "\n");
    for (int y = 1; y < h-1; y++)
      buf.append(c + main.repeat(' ', w-2) + c + "\n");
    buf.append(main.repeat(c, w) + "\n");
    return buf.toString();
  }
  
  public void toJava(Code code) {
    todo();
  }
}

Author comment

Began life as a copy of #1000382

download  show line numbers  debug dex  old transpilations   

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

2 comment(s) hidden. show

Snippet ID: #1000387
Snippet name: Empty Box learner (developing)
Eternal ID of this version: #1000387/1
Text MD5: b887211f2e04d90a10670cf5b39ab922
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-10-17 01:21:12
Source code size: 1410 bytes / 47 lines
Pitched / IR pitched: No / No
Views / Downloads: 1012 / 2905
Referenced in: [show references]