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

41
LINES

< > BotCompany Repo | #1005951 // Auto-Shooter (collect random images from screen) - replaced by #1010705

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

Libraryless. Click here for Pure Java version (9983L/69K/229K).

1  
!759
2  
3  
static int maxPixels = 6*1000*1000;
4  
5  
static long pixels;
6  
7  
p {
8  
  conceptsAndBot(60*1000);  // auto-save every minute
9  
  
10  
  awt {
11  
    showControls(jcenteredLine(jbutton("Show grabbed images", r {
12  
      nohupJavax("#1005971")
13  
    })));
14  
  }
15  
  
16  
  while licensed {
17  
    printFullHeapSizeWithGC();
18  
    
19  
    long time = now();
20  
    AutoShootInfo info = autoShoot();
21  
    pixels = totalPixelCount(collect(list(GrabbedImage), "image"));
22  
    long singlePixels = totalPixelCount(collect(conceptsWhere(GrabbedImage, count := 1), "image"));
23  
    done_always(time, "Seeing " + n(l(info.segments), "things") + ", " + info.considered + " in right size, now " +
24  
      n(countConcepts(GrabbedImage), "image") + " in store, " + toM(pixels) + "M pixels (" + toM(singlePixels) + "M seen only once)");
25  
    slimDB();
26  
    sleepSeconds(10);
27  
  }
28  
}
29  
30  
svoid slimDB {
31  
  if (pixels > maxPixels) {
32  
    int n = 0;
33  
    for (GrabbedImage gi : sortByField(list(GrabbedImage), "count")) {
34  
      pixels -= totalPixelCount(gi.image);
35  
      gi.delete();
36  
      ++n;
37  
      if (pixels <= maxPixels) break;
38  
    }
39  
    print("  Deleted " + n(n, "images") + " to get below threshold of " + toM(maxPixels) + "M pixels.");
40  
  }
41  
}

Author comment

Began life as a copy of #1005379

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005951
Snippet name: Auto-Shooter (collect random images from screen) - replaced by #1010705
Eternal ID of this version: #1005951/2
Text MD5: 69410424c2d1036e162c5b0114003cf2
Transpilation MD5: f7c6231fa7c21ebb49979fdb89d5b349
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-09-28 00:18:54
Source code size: 1219 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 647 / 1926
Version history: 1 change(s)
Referenced in: [show references]