| View previous topic :: View next topic |
| Author |
Message |
34t
Joined: 07 May 2009 Posts: 13
|
Posted: Thu May 07, 2009 8:41 pm Post subject: Suggestions for converting an array of images into digits? |
|
|
I'm getting ready to write a script that will automate playing a blackjack game for me. This game is entirely graphical, so my biggest issue (so far) is finding a way to convert the picture of the total value of my cards into a corresponding number.
To put it another way, the script will find need to search an area until one of the images in an array (???) matches what's on the screen. Then it needs to know that a number (from 4 to 21) is assigned to that image so it can perform a comparison operation to determine whether the script needs to HIT or STAND.
I would greatly appreciate any suggestions on how I can accomplish this. I've read a bit about arrays but I need to try some samples because I can understand them.
My challenge will be to ImageSearch from an array (ideally), instead of using the ImageSearch command 17 times. After a match is found, I will have to "convert" the picture to a number so I can determine my next step.
Thanks in advance! |
|
| Back to top |
|
 |
Carcophan
Joined: 24 Dec 2008 Posts: 1308 Location: :noitacoL
|
Posted: Thu May 07, 2009 8:54 pm Post subject: Re: Suggestions for converting an array of images into digit |
|
|
| 34t wrote: |
My challenge will be to ImageSearch from an array (ideally), instead of using the ImageSearch command 17 times. After a match is found, I will have to "convert" the picture to a number so I can determine my next step.
|
That is pretty much all you should have to do. You will need a LOT of pictures to compair to though, probably more than 17. You would need to cover all of the possible combinations of cards, colors, suits, depending on how sensative your imagesearch is. |
|
| Back to top |
|
 |
34t
Joined: 07 May 2009 Posts: 13
|
Posted: Thu May 07, 2009 9:04 pm Post subject: |
|
|
I'm lucky in that the particular game gives you the numeric total card value of your hand. Meaning if you have an ane and a five (of whatever suit), the total will read "16" and that's the image I'm focusing on.
I read the help file on arrays, but I'm still confused. Do you know of any samples that try anything similar or would you be so kind as to post some pseudo-code to guide me on how to structure the array imagesearch (and even more importantly how to assign number values to each image that the script can perform operations with).
Thanks  |
|
| Back to top |
|
 |
34t
Joined: 07 May 2009 Posts: 13
|
Posted: Thu May 07, 2009 11:55 pm Post subject: |
|
|
I've put together all the images that I'll need for this script - the numbers that signify my hand totals (4-21) and the monochrome versions of card faces so I can compare the value of my hand to the dealer's revealed card.
The problem is that regardless of how many times I re-read the section on arrays in the help file or the amount of searching I do, I'm unable to find anything similar to my situation.
It's possible to write a script that would search for each image in turn and then have 17 if statements that would assign a value, but that's incredibly ugly!
If anyone can suggest some reading material or pseudo code for me to explore I would really appreciate it =/ |
|
| Back to top |
|
 |
hd0202
Joined: 13 Aug 2006 Posts: 265 Location: Germany
|
Posted: Fri May 08, 2009 5:17 am Post subject: Re: Suggestions for converting an array of images into digit |
|
|
Hi,
name your files "ImageFile1" to "ImageFile17" and use this loop:
| Code: |
found =
Loop, 17
{
ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ImageFile%A_Index%
if Errorlevel = 0
{
found := A_Index
break
}
}
|
and in "found" is your card number
Hubert |
|
| Back to top |
|
 |
|