Sign in to follow this  
Followers 0
Ben Hovell

Clumsey Use Of "if" Statement, To Determain Dealer

12 posts in this topic

I am using the script below to determine who is the dealer in cards. It strikes me as being very clumsey and long winded. Is there any surgestions on shorterning the script?

$Dealer = PixelGetColor (518, 123)

if $Dealer = 11739923

$Dealer = 1

EndIf

$Dealer = PixelGetColor (657,180)

if $Dealer = 11739923

$Dealer = 2

EndIf

$Dealer = PixelGetColor (687,264)

if $Dealer = 11739923

$Dealer = 3

EndIf

$Dealer = PixelGetColor (597,343)

if $Dealer = 11739923

$Dealer = 4

EndIf

$Dealer = PixelGetColor (528,360)

if $Dealer = 11739923

$Dealer = 5

EndIf

$Dealer = PixelGetColor (270,357)

if $Dealer = 11739923

$Dealer = 6

EndIf

$Dealer = PixelGetColor (204,338)

if $Dealer = 11739923

$Dealer = 7

EndIf

$Dealer = PixelGetColor (114,260)

if $Dealer = 11739923

$Dealer = 8

EndIf

$Dealer = PixelGetColor (139,181)

if $Dealer = 11739923

$Dealer = 9

EndIf

$Dealer = PixelGetColor (278,121)

if $Dealer = 11739923

$Dealer = 10

EndIf

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Needs Beta:

Dim $x[11] = ['', 518, 657, 687, 597, 528, 270, 204, 114, 139, 278]
Dim $y[11] = ['', 123, 180, 264, 343, 360, 357, 338, 260, 181, 121]

For $i_Count = 1 To 10
    If (PixelGetColor($x[$i_Count], $y[$i_Count] == 11739923) Then
        $Dealer = $i_Count
        ExitLoop
    EndIf
Next

Edit:

Noticed I had an EndIf to close the For/Next Loop :)

Edit2: Forgot to Dim the Array

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Line 4 (File "F:\Documents and Settings\Ben Hovell\Desktop\Whos the dealer.txt"):

Dim $x[11] = ['', 518, 657, 687, 597, 528, 270, 204, 114, 139, 278]

Dim $x[11] ^ ERROR

Error: No variable given for "Dim", "Local", "Global" or "Const" statement

Any ideas about how to stop the above error statement?

Share this post


Link to post
Share on other sites

Line 4 (File "F:\Documents and Settings\Ben Hovell\Desktop\Whos the dealer.txt"):

Dim $x[11] = ['', 518, 657, 687, 597, 528, 270, 204, 114, 139, 278]

Dim $x[11] ^ ERROR

Error: No variable given for "Dim", "Local", "Global" or "Const" statement

Any ideas about how to stop the above error statement?

Yeah, as I said... you need AutoIt Beta: http://www.autoitscript.com/autoit3/files/beta/autoit/

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thanks for your help,

I have installled beta and removed the erronous open bracket before the get pixel colour statement and am now in busines.

Share this post


Link to post
Share on other sites

Thanks for your help,

I have installled beta and removed the erronous open bracket before the get pixel colour statement and am now in busines.

What open bracket?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

There is two open brakets "(" one before and one after the getpixel colour statement. There was only one corresponding close bracket.

I have moved on to the next part of the progrom determining who is sitting in the current hand. The program does not work as I get an error for the for and next statements.

It is also messy what would be better than player one = player 2 = would be an array, with a one for people at the table and a 0 for people not present as the output.

Dim $x[11] = ['', 518, 657, 687, 597, 528, 270, 204, 114, 139, 278]

Dim $y[11] = ['', 123, 180, 264, 343, 360, 357, 338, 260, 181, 121]

For $i_Count = 1 To 10

IF PixelGetColor($x[$i_Count], $y[$i_Count]) == 11739923 Then

IF $i_Count = 1 then

PLayer 1 = 1

End IF

IF $i_Count = 2 then

PLayer 2 = 1

End IF

IF $i_Count = 3 then

PLayer 3 = 1

End IF

IF $i_Count = 4 then

PLayer 4 = 1

End IF

IF $i_Count = 5 then

PLayer 5 = 1

End IF

IF $i_Count = 6 then

PLayer 6 = 1

End IF

IF $i_Count = 7 then

PLayer 7 = 1

End IF

IF $i_Count = 8 then

PLayer 8 = 1

End IF

IF $i_Count = 9 then

PLayer 9 = 1

End IF

IF $i_Count = 10 then

PLayer 10 = 1

End IF

ExitLoop

EndIf

Next

MsgBox(0,"", "end of program")

Share this post


Link to post
Share on other sites

I had actually missed a bracket, didn't have 1 too many... anyway, I have fixed the code... but before I help you... what pokersite is this? (want to make sure I don't play it :))


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

It would be a long time before I ever had something that worked on the internet live and then anyone with half a brain can destroy a bot.

You can spot them playing a mile off, no chat, very tight to regular in speed of reponsce. SOme of the new rooms ut them up to tray and pretend there are more people on there site.

Me a group of students have challaged some lectures to a poker bot game we each put in a bot and leave them to battle it out.

Last one standing wins. On a fast PC in the labs this should be a very quick as there is no waiting time. We can then analize the game latter.

I think the most will be purally satistical, so am thinking of just constantly rasing to begin with and hoping the level of so called AI, but really just learning is low so I get a pot lead then revert to very tight and hope enough people knock each other out that I don't come last

Share this post


Link to post
Share on other sites

It would be a long time before I ever had something that worked on the internet live and then anyone with half a brain can destroy a bot.

You can spot them playing a mile off, no chat, very tight to regular in speed of reponsce. SOme of the new rooms ut them up to tray and pretend there are more people on there site.

Me a group of students have challaged some lectures to a poker bot game we each put in a bot and leave them to battle it out.

Last one standing wins. On a fast PC in the labs this should be a very quick as there is no waiting time. We can then analize the game latter.

I think the most will be purally satistical, so am thinking of just constantly rasing to begin with and hoping the level of so called AI, but really just learning is low so I get a pot lead then revert to very tight and hope enough people knock each other out that I don't come last

What AI are you using?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I am not going to use any AI, it's behond me really. I will just have simple rules, plus satistics. Further rule i did not mention is if you bot crashes you out. So don't make it to complicated!!

If you are intrested bots I have basic ones that I have written that you can look at ? I don't mind sharing them as simply won't make any money for people just something for enterainment

Share this post


Link to post
Share on other sites

There is two open brakets "(" one before and one after the getpixel colour statement. There was only one corresponding close bracket.

I have moved on to the next part of the progrom determining who is sitting in the current hand. The program does not work as I get an error for the for and next statements.

It is also messy what would be better than player one = player 2 = would be an array, with a one for people at the table and a 0 for people not present as the output.

Dim $x[11] = ['', 518, 657, 687, 597, 528, 270, 204, 114, 139, 278]

Dim $y[11] = ['', 123, 180, 264, 343, 360, 357, 338, 260, 181, 121]

For $i_Count = 1 To 10

IF PixelGetColor($x[$i_Count], $y[$i_Count]) == 11739923 Then

IF $i_Count = 1 then

PLayer 1 = 1

End IF

IF $i_Count = 2 then

PLayer 2 = 1

End IF

IF $i_Count = 3 then

PLayer 3 = 1

End IF

IF $i_Count = 4 then

PLayer 4 = 1

End IF

IF $i_Count = 5 then

PLayer 5 = 1

End IF

IF $i_Count = 6 then

PLayer 6 = 1

End IF

IF $i_Count = 7 then

PLayer 7 = 1

End IF

IF $i_Count = 8 then

PLayer 8 = 1

End IF

IF $i_Count = 9 then

PLayer 9 = 1

End IF

IF $i_Count = 10 then

PLayer 10 = 1

End IF

ExitLoop

EndIf

Next

MsgBox(0,"", "end of program")

Your code can be simplified to this:

Global $x[11] = ['', 518, 657, 687, 597, 528, 270, 204, 114, 139, 278]
Global $y[11] = ['', 123, 180, 264, 343, 360, 357, 338, 260, 181, 121]
Global $Player[11]


For $i_Count = 1 To 10
    If PixelGetColor($x[$i_Count], $y[$i_Count]) == 11739923 Then
        $Player[$i_Count] = 1
        ExitLoop
    EndIf
Next
MsgBox(0,"", "end of program")

Notice how the EndIf's are all one word, and each variable starts with $ and is also one word.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0