AutoHotkey Community

It is currently May 26th, 2012, 7:35 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: May 7th, 2009, 9:41 pm 
Offline

Joined: May 7th, 2009, 9:03 pm
Posts: 13
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!


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 7th, 2009, 9:54 pm 
Offline

Joined: December 24th, 2008, 3:25 am
Posts: 1401
Location: :noitacoL
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2009, 10:04 pm 
Offline

Joined: May 7th, 2009, 9:03 pm
Posts: 13
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 :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2009, 12:55 am 
Offline

Joined: May 7th, 2009, 9:03 pm
Posts: 13
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 =/


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 8th, 2009, 6:17 am 
Offline

Joined: August 13th, 2006, 6:45 am
Posts: 355
Location: Germany
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: dmg, Google [Bot], krajan, over21, RaptorX and 61 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group