so i want to plant tress , using image search , when i do this
script start from random tree and misses half of the spots bcz they get hidden behind other tress.
how can i start it from specific direction so it doesnt choose randomaly.
Same multiple images
Moderators: JRL, Dorian (MJT support)
- Dorian (MJT support)
- Automation Wizard
- Posts: 1415
- Joined: Sun Nov 03, 2002 3:19 am
Re: Same multiple images
Mmmm, I love a good farming game. What one is this?
In a sense, we're stuck between two stalls here, but it's nothing we can't get around.
The image you provided shows that both the grassy areas and the trees aren't exactly the same. This means we can't use EXACT matching. We have to use CCOEFF. But only EXACT matching can find multiple images - and of course we want to find multiple images. So we're forced to use the EXACT matching algorithm that will only find one match at a time. The solution is for us to do that in a loop, and make the loop repeat until it doesn't see a match.
A few things to consider :
1. Be very careful with what you sample. Experiment to get best results.
2. Experiment with the tolerance until you get it exactly right (use my attached thumbnail for inspiration).
3. Experiment with the offset and/or coordinates so you click exactly where you want in relation to the found image
4. Timing. Do you have to wait for a tree to be planted after clicking? If so, increase the 1 second wait.
I found sampling some of the trunk and some of the grass worked well. Here we can see where my script clicked and marked the area (in MS Paint). You can tweak things a little to make sure your clicks wherever you like. But we can see this is possible. This script will look for a tree trunk and some grass. For me, a tolerance of 0.8 was the sweet spot. It will click on the bottom of the tree trunk, and then look for another. It will keep looping until there are no more tree trunks. This may not be exactly what you end up with, but hopefully will give you enough information to tweak and refine for your use.
In a sense, we're stuck between two stalls here, but it's nothing we can't get around.
The image you provided shows that both the grassy areas and the trees aren't exactly the same. This means we can't use EXACT matching. We have to use CCOEFF. But only EXACT matching can find multiple images - and of course we want to find multiple images. So we're forced to use the EXACT matching algorithm that will only find one match at a time. The solution is for us to do that in a loop, and make the loop repeat until it doesn't see a match.
A few things to consider :
1. Be very careful with what you sample. Experiment to get best results.
2. Experiment with the tolerance until you get it exactly right (use my attached thumbnail for inspiration).
3. Experiment with the offset and/or coordinates so you click exactly where you want in relation to the found image
4. Timing. Do you have to wait for a tree to be planted after clicking? If so, increase the 1 second wait.
I found sampling some of the trunk and some of the grass worked well. Here we can see where my script clicked and marked the area (in MS Paint). You can tweak things a little to make sure your clicks wherever you like. But we can see this is possible. This script will look for a tree trunk and some grass. For me, a tolerance of 0.8 was the sweet spot. It will click on the bottom of the tree trunk, and then look for another. It will keep looping until there are no more tree trunks. This may not be exactly what you end up with, but hopefully will give you enough information to tweak and refine for your use.
Code: Select all
Let>Finish=0
While>Finish=0
//Find and Move Mouse Middle Bottom of
FindImagePos>%BMP_DIR%\image_11.bmp,WINDOW:jetnet.png - Paint,0.8,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
Wait>0.2
Lclick
Wait>1
Else
Let>Finish=1
Endif
Endwhile