Sign in to follow this  
Followers 0
laffo16

Poker calculating all possible hands

5 posts in this topic

This script will calculate all possible Texas Holdem Poker Hands, based on the flop cards present (and only the flop). I find poker intresting and thought i'd have a try at creating such a script. I'm not totaly sure that the results are correct although i think they must be close, i'd like to speed up & clean up the script, if anyone has any suggestions please let me know. thank you.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.4.6
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")

#include <Array.au3>

Global $pf_card[3]
Global $pf_gen[3]
Global $f_card[4]
Global $c[6][2]
Global $d[6][2]
Global $n
Global $p
Global $handrecords[11][2]
Global $r = 0

_getpreflop()
_getflop()
_combinecards()
_convertcards()
;_ArrayDisplay($c, "")
;_findyourhand()
;_ArrayDisplay($c, "")
_findbesthand()

Func _getpreflop()
    $pf_card[1] = "9h"
    $pf_card[2] = "5h"
EndFunc

Func _getflop()
    $f_card[1] = "Th"
    $f_card[2] = "Jh"
    $f_card[3] = "Ah"
EndFunc

Func _combinecards()
    $c[1][0] = StringLeft($pf_card[1], 1)
    $c[2][0] = StringLeft($pf_card[2], 1)
    $c[3][0] = StringLeft($f_card[1], 1)
    $c[4][0] = StringLeft($f_card[2], 1)
    $c[5][0] = StringLeft($f_card[3], 1)
    $c[1][1] = StringRight($pf_card[1], 1)
    $c[2][1] = StringRight($pf_card[2], 1)
    $c[3][1] = StringRight($f_card[1], 1)
    $c[4][1] = StringRight($f_card[2], 1)
    $c[5][1] = StringRight($f_card[3], 1)
EndFunc

Func _convertcards()
    Dim $i
    For $i = 1 to 5
        If $c[$i][0] = "T" Then
            $c[$i][0] = Number("10")
        ElseIf $c[$i][0] = "J" Then
            $c[$i][0] = Number("11")
        ElseIf $c[$i][0] = "Q" Then
            $c[$i][0] = Number("12")
        ElseIf $c[$i][0] = "K" Then
            $c[$i][0] = Number("13")
        ElseIf $c[$i][0] = "A" Then
            $c[$i][0] = Number("14")
        ElseIf $c[$i][0] <= "9" Then
            $c[$i][0] = Number($c[$i][0])
        EndIf
    Next
EndFunc

Func _convertgen()
    $pf_card[1] = $p
    $pf_card[2] = $n
    $c[1][0] = StringLeft($pf_card[1], 1)
    $c[2][0] = StringLeft($pf_card[2], 1)
    $c[3][0] = StringLeft($f_card[1], 1)
    $c[4][0] = StringLeft($f_card[2], 1)
    $c[5][0] = StringLeft($f_card[3], 1)
    $c[1][1] = StringRight($pf_card[1], 1)
    $c[2][1] = StringRight($pf_card[2], 1)
    $c[3][1] = StringRight($f_card[1], 1)
    $c[4][1] = StringRight($f_card[2], 1)
    $c[5][1] = StringRight($f_card[3], 1)
    Dim $i
    For $i = 1 to 5
        If $c[$i][0] = "T" Then
            $c[$i][0] = Number("10")
        ElseIf $c[$i][0] = "J" Then
            $c[$i][0] = Number("11")
        ElseIf $c[$i][0] = "Q" Then
            $c[$i][0] = Number("12")
        ElseIf $c[$i][0] = "K" Then
            $c[$i][0] = Number("13")
        ElseIf $c[$i][0] = "A" Then
            $c[$i][0] = Number("14")
        ElseIf $c[$i][0] <= "9" Then
            $c[$i][0] = Number($c[$i][0])
        EndIf
    Next
EndFunc

Func _findbesthand()
    _cardgen()
    _recordsetup()
    Dim $i
    For $i = 1 to 3
        _ArrayDelete($cgen, _ArraySearch($cgen, $f_card[$i], 1, 0, 0))
    Next
    ;$d = $c
    $k = 1
    For $k = 1 to 49 ; -3 flop cards
        ;_ArrayDisplay($cgen, "1")
        $o = _ArraySearch($cgen, $cgen[$k], 1, 0, 0)
        $p = $cgen[$o]
        $cgen[$o] = ""
        For $l = 1 to 49 ; -1 card $i
            $m = _ArraySearch($cgen, $cgen[$l], 1, 0, 0)
            $n = $cgen[$m]
            If $n = "" Then
                ; nothin
            Else
                $cgen[$m] = ""
                _convertgen()
                ;_ArrayDisplay($c, "loop")
                $d = $c
                _ArraySort($c, 1, 1, "", 2)
                _findyourhand()
                ;addhandrecord($handtoadd)
                ;MsgBox(0, "", $handrec)
                $cgen[$m] = $n
            EndIf
        Next
        $cgen[$o] = $p
        $cgen[$k] = ""
        ;Dim $q
        ;For $q = 1 to 4
        ;   $q += $r
        ;   If $q > 49 Then
        ;       $q = 49
        ;   EndIf
        ;   $cgen[$q] = ""
        ;Next
        ;$r += 4
    Next
    _ArrayDisplay($handrecords, "Possible Hands when Flop = " & $d[3][0] & $d[3][1] & " " & $d[4][0] & $d[4][1] & " " & $d[5][0] & $d[5][1])
EndFunc

Func _recordsetup()
    $handrecords[1][0] = "Royal flush"
    $handrecords[2][0] = "Straight flush"
    $handrecords[3][0] = "Four of a kind"
    $handrecords[4][0] = "Full house"
    $handrecords[5][0] = "Flush"
    $handrecords[6][0] = "Straight"
    $handrecords[7][0] = "Three of a kind"
    $handrecords[8][0] = "Two pair"
    $handrecords[9][0] = "One pair"
    $handrecords[10][0] = "High card"
    $handrecords[1][1] = Number("0")
    $handrecords[2][1] = Number("0")
    $handrecords[3][1] = Number("0")
    $handrecords[4][1] = Number("0")
    $handrecords[5][1] = Number("0")
    $handrecords[6][1] = Number("0")
    $handrecords[7][1] = Number("0")
    $handrecords[8][1] = Number("0")
    $handrecords[9][1] = Number("0")
    $handrecords[10][1] = Number("0")
    ;_ArrayDisplay($handrecords, "1")
EndFunc

;$d[1][0] & $d[1][1] & " " & $d[2][0] & $d[2][1] & " " & $d[3][0] & $d[3][1] & " " & $d[4][0] & $d[4][1] & " " & $d[5][0] & $d[5][1]

Func _findyourhand()
    If _checkflush() = 1 And _checkstraight() = 1 And $c[5][0] = "10" Then
        $handrecords[1][1] += 1
        ;MsgBox(0, "", $d[1][0] & $d[1][1] & " " & $d[2][0] & $d[2][1] & " " & $d[3][0] & $d[3][1] & " " & $d[4][0] & $d[4][1] & " " & $d[5][0] & $d[5][1])
    ElseIf _checkflush() = 1 And _checkstraight() = 1 Then
        $handrecords[2][1] += 1
    ElseIf _checkfourkind() = 1 Then
        $handrecords[3][1] += 1
    ElseIf _checkfullhouse() = 1 Then
        $handrecords[4][1] += 1
    ElseIf _checkflush() = 1 Then
        $handrecords[5][1] += 1
    ElseIf _checkstraight() = 1 Then
        $handrecords[6][1] += 1
    ElseIf _checkthreekind() = 1 Then
        $handrecords[7][1] += 1
    ElseIf _checktwopair() = 1 Then
        $handrecords[8][1] += 1
    ElseIf _onepair() = 1 Then
        $handrecords[9][1] += 1
    ElseIf _highcard() = 1 Then
        $handrecords[10][1] += 1
    EndIf
    ;_ArrayDisplay($handrecords, "2")
EndFunc

Func _checkflush()
    If $c[1][1] = $c[2][1] And $c[2][1] = $c[3][1] And $c[3][1] = $c[4][1] And $c[4][1] = $c[5][1] Then
        Return 1
    EndIf
EndFunc

Func _checkstraight()
    If $c[1][0] - $c[5][0] <= 4 Then
        If $c[1][0] > $c[2][0] And $c[2][0] > $c[3][0] And $c[3][0] > $c[4][0] And $c[4][0] > $c[5][0] Then
            Return 1
        EndIf
    EndIf
EndFunc

Func _checkfourkind()
    Dim $count
    Dim $i
    For $i = 1 to 5
        $count = 0
        If $c[$i][0] = $c[1][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[2][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[3][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[4][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[5][0] Then
            $count += 1
        EndIf
        If $count >= 4 Then
            Return 1
        EndIf
    Next
EndFunc

Func _checkfullhouse()
    Dim $threekind = 0
    Dim $twopair = 0
    Dim $count
    Dim $i
    For $i = 1 to 5
        $count = 0
        If $c[$i][0] = $c[1][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[2][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[3][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[4][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[5][0] Then
            $count += 1
        EndIf
        If $count = 3 Then
            $threekind = 1
        EndIf
        If $count = 2 Then
            $twopair = 1
        EndIf
    Next
    If $threekind = 1 And $twopair = 1 Then
        Return 1
    EndIf
EndFunc

Func _checkthreekind()
    Dim $count
    Dim $i
    For $i = 1 to 5
        $count = 0
        If $c[$i][0] = $c[1][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[2][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[3][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[4][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[5][0] Then
            $count += 1
        EndIf
        If $count >= 3 Then
            Return 1
        EndIf
    Next
EndFunc

Func _checktwopair()
    Dim $twopair = 0
    Dim $count
    Dim $i
    For $i = 1 to 5
        $count = 0
        If $c[$i][0] = $c[1][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[2][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[3][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[4][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[5][0] Then
            $count += 1
        EndIf
        If $count = 2 Then
            $twopair += 1
        EndIf
    Next
    If $twopair = 4 Then
        Return 1
    EndIf
EndFunc

Func _onepair()
    Dim $count
    Dim $i
    For $i = 1 to 5
        $count = 0
        If $c[$i][0] = $c[1][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[2][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[3][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[4][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[5][0] Then
            $count += 1
        EndIf
        If $count >= 2 Then
            Return 1
        EndIf
    Next
EndFunc

Func _highcard()
    ;_ArraySort($pf_card, 1, 1)
    ;MsgBox(0, "", "high card = " & $pf_card[1])
    Return 1
EndFunc

;(1,49)
;(2,48) ;(52) store all cards in [1] array
Func _cardgen()
    Global $cgen[53]
    $cgen[1] = "2s"
    $cgen[2] = "2c"
    $cgen[3] = "2h"
    $cgen[4] = "2d"
    $cgen[5] = "3s"
    $cgen[6] = "3c"
    $cgen[7] = "3h"
    $cgen[8] = "3d"
    $cgen[9] = "4s"
    $cgen[10] = "4c"
    $cgen[11] = "4h"
    $cgen[12] = "4d"
    $cgen[13] = "5s"
    $cgen[14] = "5c"
    $cgen[15] = "5h"
    $cgen[16] = "5d"
    $cgen[17] = "6s"
    $cgen[18] = "6c"
    $cgen[19] = "6h"
    $cgen[20] = "6d"
    $cgen[21] = "7s"
    $cgen[22] = "7c"
    $cgen[23] = "7h"
    $cgen[24] = "7d"
    $cgen[25] = "8s"
    $cgen[26] = "8c"
    $cgen[27] = "8h"
    $cgen[28] = "8d"
    $cgen[29] = "9s"
    $cgen[30] = "9c"
    $cgen[31] = "9h"
    $cgen[32] = "9d"
    $cgen[33] = "Ts"
    $cgen[34] = "Tc"
    $cgen[35] = "Th"
    $cgen[36] = "Td"
    $cgen[37] = "Js"
    $cgen[38] = "Jc"
    $cgen[39] = "Jh"
    $cgen[40] = "Jd"
    $cgen[41] = "Qs"
    $cgen[42] = "Qc"
    $cgen[43] = "Qh"
    $cgen[44] = "Qd"
    $cgen[45] = "Ks"
    $cgen[46] = "Kc"
    $cgen[47] = "Kh"
    $cgen[48] = "Kd"
    $cgen[49] = "As"
    $cgen[50] = "Ac"
    $cgen[51] = "Ah"
    $cgen[52] = "Ad"
EndFunc

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This script will calculate all possible Texas Holdem Poker Hands, based on the flop cards present (and only the flop). I find poker intresting and thought i'd have a try at creating such a script. I'm not totaly sure that the results are correct although i think they must be close, i'd like to speed up & clean up the script, if anyone has any suggestions please let me know. thank you.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.4.6
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")

#include <Array.au3>

Global $pf_card[3]
Global $pf_gen[3]
Global $f_card[4]
Global $c[6][2]
Global $d[6][2]
Global $n
Global $p
Global $handrecords[11][2]
Global $r = 0

_getpreflop()
_getflop()
_combinecards()
_convertcards()
;_ArrayDisplay($c, "")
;_findyourhand()
;_ArrayDisplay($c, "")
_findbesthand()

Func _getpreflop()
    $pf_card[1] = "9h"
    $pf_card[2] = "5h"
EndFunc

Func _getflop()
    $f_card[1] = "Th"
    $f_card[2] = "Jh"
    $f_card[3] = "Ah"
EndFunc

Func _combinecards()
    $c[1][0] = StringLeft($pf_card[1], 1)
    $c[2][0] = StringLeft($pf_card[2], 1)
    $c[3][0] = StringLeft($f_card[1], 1)
    $c[4][0] = StringLeft($f_card[2], 1)
    $c[5][0] = StringLeft($f_card[3], 1)
    $c[1][1] = StringRight($pf_card[1], 1)
    $c[2][1] = StringRight($pf_card[2], 1)
    $c[3][1] = StringRight($f_card[1], 1)
    $c[4][1] = StringRight($f_card[2], 1)
    $c[5][1] = StringRight($f_card[3], 1)
EndFunc

Func _convertcards()
    Dim $i
    For $i = 1 to 5
        If $c[$i][0] = "T" Then
            $c[$i][0] = Number("10")
        ElseIf $c[$i][0] = "J" Then
            $c[$i][0] = Number("11")
        ElseIf $c[$i][0] = "Q" Then
            $c[$i][0] = Number("12")
        ElseIf $c[$i][0] = "K" Then
            $c[$i][0] = Number("13")
        ElseIf $c[$i][0] = "A" Then
            $c[$i][0] = Number("14")
        ElseIf $c[$i][0] <= "9" Then
            $c[$i][0] = Number($c[$i][0])
        EndIf
    Next
EndFunc

Func _convertgen()
    $pf_card[1] = $p
    $pf_card[2] = $n
    $c[1][0] = StringLeft($pf_card[1], 1)
    $c[2][0] = StringLeft($pf_card[2], 1)
    $c[3][0] = StringLeft($f_card[1], 1)
    $c[4][0] = StringLeft($f_card[2], 1)
    $c[5][0] = StringLeft($f_card[3], 1)
    $c[1][1] = StringRight($pf_card[1], 1)
    $c[2][1] = StringRight($pf_card[2], 1)
    $c[3][1] = StringRight($f_card[1], 1)
    $c[4][1] = StringRight($f_card[2], 1)
    $c[5][1] = StringRight($f_card[3], 1)
    Dim $i
    For $i = 1 to 5
        If $c[$i][0] = "T" Then
            $c[$i][0] = Number("10")
        ElseIf $c[$i][0] = "J" Then
            $c[$i][0] = Number("11")
        ElseIf $c[$i][0] = "Q" Then
            $c[$i][0] = Number("12")
        ElseIf $c[$i][0] = "K" Then
            $c[$i][0] = Number("13")
        ElseIf $c[$i][0] = "A" Then
            $c[$i][0] = Number("14")
        ElseIf $c[$i][0] <= "9" Then
            $c[$i][0] = Number($c[$i][0])
        EndIf
    Next
EndFunc

Func _findbesthand()
    _cardgen()
    _recordsetup()
    Dim $i
    For $i = 1 to 3
        _ArrayDelete($cgen, _ArraySearch($cgen, $f_card[$i], 1, 0, 0))
    Next
    ;$d = $c
    $k = 1
    For $k = 1 to 49 ; -3 flop cards
        ;_ArrayDisplay($cgen, "1")
        $o = _ArraySearch($cgen, $cgen[$k], 1, 0, 0)
        $p = $cgen[$o]
        $cgen[$o] = ""
        For $l = 1 to 49 ; -1 card $i
            $m = _ArraySearch($cgen, $cgen[$l], 1, 0, 0)
            $n = $cgen[$m]
            If $n = "" Then
                ; nothin
            Else
                $cgen[$m] = ""
                _convertgen()
                ;_ArrayDisplay($c, "loop")
                $d = $c
                _ArraySort($c, 1, 1, "", 2)
                _findyourhand()
                ;addhandrecord($handtoadd)
                ;MsgBox(0, "", $handrec)
                $cgen[$m] = $n
            EndIf
        Next
        $cgen[$o] = $p
        $cgen[$k] = ""
        ;Dim $q
        ;For $q = 1 to 4
        ;   $q += $r
        ;   If $q > 49 Then
        ;       $q = 49
        ;   EndIf
        ;   $cgen[$q] = ""
        ;Next
        ;$r += 4
    Next
    _ArrayDisplay($handrecords, "Possible Hands when Flop = " & $d[3][0] & $d[3][1] & " " & $d[4][0] & $d[4][1] & " " & $d[5][0] & $d[5][1])
EndFunc

Func _recordsetup()
    $handrecords[1][0] = "Royal flush"
    $handrecords[2][0] = "Straight flush"
    $handrecords[3][0] = "Four of a kind"
    $handrecords[4][0] = "Full house"
    $handrecords[5][0] = "Flush"
    $handrecords[6][0] = "Straight"
    $handrecords[7][0] = "Three of a kind"
    $handrecords[8][0] = "Two pair"
    $handrecords[9][0] = "One pair"
    $handrecords[10][0] = "High card"
    $handrecords[1][1] = Number("0")
    $handrecords[2][1] = Number("0")
    $handrecords[3][1] = Number("0")
    $handrecords[4][1] = Number("0")
    $handrecords[5][1] = Number("0")
    $handrecords[6][1] = Number("0")
    $handrecords[7][1] = Number("0")
    $handrecords[8][1] = Number("0")
    $handrecords[9][1] = Number("0")
    $handrecords[10][1] = Number("0")
    ;_ArrayDisplay($handrecords, "1")
EndFunc

;$d[1][0] & $d[1][1] & " " & $d[2][0] & $d[2][1] & " " & $d[3][0] & $d[3][1] & " " & $d[4][0] & $d[4][1] & " " & $d[5][0] & $d[5][1]

Func _findyourhand()
    If _checkflush() = 1 And _checkstraight() = 1 And $c[5][0] = "10" Then
        $handrecords[1][1] += 1
        ;MsgBox(0, "", $d[1][0] & $d[1][1] & " " & $d[2][0] & $d[2][1] & " " & $d[3][0] & $d[3][1] & " " & $d[4][0] & $d[4][1] & " " & $d[5][0] & $d[5][1])
    ElseIf _checkflush() = 1 And _checkstraight() = 1 Then
        $handrecords[2][1] += 1
    ElseIf _checkfourkind() = 1 Then
        $handrecords[3][1] += 1
    ElseIf _checkfullhouse() = 1 Then
        $handrecords[4][1] += 1
    ElseIf _checkflush() = 1 Then
        $handrecords[5][1] += 1
    ElseIf _checkstraight() = 1 Then
        $handrecords[6][1] += 1
    ElseIf _checkthreekind() = 1 Then
        $handrecords[7][1] += 1
    ElseIf _checktwopair() = 1 Then
        $handrecords[8][1] += 1
    ElseIf _onepair() = 1 Then
        $handrecords[9][1] += 1
    ElseIf _highcard() = 1 Then
        $handrecords[10][1] += 1
    EndIf
    ;_ArrayDisplay($handrecords, "2")
EndFunc

Func _checkflush()
    If $c[1][1] = $c[2][1] And $c[2][1] = $c[3][1] And $c[3][1] = $c[4][1] And $c[4][1] = $c[5][1] Then
        Return 1
    EndIf
EndFunc

Func _checkstraight()
    If $c[1][0] - $c[5][0] <= 4 Then
        If $c[1][0] > $c[2][0] And $c[2][0] > $c[3][0] And $c[3][0] > $c[4][0] And $c[4][0] > $c[5][0] Then
            Return 1
        EndIf
    EndIf
EndFunc

Func _checkfourkind()
    Dim $count
    Dim $i
    For $i = 1 to 5
        $count = 0
        If $c[$i][0] = $c[1][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[2][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[3][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[4][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[5][0] Then
            $count += 1
        EndIf
        If $count >= 4 Then
            Return 1
        EndIf
    Next
EndFunc

Func _checkfullhouse()
    Dim $threekind = 0
    Dim $twopair = 0
    Dim $count
    Dim $i
    For $i = 1 to 5
        $count = 0
        If $c[$i][0] = $c[1][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[2][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[3][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[4][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[5][0] Then
            $count += 1
        EndIf
        If $count = 3 Then
            $threekind = 1
        EndIf
        If $count = 2 Then
            $twopair = 1
        EndIf
    Next
    If $threekind = 1 And $twopair = 1 Then
        Return 1
    EndIf
EndFunc

Func _checkthreekind()
    Dim $count
    Dim $i
    For $i = 1 to 5
        $count = 0
        If $c[$i][0] = $c[1][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[2][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[3][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[4][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[5][0] Then
            $count += 1
        EndIf
        If $count >= 3 Then
            Return 1
        EndIf
    Next
EndFunc

Func _checktwopair()
    Dim $twopair = 0
    Dim $count
    Dim $i
    For $i = 1 to 5
        $count = 0
        If $c[$i][0] = $c[1][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[2][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[3][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[4][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[5][0] Then
            $count += 1
        EndIf
        If $count = 2 Then
            $twopair += 1
        EndIf
    Next
    If $twopair = 4 Then
        Return 1
    EndIf
EndFunc

Func _onepair()
    Dim $count
    Dim $i
    For $i = 1 to 5
        $count = 0
        If $c[$i][0] = $c[1][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[2][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[3][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[4][0] Then
            $count += 1
        EndIf
        If $c[$i][0] = $c[5][0] Then
            $count += 1
        EndIf
        If $count >= 2 Then
            Return 1
        EndIf
    Next
EndFunc

Func _highcard()
    ;_ArraySort($pf_card, 1, 1)
    ;MsgBox(0, "", "high card = " & $pf_card[1])
    Return 1
EndFunc

;(1,49)
;(2,48) ;(52) store all cards in [1] array
Func _cardgen()
    Global $cgen[53]
    $cgen[1] = "2s"
    $cgen[2] = "2c"
    $cgen[3] = "2h"
    $cgen[4] = "2d"
    $cgen[5] = "3s"
    $cgen[6] = "3c"
    $cgen[7] = "3h"
    $cgen[8] = "3d"
    $cgen[9] = "4s"
    $cgen[10] = "4c"
    $cgen[11] = "4h"
    $cgen[12] = "4d"
    $cgen[13] = "5s"
    $cgen[14] = "5c"
    $cgen[15] = "5h"
    $cgen[16] = "5d"
    $cgen[17] = "6s"
    $cgen[18] = "6c"
    $cgen[19] = "6h"
    $cgen[20] = "6d"
    $cgen[21] = "7s"
    $cgen[22] = "7c"
    $cgen[23] = "7h"
    $cgen[24] = "7d"
    $cgen[25] = "8s"
    $cgen[26] = "8c"
    $cgen[27] = "8h"
    $cgen[28] = "8d"
    $cgen[29] = "9s"
    $cgen[30] = "9c"
    $cgen[31] = "9h"
    $cgen[32] = "9d"
    $cgen[33] = "Ts"
    $cgen[34] = "Tc"
    $cgen[35] = "Th"
    $cgen[36] = "Td"
    $cgen[37] = "Js"
    $cgen[38] = "Jc"
    $cgen[39] = "Jh"
    $cgen[40] = "Jd"
    $cgen[41] = "Qs"
    $cgen[42] = "Qc"
    $cgen[43] = "Qh"
    $cgen[44] = "Qd"
    $cgen[45] = "Ks"
    $cgen[46] = "Kc"
    $cgen[47] = "Kh"
    $cgen[48] = "Kd"
    $cgen[49] = "As"
    $cgen[50] = "Ac"
    $cgen[51] = "Ah"
    $cgen[52] = "Ad"
EndFunc

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Nice work laffo!

It appears to be funtioning properly, although it is not easy to try other flops, since the posted example only evaluates a flop of "Th Jh Ah". I can plug in other flops manually, or take the time to randomize the flop, but I assume that you are screen scraping the flop (or hooking them from the dealer msgs).

Your ouput shows

Royal flush|1

Straight flush|0

Flush|44

Straight|15

but, since a Royal is by definition a SF, should'nt SF be 1 also? (for example it shows 44 flush possibles and 15 str8s, but no SF)

As for optimizing, I prefer CASE SELECT rather than IF ELSEIF. And I would place the possible hands in decreasing order of probability to reduce the number of evals done (you example appears to look for the least likely hands first). (Edit: Nevermind! I guess you are evaluating all possibilities anyway!) And then run some benchmarks to compare speed differences.

Just some ideas off the top of my head. Looks good.

Edited by Automan Empire

"I've seen your work in the past, and it's novice at best..." SmOke_N

Share this post


Link to post
Share on other sites

Just ran a check of

"3h 2h Ah"

but it did not detect possible str8 or SF

possible problem with A as a low card?


"I've seen your work in the past, and it's novice at best..." SmOke_N

Share this post


Link to post
Share on other sites

thanks for your input automan empire, i'll take some of your notes on board for the next release. although i dont currently plan on doing much more work on this, my aim was to create the hand ranking and good outs info which is displayed in ohi. this for my nl stuff, but i'd also need to scrape the following info before i could cut out ohi entirely. card scrapes, players currently in hand, position. The most time consuming of which would be capturing the cards, especially from multiple sites. i just dont have the time to work on the all out without ohi process, as much as i'd like to :). i also made this script partially to test my self.

Share this post


Link to post
Share on other sites

Yes. It is very tedious to do this for multiple sites, but quite manageable for one site.

I also started at the OPI forum, but wanted to base my decisions on more data, so have moved on.

Enjoyed seeing your work.

gl


"I've seen your work in the past, and it's novice at best..." SmOke_N

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