Time to win at Texas Hold-em. You are getting two cards. It could be a pair (5.9
ID: 3619543 • Letter: T
Question
Time to win at Texas Hold-em. You are getting two cards. It could be a pair (5.9% chance), it could be suited (23.5%, good for flush prospects), it could be unsuited and unpaired (70.6%). At this stage, before ‘the flop’:• Pair beats other cards unless both cards better (overcards) to the pair.
• Suited beats non-pair unless one of the other cards is an overcard
• Unpaired & unsuited beats same if it has the overcard, otherwise tie.
You’re dealt {K,9} of clubs “the black dog”. The opponent has one of 50x49=1,225 hands. Write a program with the rules above to estimate outcomes for each hand. Divide winning situations by losing situations (ignore ties). What are the ‘odds’ of you winning?
Explanation / Answer
brute force method, pseudocode: enum suitType { clubs spades hearts diamonds } struct card{ int value (2-14, jack is 11, queen is 12, king is 13, ace is 14) suitType suit } int allValues[] = {2; 3; 4; 5...14;} suitType allSuits[] = {clubs; spades...} List allCards; foreach (value in allValues) { foreach (suit in AllSuits) allCards.add Card(value, suit) } } allCards.remove(Card(13(king), clubs); allCards.remove(Carc(9,clubs); build a list of all possible hands opponent can have (two for loops) this will be in form list loop through this list of hands and just check against your hand for all the given conditions and add to counters i.e. pairs automatically beat you, so add one to loseCounter all unsuited hands automatically lose, so add one to winCounter and handle all other events too, with if statements then just do the math at the end with lose and win counters good luck, sorry so pseudo, but i g2g and it good practice to figure out the code anyways =)Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.