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)

1  
AI > MemorizeArea3 {
2  
  float similarityThreshold = 0.9f;
3  
  int shrinkPixels = 1;
4  
  RGBImage blobImage;
5  
  static ImageSurface is;
6  
  Pt lastLocation;
7  
8  
  void go {
9  
    // guess
10  
    
11  
    Rect guess = null;
12  
    if (blobImage != null) {
13  
      guess = foundImgToRect(rgbRawImageSearch_searchHereFirst(image, blobImage, similarityThreshold, lastLocation));
14  
      if (guess != null) lastLocation = new Pt(guess.x, guess.y);
15  
    }
16  
17  
    // submit
18  
    
19  
    Rect solution = first(submit(guess));
20  
    
21  
    // learn
22  
    
23  
    bool correct = solution == null ? guess == null : guess != null && solution.contains(centerOfRect(guess));
24  
    if (blobImage != null && !correct && similarityThreshold > 0.01f) {
25  
      similarityThreshold -= 0.01f;
26  
      print("Lowering similarity threshold to " + similarityThreshold);
27  
    }
28  
    
29  
    if (blobImage == null && solution != null) {
30  
      blobImage = image.clip(growRect(solution, -shrinkPixels));
31  
      if (visualize)
32  
        is = showZoomedImage(is, "Memorized Area", blobImage);
33  
    }
34  
  }
35  
}

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: 510 / 741
Version history: 5 change(s)
Referenced in: [show references]