Hi All...
I`m a member of a forum for the zynga poker bot. Its an open source bot
written in AutoIt.
http://code.google.com/p/zynga-poker-bot/
The thing is zynga have changed to a new layout which has been updated
so the bot works but wont read all the cards now.
Zynga must have found out about it?
It works by grabbing the cards and suits in .tif then creates a checksum to see the cards.
Now what happens is that zynga have changed some of the card pixels in a random way so most of the time the cards dont read anymore.
Would there be a way to use the function
;Find a pure red pixel or a red pixel within 10 shades variations of pure red
$coord = PixelSearch(0, 0, 20, 30, 0xFF0000, 10 )
If Not @error Then
MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
EndIf
And put it into the Cards.au3 so it still worked for the cards it sees but for
the ones it dont put the above in somehow?
It has been suggested that you could cut all the cards out taking screenshots in 24bit bmp and redo the checksums.
Now i only seen the AutoIt videos 3days ago
I tried playing with the script
$c = PixelGetColor( $pos[0] , $pos[1] ) ; Get the pixel color at the current coordinate.
And playing with the unknown card part below.
I put the code in to make it fold if it dont see a card.
Any advice on the way to do it would be cool
Below is the Card.au3 script
[color=green][/color];=================================================================
; Read the Cards
;=================================================================
#include-once
#Include "vendor/ScreenCapture/ScreenCaptureFixed.au3"
#Include "Table.au3"
Global $logScreenCard = Int(IniRead(@ScriptDir & "\settings.ini","Log","log_screen_card", 0))
Global $oCardDictionary = ObjCreate("Scripting.Dictionary")
Global $oSuitDictionary = ObjCreate("Scripting.Dictionary")
Func _Cards($iSeat)
Local $aCards[7], $aSuits[7]
If $aTop[0] == False Then
Return False
EndIf
If $iSeat < 1 Then
Return False
EndIf
; table card locations
Local $aTableCard1_XY[2]
Local $aTableCard2_XY[2]
Local $aTableCard3_XY[2]
Local $aTableCard4_XY[2]
Local $aTableCard5_XY[2]
; seat card locations
Local $aSeatCard1_XY[9][2]
Local $aSeatCard2_XY[9][2]
; seat 1
$aSeatCard1_XY[0][0] = 527
$aSeatCard1_XY[0][1] = 33
$aSeatCard2_XY[0][0] = 552
$aSeatCard2_XY[0][1] = 33
; seat 2
$aSeatCard1_XY[1][0] = 637
$aSeatCard1_XY[1][1] = 83
$aSeatCard2_XY[1][0] = 662
$aSeatCard2_XY[1][1] = 83
; seat 3
$aSeatCard1_XY[2][0] = 647
$aSeatCard1_XY[2][1] = 205
$aSeatCard2_XY[2][0] = 672
$aSeatCard2_XY[2][1] = 205
; seat 4
$aSeatCard1_XY[3][0] = 527
$aSeatCard1_XY[3][1] = 278
$aSeatCard2_XY[3][0] = 552
$aSeatCard2_XY[3][1] = 278
; seat 5
$aSeatCard1_XY[4][0] = 402
$aSeatCard1_XY[4][1] = 283
$aSeatCard2_XY[4][0] = 427
$aSeatCard2_XY[4][1] = 283
; seat 6
$aSeatCard1_XY[5][0] = 182
$aSeatCard1_XY[5][1] = 277
$aSeatCard2_XY[5][0] = 207
$aSeatCard2_XY[5][1] = 277
; seat 7
$aSeatCard1_XY[6][0] = 62
$aSeatCard1_XY[6][1] = 205
$aSeatCard2_XY[6][0] = 87
$aSeatCard2_XY[6][1] = 205
; seat 8
$aSeatCard1_XY[7][0] = 61
$aSeatCard1_XY[7][1] = 82
$aSeatCard2_XY[7][0] = 86
$aSeatCard2_XY[7][1] = 82
; seat 9
$aSeatCard1_XY[8][0] = 182
$aSeatCard1_XY[8][1] = 33
$aSeatCard2_XY[8][0] = 207
$aSeatCard2_XY[8][1] = 33
; table card 1
$aTableCard1_XY[0] = 287
$aTableCard1_XY[1] = 134
; table card 2
$aTableCard2_XY[0] = 327
$aTableCard2_XY[1] = 134
; table card 3
$aTableCard3_XY[0] = 367
$aTableCard3_XY[1] = 134
; table card 4
$aTableCard4_XY[0] = 407
$aTableCard4_XY[1] = 134
; table card 5
$aTableCard5_XY[0] = 447
$aTableCard5_XY[1] = 134
; get the numbers
$aCards[0] = _CardNumber($aTop[0]+$aSeatCard1_XY[$iSeat-1][0],$aTop[1]+$aSeatCard1_XY[$iSeat-1][1])
$aCards[1] = _CardNumber($aTop[0]+$aSeatCard2_XY[$iSeat-1][0],$aTop[1]+$aSeatCard2_XY[$iSeat-1][1])
$aCards[2] = _CardNumber($aTop[0]+$aTableCard1_XY[0],$aTop[1]+$aTableCard1_XY[1])
$aCards[3] = _CardNumber($aTop[0]+$aTableCard2_XY[0],$aTop[1]+$aTableCard2_XY[1])
$aCards[4] = _CardNumber($aTop[0]+$aTableCard3_XY[0],$aTop[1]+$aTableCard3_XY[1])
$aCards[5] = _CardNumber($aTop[0]+$aTableCard4_XY[0],$aTop[1]+$aTableCard4_XY[1])
$aCards[6] = _CardNumber($aTop[0]+$aTableCard5_XY[0],$aTop[1]+$aTableCard5_XY[1])
; get the suits
$aSuits[0] = _CardSuit($aTop[0]+$aSeatCard1_XY[$iSeat-1][0],$aTop[1]+$aSeatCard1_XY[$iSeat-1][1])
$aSuits[1] = _CardSuit($aTop[0]+$aSeatCard2_XY[$iSeat-1][0],$aTop[1]+$aSeatCard2_XY[$iSeat-1][1])
$aSuits[2] = _CardSuit($aTop[0]+$aTableCard1_XY[0],$aTop[1]+$aTableCard1_XY[1])
$aSuits[3] = _CardSuit($aTop[0]+$aTableCard2_XY[0],$aTop[1]+$aTableCard2_XY[1])
$aSuits[4] = _CardSuit($aTop[0]+$aTableCard3_XY[0],$aTop[1]+$aTableCard3_XY[1])
$aSuits[5] = _CardSuit($aTop[0]+$aTableCard4_XY[0],$aTop[1]+$aTableCard4_XY[1])
$aSuits[6] = _CardSuit($aTop[0]+$aTableCard5_XY[0],$aTop[1]+$aTableCard5_XY[1])
; convert to card string
$sCards = _CardString($aCards,$aSuits)
Return $sCards
EndFunc
Func _CardNumber($x,$y)
Local $iChecksum = PixelChecksum($x,$y,$x+6,$y+6)
If IsObj($oCardDictionary) And $oCardDictionary.Exists($iChecksum) Then
Return $oCardDictionary.Item($iChecksum)
EndIf
Local $sCard = IniRead($sDataPath & "\card.ini","CardChecksum",$iChecksum,'-')
If $sCard <> '-' Then
If IsObj($oCardDictionary) Then
$oCardDictionary.Add($iChecksum,$sCard)
EndIf
Return $sCard
EndIf
; unknown card
If $logScreenCard <> 0 Then
$sImageFilename = $sLogPath&'\card\'&$iChecksum
_ScreenCapture_Capture($sImageFilename&'.tif',$x-2,$y-2,$x+10,$y+14,False)
EndIf
If IsObj($oCardDictionary) Then
$oCardDictionary.Add($iChecksum,False)
If _MyTurn() Then
_Log('_PlayTurnFold = yes')
MouseClick('left',$aTop[0]+390,$aTop[1]+370,1,0)
MouseMove($aTop[0],$aTop[1],0)
EndIf
Return False
EndFunc
; get a suit based on a x/y location
Func _CardSuit($x,$y)
Local $iChecksum = PixelChecksum($x,$y+20,$x+6,$y+20+6)
If IsObj($oSuitDictionary) And $oSuitDictionary.Exists($iChecksum) Then
Return $oSuitDictionary.Item($iChecksum)
EndIf
Local $sSuit = IniRead($sDataPath & "\suit.ini","SuitChecksum",$iChecksum,'-')
If $sSuit <> '-' Then
If IsObj($oSuitDictionary) Then
$oSuitDictionary.Add($iChecksum,$sSuit)
EndIf
Return $sSuit
EndIf
; unknown suit
If $logScreenCard <> 0 Then
$sImageFilename = $sLogPath&'\suit\'&$iChecksum
_ScreenCapture_Capture($sImageFilename&'.tif',$x-10,$y+20-10,$x+6+10,$y+20+6+10,False)
EndIf
If IsObj($oSuitDictionary) Then
$oSuitDictionary.Add($iChecksum,False)
EndIf
Return False
EndFunc
Func _CardString($aCards,$aSuits)
Local $sCards
If ($aCards[0]<>False And $aCards[1]<>False) Or ($aCards[2]<>False) Then
If $aCards[0]<>False And $aCards[1]<>False Then
$sCards = $aCards[0] & $aSuits[0] & ' ' & $aCards[1] & $aSuits[1]
Else
$sCards = '-- --'
EndIf
If $aCards[2]<>False And $aCards[3]<>False And $aCards[4]<>False Then
$sCards = $sCards & ' ' & $aCards[2] & $aSuits[2] & ' ' & $aCards[3] & $aSuits[3] & ' ' & $aCards[4] & $aSuits[4]
If $aCards[5]<>False Then
$sCards = $sCards & ' ' & $aCards[5] & $aSuits[5]
If $aCards[6]<>False Then
$sCards = $sCards & ' ' & $aCards[6] & $aSuits[6]
EndIf
EndIf
EndIf
EndIf
Return $sCards
EndFunc
Func _CardNumbersArray($sCards)
Local $aCards[7]
Local $aCardsTmp = StringSplit($sCards,' ',1)
For $i = 0 To UBound($aCardsTmp)-1
If $i>0 Then
$aCards[$i-1] = StringLeft($aCardsTmp[$i],1)
EndIf
Next
Return $aCards
EndFunc
Func _CardSuitsArray($sCards)
Local $aSuits[7]
Local $aSuitsTmp = StringSplit($sCards,' ',1)
For $i = 0 To UBound($aSuitsTmp)-1
If $i>0 Then
$aSuits[$i-1] = StringRight($aSuitsTmp[$i],1)
EndIf
Next
Return $aSuits
EndFunc
[/url]