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

35
LINES

< > BotCompany Repo | #1007100 // MemorizeArea3 (AI) - lowers similarity threshold if needed

JavaX fragment (include)

AI > MemorizeArea3 {
  float similarityThreshold = 0.9f;
  int shrinkPixels = 1;
  RGBImage blobImage;
  static ImageSurface is;
  Pt lastLocation;

  void go {
    // guess
    
    Rect guess = null;
    if (blobImage != null) {
      guess = foundImgToRect(rgbRawImageSearch_searchHereFirst(image, blobImage, similarityThreshold, lastLocation));
      if (guess != null) lastLocation = new Pt(guess.x, guess.y);
    }

    // submit
    
    Rect solution = first(submit(guess));
    
    // learn
    
    bool correct = solution == null ? guess == null : guess != null && solution.contains(centerOfRect(guess));
    if (blobImage != null && !correct && similarityThreshold > 0.01f) {
      similarityThreshold -= 0.01f;
      print("Lowering similarity threshold to " + similarityThreshold);
    }
    
    if (blobImage == null && solution != null) {
      blobImage = image.clip(growRect(solution, -shrinkPixels));
      if (visualize)
        is = showZoomedImage(is, "Memorized Area", blobImage);
    }
  }
}

Author comment

Began life as a copy of #1006912

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: #1007100
Snippet name: MemorizeArea3 (AI) - lowers similarity threshold if needed
Eternal ID of this version: #1007100/6
Text MD5: f08ae639fcbd7fe200ca0b9af72fa94c
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-03 01:05:47
Source code size: 1053 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 445 / 667
Version history: 5 change(s)
Referenced in: [show references]