Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help. Combinatorics and Probability - Analyzing Poker In this assignment,

ID: 3758783 • Letter: P

Question

Please help.

Combinatorics and Probability - Analyzing Poker

In this assignment, you will apply what you have learned about combinatorics and probability to analyze the popular card game of poker.

Specifically, we will simulate a simplified two-player version of "Texas hold 'em" at the end of a round and calculate, given a player's cards and the community cards, the probabilities of the opponent's holding a hand of each possible type as well as the probability of victory.

Simplified rules of Texas hold 'em are provided below; you do not have to know anything more about poker to write this program. Some VBA skeleton code to find the best hand of five cards from the seven in a hand will be provided for you; the important part of this assignment is to learn to calculate (and implement in computer code) the probabilities. If you're writing in another language, this skeleton code may not be available.

Download skeleton code

The Assignment

That is, your program should calculate the probability that your opponent holds each type of hand, as well as the probability your hand is better than your opponent's.

Your program may simplify the usual rules of poker by assuming all hands of equal rank are equivalent, with no "high card" rules. Under this simplification, for example, any two "one pair" hands tie without regard to the rank of the cards, so a pair of aces would be the same as a pair of eights. You may implement the high card rules if they interest you or if you want to have a useful tool handy the next time you play poker, but they aren't required for this assignment. Likewise, we don't need you to implement betting or a GUI here to make a full poker app.

This is the skeleton code:

Explanation / Answer

Dim x(0 To 1) As String x(1) = Right(str, 1) x(0) = Left(str, Len(str) - 1) ParseCard = x End Function Dim str2 As String str2 = str ' we don't want to abuse our actual input string, but a copy If InStr("CSHD", Right(str2, 1)) > 0 Then str2 = Left(str2, Len(str2) - 1) ' strip suit from input string End If Select Case str2 Case "2" CardRank = 2 Case "3" CardRank = 3 Case "4" CardRank = 4 Case "5" CardRank = 5 Case "6" CardRank = 6 Case "7" CardRank = 7 Case "8" CardRank = 8 Case "9" CardRank = 9 Case "10" CardRank = 10 Case "J" CardRank = 11 Case "Q" CardRank = 12 Case "K" CardRank = 13 Case "A" CardRank = 14 Case Else CardRank = 0 End Select End Function Function HandRank(handtype As String) Select Case handtype Case "royal flush" ' royal flushes are just counted as straight flushes in the code below HandRank = 9 Case "straight flush" HandRank = 8 Case "four of a kind" HandRank = 7 Case "full house" HandRank = 6 Case "flush" HandRank = 5 Case "straight" HandRank = 4 Case "three of a kind" HandRank = 3 Case "two pair" HandRank = 2 Case "one pair" HandRank = 1 Case "nothing" HandRank = 0 Case Else HandRank = 0 End Select End Function Else If (HandRank(hand2(0))