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

49
LINES

< > BotCompany Repo | #1003798 // Test Random v6 Thinker

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

Libraryless. Click here for Pure Java version (2064L/14K/48K).

1  
!759
2  
3  
!include #1003797 // Thinker
4  
5  
sS detect = "<< detect";
6  
7  
static L<S> log = toLinesFullTrim([[
8  
  1
9  
  2
10  
  3 << detect
11  
  4 << detect
12  
  5 << detect
13  
]]);
14  
15  
p {
16  
  new Thinker thinker;
17  
  BitSet interestingLines = detectInterestingLines(log);
18  
  int maxScore = interestingLines.cardinality();
19  
  print("Interesting lines: " + interestingLines + "(" + maxScore + ")");
20  
  psl(log);
21  
  MultiSet<S> scores = thinker.scores(log, interestingLines);
22  
  S top = scores.getMostPopularEntry();
23  
  int score = scores.get(top);
24  
  if (score >= maxScore)
25  
    print("Fully solved by " + quote(top) + " (" + score + "/" + maxScore + ")!");
26  
  else if (score > 0)
27  
    print("Partially solved by " + quote(top) + " (" + score + "/" + maxScore + ")!");
28  
  else
29  
    print("Not solved at all.");
30  
}
31  
32  
// removes the markers from the log!
33  
static BitSet detectInterestingLines(L<S> log) {
34  
  new BitSet bs;
35  
  for (int i = 0; i < l(log); i++)
36  
    if (endsWith(log.get(i), detect)) {
37  
      bs.set(i);
38  
      log.set(i, dropSuffixAndTrim(detect, log.get(i)));
39  
    }
40  
  ret bs;
41  
}
42  
43  
// CREATIVE PART!
44  
45  
// put func {}'s returning a string in there
46  
static void makeGenerators(L<Gen> l, final L<S> log) {
47  
  gen(l, func { "3" });
48  
  gen(l, "plus1", func { parseLong(last(log))+1 });
49  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1003798
Snippet name: Test Random v6 Thinker
Eternal ID of this version: #1003798/1
Text MD5: af0b1a481b4f0456a9f2232a704c3d25
Transpilation MD5: 9f59a0b50c0862c085668fb752602e97
Author: stefan
Category: javax / talking robots
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-07-27 17:48:46
Source code size: 1282 bytes / 49 lines
Pitched / IR pitched: No / No
Views / Downloads: 488 / 548
Referenced in: [show references]