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).

!759

static int maxPixels = 6*1000*1000;

static long pixels;

p {
  conceptsAndBot(60*1000);  // auto-save every minute
  
  awt {
    showControls(jcenteredLine(jbutton("Show grabbed images", r {
      nohupJavax("#1005971")
    })));
  }
  
  while licensed {
    printFullHeapSizeWithGC();
    
    long time = now();
    AutoShootInfo info = autoShoot();
    pixels = totalPixelCount(collect(list(GrabbedImage), "image"));
    long singlePixels = totalPixelCount(collect(conceptsWhere(GrabbedImage, count := 1), "image"));
    done_always(time, "Seeing " + n(l(info.segments), "things") + ", " + info.considered + " in right size, now " +
      n(countConcepts(GrabbedImage), "image") + " in store, " + toM(pixels) + "M pixels (" + toM(singlePixels) + "M seen only once)");
    slimDB();
    sleepSeconds(10);
  }
}

svoid slimDB {
  if (pixels > maxPixels) {
    int n = 0;
    for (GrabbedImage gi : sortByField(list(GrabbedImage), "count")) {
      pixels -= totalPixelCount(gi.image);
      gi.delete();
      ++n;
      if (pixels <= maxPixels) break;
    }
    print("  Deleted " + n(n, "images") + " to get below threshold of " + toM(maxPixels) + "M pixels.");
  }
}

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: 703 / 2003
Version history: 1 change(s)
Referenced in: [show references]