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

50
LINES

< > BotCompany Repo | #1009821 // Soul for a bot

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

Download Jar. Uses 4489K of libraries. Click here for Pure Java version (12324L/88K).

!7

sclass Node {
  S id, name;
  *() {} *(S *id, S *name) {}
}

sS meID = 'liahcrxesjjuwuur, functionsID = 'dudnfsbhcgoeudhs;
static new L<Node> functions;

static Canvas canvas;

p-subst {
  functions = persistentList("Functions");
  canvas = showCAL(diagram(), 650, 450);
  doFrameTitle();
  calcOnConceptChanges(1000, r { canvas = showCAL(diagram(), canvas); doFrameTitle() }, false);
  bot("Soul.");
  showCommandList();
}

svoid doFrameTitle {
  setFrameTitle("Soul Bot - Happiness Level: " + happiness(), canvas);
}  

static CirclesAndLines diagram() {
  new CirclesAndLines cal;
  
  // Static circles
  Circle me = cal.circle("Me\n(Voice Assistant)\n\n" + meID, halfSizeImage(quickVisualize("Voice assistant")), 0.2, 0.4);
  int size = l(functions)*20+4;
  Circle f = cal.circle(whiteImage(size, size), 0.7, 0.65, n(functions, "function") + "\n(collection)\n\n" + functionsID);
  cal.arrow(me, "has", f);
  
  // Dynamically changing circles
  int i = 0;
  for (Node n : functions) {
    double x = 0.5 + (i++)*0.35/max(1, l(functions)-1);
    Circle fn = cal.circle(whiteImage(20, 20), x, 0.1, quote(n.name));
    cal.arrow(f, "contains", fn);
  }
  ret cal;
}

static int happiness() { ret 1+l(functions); }

answer {
  if "add function *" { functions.add(new Node(aGlobalID(), $1)); ret "OK"; }
  if "remove function *" { removeWhereParams(functions, id := $1); removeWhereParams(functions, name := $1); ret "OK"; }
}

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: #1009821
Snippet name: Soul for a bot
Eternal ID of this version: #1009821/34
Text MD5: 7f1932401c539d1cf3688ef3e2db9915
Transpilation MD5: 485d011cbc101553c17e99de6ab7ec65
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-20 03:06:34
Source code size: 1479 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 480 / 1153
Version history: 33 change(s)
Referenced in: [show references]