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

45
LINES

< > BotCompany Repo | #1010266 // Computer Understands Today's Project [Backup]

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

Download Jar. Uses 3874K of libraries. Click here for Pure Java version (14632L/105K).

1  
!7
2  
3  
sS inputDiagrams = [[
4  
  CirclesAndLines(circles=[Circle(text="Today's project", x=d("0.24927953890489912"), y=d("0.1760154738878143")), Circle(text="Showing", x=d("0.24639769452449567"), y=d("0.4816247582205029")), Circle(text="a JButton", x=d("0.5547550432276657"), y=d("0.4796905222437137")), Circle(text="an image", x=d("0.43948126801152737"), y=d("0.758220502901354")), Circle(text="a text", x=d("0.7103746397694525"), y=d("0.7620889748549323"))], lines=[Arrow(a=t5, b=t26, text="is"), Arrow(a=t26, b=t47, text=""), Arrow(a=t47, b=t68, text="with"), Arrow(a=t47, b=t89, text="with")], title="Today's project")
5  
  CirclesAndLines(circles=[Circle(text="What I can do", x=d("0.24927953890489912"), y=d("0.1760154738878143")), Circle(text="Showing", x=d("0.24639769452449567"), y=d("0.4816247582205029")), Circle(text="a JButton", x=d("0.5547550432276657"), y=d("0.4796905222437137")), Circle(text="a text", x=d("0.7103746397694525"), y=d("0.7620889748549323"))], lines=[Arrow(a=t5, b=t26, text="is"), Arrow(a=t26, b=t47, text=""), Arrow(a=t47, b=t68, text="with")], title="What I could already do")
6  
  CirclesAndLines(circles=[Circle(text="What I can do", x=d("0.24927953890489912"), y=d("0.1760154738878143")), Circle(text="Showing", x=d("0.24639769452449567"), y=d("0.4816247582205029")), Circle(text="a JButton", x=d("0.5547550432276657"), y=d("0.4796905222437137")), Circle(text="an image", x=d("0.41210374639769454"), y=d("0.758220502901354"))], lines=[Arrow(a=t5, b=t26, text="is"), Arrow(a=t26, b=t47, text=""), Arrow(a=t47, b=t68, text="with")], title="What I could already do 2")
7  
]];
8  
9  
p-subst {
10  
  L<Web> webs = websFromCALStructures(inputDiagrams);
11  
  JTextPane tpAnswer = setFont(sansSerif(20), jcenteredtextpane());
12  
  setFrameSize(700, 500, showTabbedWebs(listPlus((L) moveFirstToEnd(cloneList(webs)), "Computer's Insight", jTiledBackground(whiteImage(10, 10), jFullCenter(tpAnswer)))));
13  
  
14  
  // Just print some stuff
15  
  
16  
  print(web_starterNodes(first(webs)));
17  
  
18  
  webs = map cloneWeb(webs);
19  
  L<WebTree> trees = map(webs, func(Web web) {
20  
    webTree_sortChildren(webTree_renameHead("*", web_makeTree(web_starterNode(web))))
21  
  });
22  
  map web_printWebTree(trees);
23  
  
24  
  // Do the actual calculation
25  
26  
  L<Pair<WebNode>> diff1 = webs_differingNodes(first(webs), second(webs));
27  
  L<Pair<WebNode>> diff2 = webs_differingNodes(first(webs), last(webs));
28  
  if (l(diff1) == 1 && l(diff2) == 1) {
29  
    Pair<WebNode> a = first(diff1), b = first(diff2);
30  
    if (a.a == b.a) {
31  
      WebNode node = a.a;
32  
      L<WebNode> nu = web_forwardRelated(node);
33  
      L<WebNode> old1 = web_forwardRelated(a.b);
34  
      L<WebNode> old2 = web_forwardRelated(b.b);
35  
      Set<S> t_nu = web_textSet(nu), t_old1 = web_textSet(old1), t_old2 = web_textSet(old2);
36  
      if (eq(t_nu, joinTreeSets(t_old1, t_old2))) {
37  
        S answer = "AHA!!!\n\nYou want to combine " + join(" AND ", t_nu) + " into " + web_text(node) + ".";
38  
        int seconds = 100;
39  
        setText(tpAnswer, answer);
40  
        JWindow box = infoBox(answer, seconds);
41  
        moveWindowDown(showAnim(#1010239, seconds), box.getHeight()+20);
42  
      }
43  
    }
44  
  }
45  
}

Author comment

Began life as a copy of #1010237

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: #1010266
Snippet name: Computer Understands Today's Project [Backup]
Eternal ID of this version: #1010266/1
Text MD5: bfd330febdd59f43bd4bcbb342e2d4a2
Transpilation MD5: 78082c30650b259dc284acd19c9e88ad
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-09-07 20:11:43
Source code size: 3147 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 499 / 1124
Referenced in: [show references]