Author Archive

Evaluate a Poker Hand VB.NET

Posted July 1, 2013 By martin

 

Public Class Form1
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim CardValues As String() = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"}
        Dim CardSuits As String() = {"Hearts", "Spades", "Clubs", "Diamonds"}
        For Each value As String In CardValues
            ddlValue1.Items.Add(value)
            ddlValue2.Items.Add(value)
            ddlValue3.Items.Add(value)
            ddlValue4.Items.Add(value)
            ddlValue5.Items.Add(value)
        Next
        For Each value As String In CardSuits
            ddlSuit1.Items.Add(value)
            ddlSuit2.Items.Add(value)
            ddlSuit3.Items.Add(value)
            ddlSuit4.Items.Add(value)
            ddlSuit5.Items.Add(value)
        Next
    End Sub
    Private Function GetSuit(ByVal DropDownSuit As String) As Integer
        Dim retVal As Integer
        Select Case DropDownSuit
            Case "Clubs"
                retVal = 0
            Case "Diamonds"
                retVal = 1
            Case "Hearts"
                retVal = 2
            Case "Spades"
                retVal = 3
        End Select
        Return retVal
    End Function
    Private Function GetFace(ByVal DropDownFace As String) As Integer
        Dim retVal As Integer
        Select Case DropDownFace
            Case "Ace"
                retVal = 0
            Case "2"
                retVal = 1
            Case "3"
                retVal = 2
            Case "4"
                retVal = 3
            Case "5"
                retVal = 4
            Case "6"
                retVal = 5
            Case "7"
                retVal = 6
            Case "8"
                retVal = 7
            Case "9"
                retVal = 8
            Case "10"
                retVal = 9
            Case "Jack"
                retVal = 10
            Case "Queen"
                retVal = 11
            Case "King"
                retVal = 12
        End Select
        Return retVal
    End Function
    Private Sub btnGetHand_Click(sender As System.Object, e As System.EventArgs) Handles btnGetHand.Click
        If ddlSuit1.Text = "" Or ddlSuit2.Text = "" Or ddlSuit3.Text = "" Or ddlSuit4.Text = "" Or ddlSuit5.Text = "" Or _
            ddlValue1.Text = "" Or ddlValue2.Text = "" Or ddlValue3.Text = "" Or ddlValue4.Text = "" Or ddlValue5.Text = "" Then
            MsgBox("All boxes need to have a value.")
        Else
            lblHandDisplay.Text = CreateHand()
        End If
    End Sub
    Private Function CreateHand() As String
        Dim retHand As String = ""
        Dim hand(3, 12) As Integer
        '1st Card
        hand(GetSuit(ddlSuit1.Text), GetFace(ddlValue1.Text)) = 1
        '2nd Card
        hand(GetSuit(ddlSuit2.Text), GetFace(ddlValue2.Text)) = 1
        '3rd Card
        hand(GetSuit(ddlSuit3.Text), GetFace(ddlValue3.Text)) = 1
        '4th Card
        hand(GetSuit(ddlSuit4.Text), GetFace(ddlValue4.Text)) = 1
        '5th Card
        hand(GetSuit(ddlSuit5.Text), GetFace(ddlValue5.Text)) = 1
        If IsStraight(hand) = True AndAlso IsFlush(hand) = True Then
            retHand = "Straight Flush"
        ElseIf IsFourOfAKind(hand) = True Then
            retHand = "4 of a Kind"
        ElseIf IsThreeOfAKind(hand) = True AndAlso IsPair(hand) = True Then
            retHand = "Full House"
        ElseIf IsFlush(hand) = True Then
            retHand = "Flush"
        ElseIf IsStraight(hand) = True Then
            retHand = "Straight"
        ElseIf IsThreeOfAKind(hand) = True Then
            retHand = "3 of a Kind"
        ElseIf IsTwoPair(hand) = True Then
            retHand = "2 Pairs"
        ElseIf IsPair(hand) = True Then
            retHand = "a Pair"
        Else
            retHand = "Nothing"
        End If
        Return retHand
    End Function
    Private Function IsFlush(ByVal hand) As Boolean
        Dim retVal As Boolean = False
        Dim x As Integer = 0
        Dim y As Integer = 0
        Dim fCount As Integer = 0
        Do While x < 4 AndAlso y < 13
            If hand(x, y) = 1 Then
                fCount = fCount + 1
            End If
            y = y + 1
            If fCount = 5 Then
                retVal = True
                Exit Do
            ElseIf fCount <> 5 AndAlso y = 13 AndAlso x < 4 Then
                y = 0
                x = x + 1
                fCount = 0
            ElseIf fCount <> 5 AndAlso y = 13 AndAlso x = 4 Then
                Exit Do
            End If
        Loop
        Return retVal
    End Function
    Private Function IsFourOfAKind(ByVal hand) As Boolean
        Dim retVal As Boolean = False
        Dim x As Integer = 0
        Dim y As Integer = 0
        Dim fKCount As Integer = 0
        Do While x < 5 AndAlso y < 13
            Do While fKCount < 5 AndAlso x < 4
                If hand(x, y) = 1 Then
                    fKCount = fKCount + 1
                End If
                x = x + 1
            Loop
            If fKCount = 4 Then
                retVal = True
                Exit Do
            ElseIf fKCount > 4 Then
                Exit Do
            Else
                y = y + 1
                x = 0
                fKCount = 0
            End If
        Loop
        Return retVal
    End Function
    Private Function IsStraight(ByVal hand) As Boolean
        Dim retVal As Boolean = False
        Dim sCount As Integer = 0
        Dim total As Integer = 0
        Dim x As Integer = 0
        Dim y As Integer = 0
        Do While y < 13
            total = 0
            x = 0
            Do While x < 4
                total = total + hand(x, y)
                x = x + 1
            Loop
            If total > 1 Then
                Exit Do
            ElseIf total = 1 Then
                sCount = sCount + 1
                If sCount = 5 Then
                    retVal = True
                    Exit Do
                End If
            ElseIf total = 0 Then
                sCount = 0
            End If
            y = y + 1
        Loop
        If sCount = 5 Then
            Return retVal
        Else
            Dim Aces As Integer
            Dim Kings As Integer
            Dim Queens As Integer
            Dim Jacks As Integer
            Dim Tens As Integer
            Aces = hand(0, 0) + hand(1, 0) + hand(2, 0) + hand(3, 0)
            Kings = hand(0, 12) + hand(1, 12) + hand(2, 12) + hand(3, 12)
            Queens = hand(0, 11) + hand(1, 11) + hand(2, 11) + hand(3, 11)
            Jacks = hand(0, 10) + hand(1, 10) + hand(2, 10) + hand(3, 10)
            Tens = hand(0, 9) + hand(1, 9) + hand(2, 9) + hand(3, 9)
            If Aces + Kings + Queens + Jacks + Tens = 5 Then
                retVal = True
            End If
            Return retVal
        End If
    End Function
    Private Function IsThreeOfAKind(ByVal hand) As Boolean
        Dim retVal As Boolean = False
        Dim x As Integer = 0
        Dim y As Integer = 0
        Dim tKCount As Integer = 0
        Do While x < 4 AndAlso y < 13
            Do While tKCount < 4 AndAlso x < 4
                If hand(x, y) = 1 Then
                    tKCount = tKCount + 1
                End If
                x = x + 1
            Loop
            If tKCount = 3 Then
                retVal = True
                Exit Do
            ElseIf tKCount > 3 Then
                Exit Do
            Else
                y = y + 1
                x = 0
                tKCount = 0
            End If
        Loop
        Return retVal
    End Function
    Private Function IsPair(ByVal hand) As Boolean
        Dim retVal As Boolean = False
        Dim x As Integer = 0
        Dim y As Integer = 0
        Dim pCount As Integer = 0
        Do While x < 4 AndAlso y < 13
            Do While pCount < 3 AndAlso x < 4
                If hand(x, y) = 1 Then
                    pCount = pCount + 1
                End If
                x = x + 1
            Loop
            If pCount = 2 Then
                retVal = True
                Exit Do
            ElseIf pCount > 2 AndAlso y > 12 Then
                Exit Do
            ElseIf pCount <= 3 Then
                y = y + 1
                x = 0
                pCount = 0
            End If
        Loop
        Return retVal
    End Function
    Private Function IsTwoPair(ByVal hand) As Boolean
        Dim retVal As Boolean = False
        Dim x As Integer = 0
        Dim y As Integer = 0
        Dim pCount As Integer = 0
        Dim p2Count As Integer = 0
        Do While x < 4 AndAlso y < 13
            Do While pCount < 3 AndAlso x < 4
                If hand(x, y) = 1 Then
                    pCount = pCount + 1
                End If
                x = x + 1
            Loop
            If pCount = 2 Then
                Exit Do
            ElseIf pCount > 2 Then
                Exit Do
            Else
                y = y + 1
                x = 0
                pCount = 0
            End If
        Loop
        y = y + 1
        x = 0
        If pCount = 2 Then
            Do While x < 4 AndAlso y < 13
                Do While p2Count < 3 AndAlso x < 4
                    If hand(x, y) = 1 Then
                        p2Count = p2Count + 1
                    End If
                    x = x + 1
                Loop
                If pCount = 2 AndAlso p2Count = 2 Then
                    retVal = True
                    Exit Do
                ElseIf p2Count > 2 Then
                    Exit Do
                Else
                    y = y + 1
                    x = 0
                    p2Count = 0
                End If
            Loop
            Return retVal
        Else
            Return retVal
        End If
    End Function
End Class
1 Comment. Join the Conversation

PokerStars To Fight Kentucky in Court

Posted June 27, 2013 By martin

The USA is full of contrasting laws that seem to keep everyone guessing what’s what. An issue that stems back to 2008 in the State of Kentucky when 140 online gambling domains were seized based on the state’s legal definition of the confiscated domains as “gambling devices” illegally offering services to residents has again surfaced.
The parent firms of online poker operator PokerStars have filed a motion to dismiss with prejudice the Commonwealth of Kentucky’s claim on the PokerStars.com domain name. Kentucky made a similar claim at the federal level following the US Department of Justice’s seizure of PokerStars.com domain on April 15, 2011.
The latter claim resulted in the federal government writing a cheque in exchange for the state dropping its claims on AbsolutePoker.com and UltimateBet.com. Kentucky announced its $6m remittance it announced its intent to pursue the claim against PokerStars.com.

Lawyers for Rational Entertainment Enterprises Ltd. and Rational Intellectual Holdings Ltd. contend that Kentucky has never provided the firms with notice that the PokerStars.com domain had been targeted, nor allowed them the opportunity to challenge the alleged seizure in any court.

The parent companies also challenge Kentucky’s very broad definition of “gambling devices.” Both firms note that the state’s own Court of Appeals rejected the inclusion of domains as gambling devices when the Interactive Media Entertainment and Gaming Association contested the 2008 domain seizures, an opinion that was not challenged when the state Supreme Court reviewed the case one year later.

Paying the State of Kentucky has released another firm Bwin.party digital entertainment from any possible sanctions after Bwin. party paid Kentucky $15 million for civil suit violations back in 2010. The governor of Kentucky Steve Beshear, said in praise of Bwin.party for, “making every effort to comply with the laws of the United States.” It may be a less than profitable move by PokerStars to fight Kentucky while pursuing a license to operate in New Jersey.

Be the first to comment

Player Drafts His Own Online Poker Legislation

Posted June 24, 2013 By martin

PokerXanadu Internet Wagering Citizens Protection Act

In an attempt to reduce the friction in the legislative process, avid poker enthusiast Martin Shapiro, better known by his forum screen name PokerXanadu, has authored a document the he hopes is both friendly to players and can garner enough support from special interest groups to be passed into law.

At both the state and federal level in the US, legislators have had difficult time crafting online poker legislation that is acceptable to the wide array of stakeholders. To date only Delaware, New Jersey and Nevada have been able to enact laws regulating online poker though many more states, as well as federal lawmakers, have tried to do so in recent years.

Shapiro believes his document can serve as a guideline for lawmakers to understand the protections that are important to poker-playing consumers while at the same time creating a bill that is “passable in today’s political climate.”

“I undertook this venture because no one else was doing it,” Shapiro told pokerfuse. “Every bill that has been introduced to Congress to date has been an incomplete bill and which isn’t passable because it is partisan to a limited number of vested interests.”

“I thought it time to come out with a bill which covers every issue, preserves all the protections and rights of players and sufficiently meets the needs of all the major vested interests in a compromise with which they can support.”

Internet Wagering Citizens Protection Act

The bill, currently a work in progress, would legalize online poker but restrict other forms of online gambling.

The Act combines what Shapiro sees as the best of previously introduced legislation including provisions from current federally proposed bills by US Representatives King and Barton, and various other attempted legislative efforts.

Shapiro’s act is in depth and covers such topics as licensing, taxation of operators and consumers, enforcement measures, regulatory oversight, consumer protections, and updates to existing federal laws including the Unlawful Internet Gambling Enforcement Act (UIGEA), The Wire Act and the Illegal Gambling Business Act (IGBA). Shapiro has even included his own version of a “bad actor clause.”

“I included a bad actors clause because I don’t think a bill would be able to pass the current Congress without one,” Shapiro said. However, he believes that “true bad actors” deserve no place in the newly regulated US market.

“I don’t think there is anyone so far that would be excluded [under the terms of his proposed legislation] except for a few who were convicted for offering sports wagering. In the future, this provision will protect us from true bad actors.”

Shapiro is soliciting feedback on his work from the poker community.

“My greatest hope is that someone with influence in DC will carry this bill forward.” Shapiro plans to present his work to Reps. King and Barton as well as US Senators from Nevada, Harry Reid and Dean Heller, both of whom have spoken out in favor of federal regulation of online poker.

By Michael Gentile

July 22, 2013

Be the first to comment

Hit Counter provided by shuttle service from lax